Added case for parsing a compact key: value pair in a flow sequence with a null key

This commit is contained in:
Jesse Beder
2009-10-29 22:01:01 +00:00
parent fadc2ad39f
commit d372729b92
3 changed files with 23 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ namespace YAML
case Token::BLOCK_MAP_START: ParseBlock(pScanner, state); break;
case Token::FLOW_MAP_START: ParseFlow(pScanner, state); break;
case Token::FLOW_MAP_COMPACT: ParseCompact(pScanner, state); break;
case Token::VALUE: ParseCompactWithNoKey(pScanner, state); break;
default: break;
}
}
@@ -178,6 +179,20 @@ namespace YAML
m_data[pKey.release()] = pValue.release();
}
// ParseCompactWithNoKey
// . Single key: value pair in a flow sequence
void Map::ParseCompactWithNoKey(Scanner *pScanner, const ParserState& state)
{
std::auto_ptr <Node> pKey(new Node), pValue(new Node);
// grab value
pScanner->pop();
pValue->Parse(pScanner, state);
// assign the map with the actual pointers
m_data[pKey.release()] = pValue.release();
}
void Map::Write(Emitter& out) const
{
out << BeginMap;