Fixed new API node key/value insertion in NodeBuilder (it was using the wrong condition on when it had added a key already)

This commit is contained in:
Jesse Beder
2011-09-12 13:25:41 -05:00
parent 41533a8c49
commit 3337df7ca2
2 changed files with 8 additions and 5 deletions

View File

@@ -86,7 +86,7 @@ namespace YAML
RegisterAnchor(anchor, node);
if(needsKey)
m_keys.push_back(&node);
m_keys.push_back(Key(&node, false));
return node;
}
@@ -108,10 +108,12 @@ namespace YAML
if(collection.type() == NodeType::Sequence) {
collection.append(node, m_pMemory);
} else if(collection.type() == NodeType::Map) {
detail::node& key = *m_keys.back();
if(&key != &node) {
Key& key = m_keys.back();
if(key.second) {
collection.insert(*key.first, node, m_pMemory);
m_keys.pop_back();
collection.insert(key, node, m_pMemory);
} else {
key.second = true;
}
} else {
assert(false);

View File

@@ -47,7 +47,8 @@ namespace YAML
Nodes m_stack;
Nodes m_anchors;
Nodes m_keys;
typedef std::pair<detail::node *, bool> Key;
std::vector<Key> m_keys;
std::size_t m_mapDepth;
};
}