本文整理汇总了C++中YamlNode类的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode类的具体用法?C++ YamlNode怎么用?C++ YamlNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了YamlNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveToYamlNode
YamlNode* UIAggregatorControl::SaveToYamlNode(UIYamlLoader * loader)
{
YamlNode* node = UIControl::SaveToYamlNode(loader);
SetPreferredNodeType(node, "UIAggregatorControl");
node->Set(AGGREGATOR_PATH, aggregatorPath.GetFrameworkPath());
return node;
}
示例2: ColorToVector
YamlNode* PropertyLineYamlWriter::WriteColorPropertyLineToYamlNode(YamlNode* parentNode, const String& propertyName,
RefPtr<PropertyLine<Color> > propertyLine)
{
// Write the property line.
Vector<PropValue<Color> > wrappedPropertyValues = PropLineWrapper<Color>(propertyLine).GetProps();
if (wrappedPropertyValues.empty())
{
return NULL;
}
if (wrappedPropertyValues.size() == 1)
{
// This has to be single string value. Write Colors as Vectors.
parentNode->Set(propertyName, ColorToVector(wrappedPropertyValues.at(0).v));
return NULL;
}
// Create the child array node.
YamlNode* childNode = new YamlNode(YamlNode::TYPE_ARRAY);
for (Vector<PropValue<Color> >::iterator iter = wrappedPropertyValues.begin();
iter != wrappedPropertyValues.end(); iter ++)
{
childNode->AddValueToArray((*iter).t);
childNode->AddValueToArray(ColorToVector((*iter).v));
}
parentNode->AddNodeToMap(propertyName, childNode);
return childNode;
}
示例3:
YamlNode * UIList::SaveToYamlNode(UIYamlLoader * loader)
{
YamlNode *node = UIControl::SaveToYamlNode(loader);
//Temp variable
String stringValue;
//Control Type
node->Set("type", "UIList");
//Orientation
eListOrientation orient = this->GetOrientation();
switch(orient)
{
case ORIENTATION_VERTICAL:
stringValue = "ORIENTATION_VERTICAL";
break;
case ORIENTATION_HORIZONTAL:
stringValue = "ORIENTATION_HORIZONTAL";
break;
default:
stringValue = "ORIENTATION_VERTICAL";
break;
}
node->Set("orientation", stringValue);
return node;
}
示例4: LoadFromYamlNode
void UIScrollView::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
UIControl::LoadFromYamlNode(node, loader);
YamlNode *contentSizeNode = node->Get("contentSize");
SetContentSize(contentSizeNode->AsPoint());
}
示例5: SafeRelease
bool Shader::LoadFromYaml(const FilePath & pathname)
{
//#if defined(__DAVAENGINE_ANDROID__) || defined (__DAVAENGINE_MACOS__)
// relativeFileName = pathname;
//#endif //#if defined(__DAVAENGINE_ANDROID__)
uint64 shaderLoadTime = SystemTimer::Instance()->AbsoluteMS();
YamlParser * parser = YamlParser::Create(pathname);
if (!parser)
return false;
YamlNode * rootNode = parser->GetRootNode();
if (!rootNode)
{
SafeRelease(rootNode);
return false;
}
const YamlNode * vertexShaderNode = rootNode->Get("vertexShader");
if (!vertexShaderNode)
{
SafeRelease(parser);
return false;
}
const YamlNode * glslVertexNode = vertexShaderNode->Get("glsl");
if (!glslVertexNode)
{
SafeRelease(parser);
return false;
}
const YamlNode * fragmentShaderNode = rootNode->Get("fragmentShader");
if (!fragmentShaderNode)
{
SafeRelease(parser);
return false;
}
const YamlNode * glslFragmentNode = fragmentShaderNode->Get("glsl");
if (!glslFragmentNode)
{
SafeRelease(parser);
return false;
}
FilePath pathOnly(pathname.GetDirectory());
vertexShaderPath = pathOnly + glslVertexNode->AsString();
fragmentShaderPath = pathOnly + glslFragmentNode->AsString();
SafeRelease(parser);
Load(vertexShaderPath, fragmentShaderPath);
shaderLoadTime = SystemTimer::Instance()->AbsoluteMS() - shaderLoadTime;
// Logger::FrameworkDebug("shader loaded:%s load-time: %lld ms", pathname.c_str(), shaderLoadTime);
return true;
}
示例6: getValue
bool
YamlMapping::equalTo(char *k, char *val){
YamlNode *n = getValue(k);
if(n != NULL){
return n->equalTo(val);
}
return false;
}
示例7: find
bool YamlMapping::read(const std::string &key, double &out_value) const
{
YamlNode* node = find(toUtf8(key));
if(node->isValid()){
out_value = node->toDouble();
return true;
}
return false;
}
示例8:
YamlMapping *
YamlSequence::getMappingAt(int x)
{
try{
YamlNode *n = value.at(x);
return n->toMapping();
}catch(std::out_of_range& e){
return NULL;
}
}
示例9: SetSize
bool HierarchyTreePlatformNode::Load(YamlNode* platform)
{
YamlNode* width = platform->Get(WIDTH_NODE);
YamlNode* height = platform->Get(HEIGHT_NODE);
if (!width || !height)
return false;
bool result = true;
SetSize(width->AsInt(), height->AsInt());
ActivatePlatform();
YamlNode* screens = platform->Get(SCREENS_NODE);
if (screens)
{
for (int i = 0; i < screens->GetCount(); i++)
{
YamlNode* screen = screens->Get(i);
if (!screen)
continue;
String screenName = screen->AsString();
QString screenPath = QString(SCREEN_PATH).arg(GetResourceFolder()).arg(QString::fromStdString(screenName));
HierarchyTreeScreenNode* screenNode = new HierarchyTreeScreenNode(this, QString::fromStdString(screenName));
result &= screenNode->Load(screenPath);
AddTreeNode(screenNode);
}
}
return result;
}
示例10: DeviceInfo
void GameCore::OnAppStarted()
{
DeviceInfo();
SettingsManager::Instance()->InitWithFile("~res:/Config/config.yaml");
cursor = 0;
RenderManager::Instance()->SetFPS(60);
String dirPath = "~res:/3d/Maps/";
Vector<String> levelsPaths;
YamlParser* parser = YamlParser::Create("~res:/maps.yaml");
if(parser)
{
YamlNode* rootNode = parser->GetRootNode();
if(rootNode)
{
int32 sz = rootNode->GetCount();
for(DAVA::int32 i = 0; i < sz; ++i)
{
String k = rootNode->GetItemKeyName(i);
String levelFile = rootNode->Get(i)->AsString();
if(k != "default")
levelsPaths.push_back(levelFile);
}
}
}
for(Vector<String>::const_iterator it = levelsPaths.begin(); it != levelsPaths.end(); ++it)
{
Test *test = new Test(dirPath + (*it));
if(test != NULL)
{
UIScreenManager::Instance()->RegisterScreen(test->GetScreenId(), test);
tests.push_back(test);
}
}
if(levelsPaths.size() > 0)
{
appFinished = false;
testCount = tests.size();
Test *firstTest = tests.front();
UIScreenManager::Instance()->SetFirst(firstTest->GetScreenId());
}
else
{
appFinished = true;
}
ConnectToDB();
}
示例11:
YamlNode * UIListCell::SaveToYamlNode(UIYamlLoader * loader)
{
YamlNode *node = UIControl::SaveToYamlNode(loader);
//Control Type
SetPreferredNodeType(node, "UIListCell");
//Identifier
node->Set("identifier", this->GetIdentifier());
return node;
}
示例12: YamlNode
YamlNode *
YamlDocument::ParseYamlDoc()
{
YamlNode *root = new YamlNode();
yaml_event_delete(&event);
do{
yaml_parser_parse(&parser, &event);
switch(event.type){
case YAML_STREAM_END_EVENT:
case YAML_DOCUMENT_END_EVENT:
return root;
case YAML_SEQUENCE_START_EVENT:
{
YamlSequence *v;
v = ParseYamlSequence();
root->addChild(reinterpret_cast<YamlNode *>(v));
}
break;
case YAML_SEQUENCE_END_EVENT:
break;
case YAML_MAPPING_START_EVENT:
{
YamlMapping *v;
v=ParseYamlMapping();
root->addChild(reinterpret_cast<YamlNode *>(v));
}
break;
case YAML_MAPPING_END_EVENT:
break;
case YAML_SCALAR_EVENT:
{
YamlScalar *v = new YamlScalar((char *)event.data.scalar.value );
root->addChild(reinterpret_cast<YamlNode *>(v));
}
break;
default:
std::cout << "FORMAT ERROR" << std::endl;
break;
}
if(event.type != YAML_DOCUMENT_END_EVENT){
yaml_event_delete(&event);
}
}while(event.type != YAML_DOCUMENT_END_EVENT);
yaml_event_delete(&event);
return root;
}
示例13: throwNotMappingException
YamlSequence* YamlMapping::findSequence(const std::string& key) const
{
if(!isValid()){
throwNotMappingException();
}
const_iterator p = values.find(toUtf8(key));
if(p != values.end()){
YamlNode* node = p->second.get();
if(node->type() == YAML_SEQUENCE){
return static_cast<YamlSequence*>(node);
}
}
return invalidSequence.get();
}
示例14: Load
bool HierarchyTreeAggregatorNode::Load(YamlNode* node, const QString& path)
{
this->path = path.toStdString();
YamlNode* width = node->Get(WIDTH_NODE);
YamlNode* height = node->Get(HEIGHT_NODE);
if (!width || !height)
return false;
rect = Rect(0, 0, width->AsInt(), height->AsInt());
screen->SetRect(rect);
bool result = HierarchyTreeScreenNode::Load(path);
UpdateHierarchyTree();
return result;
}
示例15: YamlNode
YamlNode * Font::SaveToYamlNode() const
{
YamlNode *node = new YamlNode(YamlNode::TYPE_MAP);
VariantType *nodeValue = new VariantType();
//Type
node->Set("type", "Font");
//Font size
node->Set("size", this->GetSize());
//Vertical Spacing
node->Set("verticalSpacing", this->GetVerticalSpacing());
SafeDelete(nodeValue);
return node;
}