1
0
Fork 0

corrected sub-string indexing for nested arrays

This commit is contained in:
Kevin Matz 2023-05-13 11:36:45 -04:00
parent 81746d635e
commit 706fe5a3f9
1 changed files with 4 additions and 2 deletions

View File

@ -98,7 +98,7 @@ std::vector<std::shared_ptr<Argument>> Message::createArguments(std::string type
{
args.emplace_back(std::make_shared<array>());
auto arg = std::static_pointer_cast<array>(args.back());
std::string::size_type close = pos;
std::string::size_type close = ++pos;
int depth = 1;
while (depth > 0)
{
@ -110,15 +110,17 @@ std::vector<std::shared_ptr<Argument>> Message::createArguments(std::string type
}
if (types.at(close) == '[') // nested braces, keep going
{
close++;
depth++;
continue;
}
if (types.at(close) == ']') // closed this level of nesting
{
close++;
depth--;
}
}
arg->setTypes(types.substr(pos+1, close-(pos+1)));
arg->setTypes(types.substr(pos, close-(pos)));
pos = close;
}
break;