本文整理汇总了C++中YamlNode::AddNodeToArray方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::AddNodeToArray方法的具体用法?C++ YamlNode::AddNodeToArray怎么用?C++ YamlNode::AddNodeToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::AddNodeToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
bool YamlParser::Parse(YamlDataHolder * dataHolder)
{
yaml_parser_t parser;
yaml_event_t event;
int done = 0;
/* Create the Parser object. */
yaml_parser_initialize(&parser);
yaml_parser_set_encoding(&parser, YAML_UTF8_ENCODING);
/* Set a string input. */
//yaml_parser_set_input_string(&parser, (const unsigned char*)pathName.c_str(), pathName.length());
yaml_parser_set_input(&parser, read_handler, dataHolder);
String lastMapKey;
bool isKeyPresent = false;
/* Read the event sequence. */
while (!done)
{
/* Get the next event. */
if (!yaml_parser_parse(&parser, &event))
{
Logger::Error("[YamlParser::Parse] error: type: %d %s line: %d pos: %d", parser.error, parser.problem, parser.problem_mark.line, parser.problem_mark.column);
break;
}
switch(event.type)
{
case YAML_ALIAS_EVENT:
Logger::FrameworkDebug("[YamlParser::Parse] alias: %s", event.data.alias.anchor);
break;
case YAML_SCALAR_EVENT:
{
String scalarValue = (const char*)event.data.scalar.value;
if (objectStack.empty())
{
YamlNode * node = YamlNode::CreateStringNode();
node->Set(scalarValue);
rootObject = node;
}
else
{
YamlNode * topContainer = objectStack.top();
DVASSERT(topContainer->GetType() != YamlNode::TYPE_STRING);
if (topContainer->GetType() == YamlNode::TYPE_MAP)
{
if (!isKeyPresent)
{
lastMapKey = scalarValue;
}
else
{
topContainer->Add(lastMapKey, scalarValue);
}
isKeyPresent = !isKeyPresent;
}
else if (topContainer->GetType() == YamlNode::TYPE_ARRAY)
{
topContainer->Add(scalarValue);
}
}
}
break;
case YAML_DOCUMENT_START_EVENT:
//Logger::FrameworkDebug("document start:");
break;
case YAML_DOCUMENT_END_EVENT:
//Logger::FrameworkDebug("document end:");
break;
case YAML_SEQUENCE_START_EVENT:
{
YamlNode * node = YamlNode::CreateArrayNode();
if (objectStack.empty())
{
rootObject = node;
}
else
{
YamlNode * topContainer = objectStack.top();
DVASSERT(topContainer->GetType() != YamlNode::TYPE_STRING);
if (topContainer->GetType() == YamlNode::TYPE_MAP)
{
DVASSERT(isKeyPresent);
topContainer->AddNodeToMap(lastMapKey, node);
isKeyPresent = false;
}
else if (topContainer->GetType() == YamlNode::TYPE_ARRAY)
{
topContainer->AddNodeToArray(node);
}
//.........这里部分代码省略.........