YAMLDocReader sequence fix

This commit is contained in:
Jack Andersen 2016-03-28 11:37:55 -10:00
parent 821e9c505e
commit ae14d51607
1 changed files with 31 additions and 13 deletions

View File

@ -549,6 +549,8 @@ public:
{ {
int& seqIdx = m_seqTrackerStack.back(); int& seqIdx = m_seqTrackerStack.back();
m_subStack.push_back(curSub->m_seqChildren[seqIdx++].get()); m_subStack.push_back(curSub->m_seqChildren[seqIdx++].get());
if (m_subStack.back()->m_type == YAML_SEQUENCE_NODE)
m_seqTrackerStack.push_back(0);
return true; return true;
} }
for (const auto& item : curSub->m_mapChildren) for (const auto& item : curSub->m_mapChildren)
@ -556,6 +558,8 @@ public:
if (!item.first.compare(name)) if (!item.first.compare(name))
{ {
m_subStack.push_back(item.second.get()); m_subStack.push_back(item.second.get());
if (m_subStack.back()->m_type == YAML_SEQUENCE_NODE)
m_seqTrackerStack.push_back(0);
return true; return true;
} }
} }
@ -565,8 +569,12 @@ public:
void leaveSubRecord() void leaveSubRecord()
{ {
if (m_subStack.size() > 1) if (m_subStack.size() > 1)
{
if (m_subStack.back()->m_type == YAML_SEQUENCE_NODE)
m_seqTrackerStack.pop_back();
m_subStack.pop_back(); m_subStack.pop_back();
} }
}
template <class T> template <class T>
void enumerate(const char* name, T& record) void enumerate(const char* name, T& record)
@ -579,6 +587,15 @@ public:
bool enterSubVector(const char* name, size_t& countOut) bool enterSubVector(const char* name, size_t& countOut)
{ {
YAMLNode* curSub = m_subStack.back(); YAMLNode* curSub = m_subStack.back();
if (!name && curSub->m_type == YAML_SEQUENCE_NODE)
{
m_subStack.push_back(curSub);
m_seqTrackerStack.push_back(0);
countOut = curSub->m_seqChildren.size();
return true;
}
else
{
for (const auto& item : curSub->m_mapChildren) for (const auto& item : curSub->m_mapChildren)
{ {
if (!item.first.compare(name)) if (!item.first.compare(name))
@ -598,6 +615,7 @@ public:
return true; return true;
} }
} }
}
countOut = 0; countOut = 0;
return false; return false;
} }