corrected sub-string indexing for nested arrays
This commit is contained in:
parent
81746d635e
commit
706fe5a3f9
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue