本文整理汇总了C++中YamlNode::type方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::type方法的具体用法?C++ YamlNode::type怎么用?C++ YamlNode::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: openMapping
YamlMapping* YamlMapping::openMapping(const std::string& key, bool doOverwrite)
{
if(!isValid()){
throwNotMappingException();
}
YamlMapping* mapping = 0;
const string uKey(toUtf8(key));
iterator p = values.find(uKey);
if(p != values.end()){
YamlNode* node = p->second.get();
if(node->type() != YAML_MAPPING){
values.erase(p);
} else {
mapping = static_cast<YamlMapping*>(node);
if(doOverwrite){
mapping->clear();
}
mapping->indexInMapping = indexCounter++;
}
}
if(!mapping){
mapping = new YamlMapping();
mapping->doubleFormat_ = doubleFormat_;
insertSub(uKey, mapping);
}
return mapping;
}
示例2: openSequence
YamlSequence* YamlMapping::openSequence(const std::string& key, bool doOverwrite)
{
if(!isValid()){
throwNotMappingException();
}
YamlSequence* sequence = 0;
const string uKey(toUtf8(key));
iterator p = values.find(uKey);
if(p != values.end()){
YamlNode* node = p->second.get();
if(node->type() != YAML_SEQUENCE){
values.erase(p);
} else {
sequence = static_cast<YamlSequence*>(node);
if(doOverwrite){
sequence->clear();
}
sequence->indexInMapping = indexCounter++;
}
}
if(!sequence){
sequence = new YamlSequence();
sequence->doubleFormat_ = doubleFormat_;
insertSub(uKey, sequence);
}
return sequence;
}
示例3: findSequence
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();
}
示例4: writeSub
/**
This is for internal use. Text are not converted to UTF-8.
*/
void YamlMapping::writeSub(const std::string &key, const char* text, size_t length, YamlStringStyle stringStyle)
{
const string uKey(toUtf8(key));
iterator p = values.find(uKey);
if(p == values.end()){
insertSub(uKey, new YamlScalar(text, length, stringStyle));
} else {
YamlNode* node = p->second.get();
if(node->type() == YAML_SCALAR){
YamlScalar* scalar = static_cast<YamlScalar*>(node);
scalar->stringValue = string(text, length);
scalar->stringStyle = stringStyle;
scalar->indexInMapping = indexCounter++;
} else {
throwNotScalrException();
}
}
}