本文整理汇总了C++中YamlNode::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::GetType方法的具体用法?C++ YamlNode::GetType怎么用?C++ YamlNode::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
RefPtr<PropertyLine<float32> > PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(YamlNode * parentNode, const String & propertyName, RefPtr<PropertyLine<float32> > defaultPropertyLine)
{
YamlNode * node = parentNode->Get(propertyName);
if (!node)return defaultPropertyLine;
if (node->GetType() == YamlNode::TYPE_STRING)
{
return RefPtr< PropertyLine<float32> >(new PropertyLineValue<float32>(node->AsFloat()));
}else if (node->GetType() == YamlNode::TYPE_ARRAY)
{
RefPtr<PropertyLineKeyframes<float32> > keyframes(new PropertyLineKeyframes<float32>());
for (int k = 0; k < node->GetCount() / 2; ++k)
{
YamlNode * time = node->Get(k * 2);
YamlNode * value = node->Get(k * 2 + 1);
if (time && value)
{
keyframes->AddValue(time->AsFloat(), value->AsFloat());
}
}
return keyframes;
}
return RefPtr<PropertyLine<float32> >();
}
示例2: res
RefPtr< PropertyLine<Vector2> > PropertyLineYamlReader::CreateVector2PropertyLineFromYamlNode( YamlNode * parentNode, const String & propertyName, RefPtr< PropertyLine<Vector2> > defaultPropertyLine /*= 0*/ )
{
YamlNode * node = parentNode->Get(propertyName);
if (!node)return defaultPropertyLine;
if (node->GetType() == YamlNode::TYPE_STRING)
{
float32 v = node->AsFloat();
return RefPtr< PropertyLine<Vector2> >(new PropertyLineValue<Vector2>(Vector2(v, v)));
}else if (node->GetType() == YamlNode::TYPE_ARRAY)
{
if (node->GetCount() == 2)
{
Vector2 res(1.0f, 1.0f);
res = node->AsPoint();
return RefPtr< PropertyLine<Vector2> >(new PropertyLineValue<Vector2>(res));
}
RefPtr< PropertyLineKeyframes<Vector2> > keyframes (new PropertyLineKeyframes<Vector2>());
for (int k = 0; k < node->GetCount() / 2; ++k)
{
YamlNode * time = node->Get(k * 2);
YamlNode * value = node->Get(k * 2 + 1);
if (time && value)
{
if (value->GetType() == YamlNode::TYPE_ARRAY)
{
keyframes->AddValue(time->AsFloat(), value->AsPoint());
}
else
{
float32 v = value->AsFloat();
keyframes->AddValue(time->AsFloat(), Vector2(v, v));
}
}
}
return keyframes;
}
return RefPtr< PropertyLine<Vector2> >();
}
示例3: keyframes
RefPtr< PropertyLine<Color> > PropertyLineYamlReader::CreateColorPropertyLineFromYamlNode( YamlNode * parentNode, const String & propertyName, RefPtr< PropertyLine<Color> > defaultPropertyLine)
{
YamlNode * node = parentNode->Get(propertyName);
if (!node)return defaultPropertyLine;
if (node->GetType() == YamlNode::TYPE_ARRAY)
{
bool allString = true;
for (int k = 0; k < node->GetCount(); ++k)
if (node->Get(k)->GetType() != YamlNode::TYPE_STRING)
allString = false;
if (allString && node->GetCount() == 4)
{
return RefPtr< PropertyLine<Color> >(new PropertyLineValue<Color>(ColorFromYamlNode(node)));
}else
{
RefPtr< PropertyLineKeyframes<Color> > keyframes (new PropertyLineKeyframes<Color>());
for (int k = 0; k < node->GetCount() / 2; ++k)
{
YamlNode * time = node->Get(k * 2);
YamlNode * value = node->Get(k * 2 + 1);
if (time && value)
{
if (value->GetType() == YamlNode::TYPE_ARRAY)
{
keyframes->AddValue(time->AsFloat(), ColorFromYamlNode(value));
}
}
}
return keyframes;
}
}
return RefPtr< PropertyLine<Color> >();
}
示例4: 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);
}
//.........这里部分代码省略.........