本文整理汇总了C++中Mapping::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Mapping::insert方法的具体用法?C++ Mapping::insert怎么用?C++ Mapping::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapping
的用法示例。
在下文中一共展示了Mapping::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hashToBiMap
static Mapping hashToBiMap(const Hash &hash)
{
Mapping biMap;
Hash::const_iterator it = hash.constBegin();
const Hash::const_iterator end = hash.constEnd();
for ( ; it != end; ++it)
biMap.insert(Mapping::value_type(it.key(), it.value()));
return biMap;
}
示例2: addNode
void YAMLReaderImpl::addNode(ValueNode* node, yaml_event_t& event)
{
NodeInfo& info = nodeStack.top();
ValueNode* parent = info.node;
if(parent->isListing()){
Listing* listing = static_cast<Listing*>(parent);
listing->append(node);
} else if(parent->isMapping()){
Mapping* mapping = static_cast<Mapping*>(parent);
if(info.key == "<<"){
if(node->isMapping()){
mapping->insert(static_cast<Mapping*>(node));
} else if(node->isListing()){
Listing* listing = static_cast<Listing*>(node);
for(auto& element : *listing){
if(element->isMapping()){
mapping->insert(static_cast<Mapping*>(element.get()));
} else {
ValueNode::SyntaxException ex;
ex.setMessage(_("An element to merge by the \"<<\" key must be a mapping"));
const yaml_mark_t& start_mark = event.start_mark;
ex.setPosition(start_mark.line, start_mark.column);
throw ex;
}
}
} else {
ValueNode::SyntaxException ex;
ex.setMessage(_("A value to merge by the \"<<\" key must be mapping or listing"));
const yaml_mark_t& start_mark = event.start_mark;
ex.setPosition(start_mark.line, start_mark.column);
throw ex;
}
}
mapping->insert(info.key, node);
info.key.clear();
}
}