本文整理汇总了C++中NameCollection::addName方法的典型用法代码示例。如果您正苦于以下问题:C++ NameCollection::addName方法的具体用法?C++ NameCollection::addName怎么用?C++ NameCollection::addName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameCollection
的用法示例。
在下文中一共展示了NameCollection::addName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: X
bool
XMLIndata::parseName( const DOMNode* name,
NameCollection& names )
{
if ( XMLString::equals( name->getNodeName(), "name" ) ) {
// Get attributes
DOMNamedNodeMap* attributes = name->getAttributes();
LangTypes::language_t lang;
ItemTypes::name_t nameType;
// Note that language attribute is #REQUIRED.
DOMNode* attribute =
attributes->getNamedItem( X( "language" ) );
MC2_ASSERT( attribute != NULL );
MC2String langStr =
XMLUtility::transcodefromucs(attribute->getNodeValue() );
// Replace any occurance of '_' with space.
for (MC2String::iterator strIt = langStr.begin();
strIt != langStr.end(); ++strIt){
if ( *strIt == '_' ){
*strIt = ' ';
}
}
lang = LangTypes::getStringAsLanguage( langStr.c_str(), true );
if ( lang == LangTypes::invalidLanguage ){
mc2log << error << "Could not interpret language code of string"
<< endl;
MC2_ASSERT(false);
}
// Note that type attribute is always present.
attribute =
attributes->getNamedItem( X( "type" ) );
MC2_ASSERT( attribute != NULL );
const char* tmpStr = XMLUtility::transcodefromucs(
attribute->getNodeValue() );
nameType = ItemTypes::getStringAsNameType( tmpStr );
delete [] tmpStr;
// Get the name.
tmpStr = XMLUtility::getChildTextValue( name );
// Add name
Name* tmpName = new Name( tmpStr, lang, nameType );
names.addName( tmpName );
mc2dbg << "Added name: " << (*tmpName) << endl;
mc2dbg8 << "All names: " << names << endl;
delete tmpStr;
return true;
} else {
// Not a name node.
mc2log << warn
<< "XMLIndata::parseName:"
<< " not a name node."
<< name->getNodeName() << endl;
return false;
}
}