本文整理汇总了C++中parser::name_stack_t::end方法的典型用法代码示例。如果您正苦于以下问题:C++ name_stack_t::end方法的具体用法?C++ name_stack_t::end怎么用?C++ name_stack_t::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser::name_stack_t
的用法示例。
在下文中一共展示了name_stack_t::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: submitValue
bool BaseBlock::submitValue(const Parser::name_stack_t& name_stack, Parser& p, bool silent)
{
if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end())))
{
if (!silent)
{
p.parserWarning(llformat("Failed to parse parameter \"%s\"", p.getCurrentElementName().c_str()));
}
return false;
}
return true;
}
示例2: writeAttribute
void LLRNGWriter::writeAttribute(const std::string& type, const Parser::name_stack_t& stack, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values)
{
if (max_count == 0) return;
name_stack_t non_empty_names;
std::string attribute_name;
for (name_stack_t::const_iterator it = stack.begin();
it != stack.end();
++it)
{
const std::string& name = it->first;
if (!name.empty())
{
non_empty_names.push_back(*it);
}
}
if (non_empty_names.empty()) return;
for (name_stack_t::const_iterator it = non_empty_names.begin();
it != non_empty_names.end();
++it)
{
if (!attribute_name.empty())
{
attribute_name += ".";
}
attribute_name += it->first;
}
// singular attribute, e.g. <foo bar="1"/>
if (non_empty_names.size() == 1 && max_count == 1)
{
if (mAttributesWritten.second.find(attribute_name) == mAttributesWritten.second.end())
{
LLXMLNodePtr node = createCardinalityNode(mElementNode, min_count, max_count)->createChild("attribute", false);
node->createChild("name", true)->setStringValue(attribute_name);
node->createChild("data", false)->createChild("type", true)->setStringValue(type);
mAttributesWritten.second.insert(attribute_name);
}
}
// compound attribute
else
{
std::string element_name;
// traverse all but last element, leaving that as an attribute name
name_stack_t::const_iterator end_it = non_empty_names.end();
end_it--;
for (name_stack_t::const_iterator it = non_empty_names.begin();
it != end_it;
++it)
{
if (it != non_empty_names.begin())
{
element_name += ".";
}
element_name += it->first;
}
elements_map_t::iterator found_it = mElementsWritten.find(element_name);
// <choice>
// <group>
// <optional>
// <attribute name="foo.bar"><data type="string"/></attribute>
// </optional>
// <optional>
// <attribute name="foo.baz"><data type="integer"/></attribute>
// </optional>
// </group>
// <element name="foo">
// <optional>
// <attribute name="bar"><data type="string"/></attribute>
// </optional>
// <optional>
// <attribute name="baz"><data type="string"/></attribute>
// </optional>
// </element>
// <element name="outer.foo">
// <ref name="foo"/>
// </element>
// </choice>
if (found_it != mElementsWritten.end())
{
// reuse existing element
LLXMLNodePtr choice_node = found_it->second.first;
// attribute with this name not already written?
if (found_it->second.second.find(attribute_name) == found_it->second.second.end())
{
// append to <group>
LLXMLNodePtr node = choice_node->mChildren->head;
node = createCardinalityNode(node, min_count, max_count)->createChild("attribute", false);
node->createChild("name", true)->setStringValue(attribute_name);
addTypeNode(node, type, possible_values);
// append to <element>
//.........这里部分代码省略.........
示例3: writeAttribute
void LLXSDWriter::writeAttribute(const std::string& type, const Parser::name_stack_t& stack, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values)
{
name_stack_t non_empty_names;
std::string attribute_name;
for (name_stack_t::const_iterator it = stack.begin();
it != stack.end();
++it)
{
const std::string& name = it->first;
if (!name.empty())
{
non_empty_names.push_back(*it);
}
}
for (name_stack_t::const_iterator it = non_empty_names.begin();
it != non_empty_names.end();
++it)
{
if (!attribute_name.empty())
{
attribute_name += ".";
}
attribute_name += it->first;
}
// only flag non-nested attributes as mandatory, nested attributes have variant syntax
// that can't be properly constrained in XSD
// e.g. <foo mandatory.value="bar"/> vs <foo><mandatory value="bar"/></foo>
bool attribute_mandatory = min_count == 1 && max_count == 1 && non_empty_names.size() == 1;
// don't bother supporting "Multiple" params as xml attributes
if (max_count <= 1)
{
// add compound attribute to root node
addAttributeToSchema(mAttributeNode, attribute_name, type, attribute_mandatory, possible_values);
}
// now generated nested elements for compound attributes
if (non_empty_names.size() > 1 && !attribute_mandatory)
{
std::string element_name;
// traverse all but last element, leaving that as an attribute name
name_stack_t::const_iterator end_it = non_empty_names.end();
end_it--;
for (name_stack_t::const_iterator it = non_empty_names.begin();
it != end_it;
++it)
{
if (it != non_empty_names.begin())
{
element_name += ".";
}
element_name += it->first;
}
std::string short_attribute_name = non_empty_names.back().first;
LLXMLNodePtr complex_type_node;
// find existing element node here, starting at tail of child list
if (mElementNode->mChildren.notNull())
{
for(LLXMLNodePtr element = mElementNode->mChildren->tail;
element.notNull();
element = element->mPrev)
{
std::string name;
if(element->getAttributeString("name", name) && name == element_name)
{
complex_type_node = element->mChildren->head;
break;
}
}
}
//create complex_type node
//
//<xs:element
// maxOccurs="1"
// minOccurs="0"
// name="name">
// <xs:complexType>
// </xs:complexType>
//</xs:element>
if(complex_type_node.isNull())
{
complex_type_node = mElementNode->createChild("xs:element", false);
complex_type_node->createChild("minOccurs", true)->setIntValue(min_count);
complex_type_node->createChild("maxOccurs", true)->setIntValue(max_count);
complex_type_node->createChild("name", true)->setStringValue(element_name);
complex_type_node = complex_type_node->createChild("xs:complexType", false);
}
addAttributeToSchema(complex_type_node, short_attribute_name, type, false, possible_values);
}
}