mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-05-09 14:04:57 +00:00
Make defines proxy accept parameter values that have parenthesis
This commit is contained in:
parent
e7eb43a955
commit
e94c48338c
@ -504,6 +504,7 @@ void DefinesStreamProxy::ExtractParametersFromDefineUsage(const ParserLine& line
|
||||
std::ostringstream currentValue;
|
||||
auto pos = parameterStart + 1;
|
||||
auto valueHasStarted = false;
|
||||
auto parenthesisDepth = 0;
|
||||
while (true)
|
||||
{
|
||||
if (pos >= line.m_line.size())
|
||||
@ -518,11 +519,26 @@ void DefinesStreamProxy::ExtractParametersFromDefineUsage(const ParserLine& line
|
||||
currentValue.str(std::string());
|
||||
valueHasStarted = false;
|
||||
}
|
||||
else if(c == '(')
|
||||
{
|
||||
valueHasStarted = true;
|
||||
parenthesisDepth++;
|
||||
currentValue << c;
|
||||
}
|
||||
else if (c == ')')
|
||||
{
|
||||
parameterValues.emplace_back(currentValue.str());
|
||||
parameterEnd = pos + 1;
|
||||
break;
|
||||
if(parenthesisDepth > 0)
|
||||
{
|
||||
valueHasStarted = true;
|
||||
parenthesisDepth--;
|
||||
currentValue << c;
|
||||
}
|
||||
else
|
||||
{
|
||||
parameterValues.emplace_back(currentValue.str());
|
||||
parameterEnd = pos + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (valueHasStarted || !isspace(c))
|
||||
{
|
||||
|
@ -670,4 +670,21 @@ namespace test::parsing::impl::defines_stream_proxy
|
||||
|
||||
REQUIRE(proxy.Eof());
|
||||
}
|
||||
|
||||
TEST_CASE("DefinesStreamProxy: Ensure can use parenthesis in parameters values", "[parsing][parsingstream]")
|
||||
{
|
||||
const std::vector<std::string> lines
|
||||
{
|
||||
"#define someStuff(param1) Hello param1 World",
|
||||
"someStuff(A sentence with (parenthesis) and stuff)"
|
||||
};
|
||||
|
||||
MockParserLineStream mockStream(lines);
|
||||
DefinesStreamProxy proxy(&mockStream);
|
||||
|
||||
ExpectLine(&proxy, 1, "");
|
||||
ExpectLine(&proxy, 2, "Hello A sentence with (parenthesis) and stuff World");
|
||||
|
||||
REQUIRE(proxy.Eof());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user