mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Skip until first non empty line for templater
This commit is contained in:
parent
e8baf65134
commit
f574204e61
@ -1,11 +1,14 @@
|
|||||||
#pragma options TEST(asdf, bla)
|
#pragma options TEST(asdf, bla)
|
||||||
#pragma switch TEST_SWITCH
|
#pragma switch TEST_SWITCH
|
||||||
|
|
||||||
#ifdef TEST_SWITCH
|
#ifdef TEST_SWITCH
|
||||||
#define SVAL "1"
|
#define SVAL "1"
|
||||||
#else
|
#else
|
||||||
#define SVAL "0"
|
#define SVAL "0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma filename "lemao_" + TEST + SVAL + ".txt"
|
#pragma filename "lemao_" + TEST + SVAL + ".txt"
|
||||||
|
|
||||||
HAHA TEST
|
HAHA TEST
|
||||||
#ifdef TEST_SWITCH
|
#ifdef TEST_SWITCH
|
||||||
kekw
|
kekw
|
||||||
|
40
src/Parser/Parsing/Impl/SkipUntilFirstNonEmptyProxy.cpp
Normal file
40
src/Parser/Parsing/Impl/SkipUntilFirstNonEmptyProxy.cpp
Normal 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();
|
||||||
|
}
|
19
src/Parser/Parsing/Impl/SkipUntilFirstNonEmptyProxy.h
Normal file
19
src/Parser/Parsing/Impl/SkipUntilFirstNonEmptyProxy.h
Normal 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;
|
||||||
|
};
|
@ -12,6 +12,7 @@
|
|||||||
#include "Parsing/ParsingException.h"
|
#include "Parsing/ParsingException.h"
|
||||||
#include "Parsing/Impl/DefinesStreamProxy.h"
|
#include "Parsing/Impl/DefinesStreamProxy.h"
|
||||||
#include "Parsing/Impl/ParserSingleInputStream.h"
|
#include "Parsing/Impl/ParserSingleInputStream.h"
|
||||||
|
#include "Parsing/Impl/SkipUntilFirstNonEmptyProxy.h"
|
||||||
|
|
||||||
using namespace templating;
|
using namespace templating;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@ -33,15 +34,17 @@ namespace templating
|
|||||||
m_templating_proxy = std::make_unique<TemplatingStreamProxy>(m_base_stream.get(), templaterControl);
|
m_templating_proxy = std::make_unique<TemplatingStreamProxy>(m_base_stream.get(), templaterControl);
|
||||||
m_defines_proxy = std::make_unique<DefinesStreamProxy>(m_templating_proxy.get());
|
m_defines_proxy = std::make_unique<DefinesStreamProxy>(m_templating_proxy.get());
|
||||||
m_directive_escape_proxy = std::make_unique<DirectiveEscapeStreamProxy>(m_defines_proxy.get());
|
m_directive_escape_proxy = std::make_unique<DirectiveEscapeStreamProxy>(m_defines_proxy.get());
|
||||||
|
m_skip_until_first_non_empty_proxy = std::make_unique<SkipUntilFirstNonEmptyProxy>(m_directive_escape_proxy.get());
|
||||||
|
|
||||||
m_templating_proxy->SetDefinesProxy(m_defines_proxy.get());
|
m_templating_proxy->SetDefinesProxy(m_defines_proxy.get());
|
||||||
m_stream = m_directive_escape_proxy.get();
|
m_stream = m_skip_until_first_non_empty_proxy.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IParserLineStream> m_base_stream;
|
std::unique_ptr<IParserLineStream> m_base_stream;
|
||||||
std::unique_ptr<TemplatingStreamProxy> m_templating_proxy;
|
std::unique_ptr<TemplatingStreamProxy> m_templating_proxy;
|
||||||
std::unique_ptr<DefinesStreamProxy> m_defines_proxy;
|
std::unique_ptr<DefinesStreamProxy> m_defines_proxy;
|
||||||
std::unique_ptr<DirectiveEscapeStreamProxy> m_directive_escape_proxy;
|
std::unique_ptr<DirectiveEscapeStreamProxy> m_directive_escape_proxy;
|
||||||
|
std::unique_ptr<SkipUntilFirstNonEmptyProxy> m_skip_until_first_non_empty_proxy;
|
||||||
IParserLineStream* m_stream;
|
IParserLineStream* m_stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user