mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Make skipping lines in defines stream proxy configurable
This commit is contained in:
parent
379aabebd6
commit
6702856399
@ -122,8 +122,9 @@ void DefinesStreamProxy::Define::IdentifyParameters(const std::vector<std::strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DefinesStreamProxy::DefinesStreamProxy(IParserLineStream* stream)
|
DefinesStreamProxy::DefinesStreamProxy(IParserLineStream* stream, const bool skipDirectiveLines)
|
||||||
: m_stream(stream),
|
: m_stream(stream),
|
||||||
|
m_skip_directive_lines(skipDirectiveLines),
|
||||||
m_ignore_depth(0),
|
m_ignore_depth(0),
|
||||||
m_in_define(false)
|
m_in_define(false)
|
||||||
{
|
{
|
||||||
@ -668,10 +669,22 @@ ParserLine DefinesStreamProxy::NextLine()
|
|||||||
if (m_in_define)
|
if (m_in_define)
|
||||||
{
|
{
|
||||||
ContinueDefine(line);
|
ContinueDefine(line);
|
||||||
|
if (!m_skip_directive_lines)
|
||||||
|
{
|
||||||
|
line.m_line = std::string();
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
line = m_stream->NextLine();
|
line = m_stream->NextLine();
|
||||||
}
|
}
|
||||||
else if (MatchDirectives(line) || !m_modes.empty() && m_modes.top() != BlockMode::IN_BLOCK)
|
else if (MatchDirectives(line) || !m_modes.empty() && m_modes.top() != BlockMode::IN_BLOCK)
|
||||||
{
|
{
|
||||||
|
if (!m_skip_directive_lines)
|
||||||
|
{
|
||||||
|
line.m_line = std::string();
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
line = m_stream->NextLine();
|
line = m_stream->NextLine();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -54,6 +54,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
IParserLineStream* const m_stream;
|
IParserLineStream* const m_stream;
|
||||||
|
const bool m_skip_directive_lines;
|
||||||
std::map<std::string, Define> m_defines;
|
std::map<std::string, Define> m_defines;
|
||||||
std::stack<BlockMode> m_modes;
|
std::stack<BlockMode> m_modes;
|
||||||
unsigned m_ignore_depth;
|
unsigned m_ignore_depth;
|
||||||
@ -79,7 +80,7 @@ private:
|
|||||||
bool FindDefineForWord(const ParserLine& line, unsigned wordStart, unsigned wordEnd, Define*& value);
|
bool FindDefineForWord(const ParserLine& line, unsigned wordStart, unsigned wordEnd, Define*& value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DefinesStreamProxy(IParserLineStream* stream);
|
DefinesStreamProxy(IParserLineStream* stream, bool skipDirectiveLines = false);
|
||||||
|
|
||||||
void AddDefine(Define define);
|
void AddDefine(Define define);
|
||||||
void Undefine(const std::string& name);
|
void Undefine(const std::string& name);
|
||||||
|
@ -32,7 +32,7 @@ namespace templating
|
|||||||
m_base_stream = std::make_unique<ParserSingleInputStream>(stream, fileName);
|
m_base_stream = std::make_unique<ParserSingleInputStream>(stream, fileName);
|
||||||
|
|
||||||
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(), true);
|
||||||
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_skip_until_first_non_empty_proxy = std::make_unique<SkipUntilFirstNonEmptyProxy>(m_directive_escape_proxy.get());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user