Skip until first non empty line for templater

This commit is contained in:
Jan
2022-09-05 23:51:09 +02:00
parent e8baf65134
commit f574204e61
4 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,40 @@
#include "SkipUntilFirstNonEmptyProxy.h"
SkipUntilFirstNonEmptyProxy::SkipUntilFirstNonEmptyProxy(IParserLineStream* stream)
: m_stream(stream),
m_had_non_empty(false)
{
}
ParserLine SkipUntilFirstNonEmptyProxy::NextLine()
{
auto line = m_stream->NextLine();
if (!m_had_non_empty)
{
while (line.m_line.empty() && !m_stream->Eof())
line = m_stream->NextLine();
m_had_non_empty = true;
}
return line;
}
bool SkipUntilFirstNonEmptyProxy::IncludeFile(const std::string& filename)
{
return m_stream->IncludeFile(filename);
}
void SkipUntilFirstNonEmptyProxy::PopCurrentFile()
{
m_stream->PopCurrentFile();
}
bool SkipUntilFirstNonEmptyProxy::IsOpen() const
{
return m_stream->IsOpen();
}
bool SkipUntilFirstNonEmptyProxy::Eof() const
{
return m_stream->Eof();
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "Parsing/IParserLineStream.h"
class SkipUntilFirstNonEmptyProxy final : public IParserLineStream
{
public:
explicit SkipUntilFirstNonEmptyProxy(IParserLineStream* stream);
ParserLine NextLine() override;
bool IncludeFile(const std::string& filename) override;
void PopCurrentFile() override;
_NODISCARD bool IsOpen() const override;
_NODISCARD bool Eof() const override;
private:
IParserLineStream* const m_stream;
bool m_had_non_empty;
};