Value GetResult();
private:
- struct Node
- {
- union
- {
- Dictionary *Object;
- Array *Aray;
- };
-
- bool IsObject;
- };
-
Value m_Root;
- std::stack<Node> m_CurrentSubtree;
+ std::stack<std::pair<Dictionary*, Array*>> m_CurrentSubtree;
String m_CurrentKey;
void FillCurrentTarget(Value value);
FillCurrentTarget(object);
- m_CurrentSubtree.push(Node{{.Object = object}, true});
+ m_CurrentSubtree.push({object, nullptr});
return true;
}
FillCurrentTarget(array);
- m_CurrentSubtree.push(Node{{.Aray = array}, false});
+ m_CurrentSubtree.push({nullptr, array});
return true;
}
} else {
auto& node (m_CurrentSubtree.top());
- if (node.IsObject) {
- node.Object->Set(m_CurrentKey, value);
+ if (node.first) {
+ node.first->Set(m_CurrentKey, value);
} else {
- node.Aray->Add(value);
+ node.second->Add(value);
}
}
}