本文整理汇总了C++中CXmlNode::GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ CXmlNode::GetChildren方法的具体用法?C++ CXmlNode::GetChildren怎么用?C++ CXmlNode::GetChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CXmlNode
的用法示例。
在下文中一共展示了CXmlNode::GetChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDefaultRecord
//----------------------------------------
CDefaultRecord* CAliasesDictionary::CreateDefaultRecord(CXmlNode* defaultRecordNode)
{
if (defaultRecordNode == NULL)
{
return NULL;
}
CDefaultRecord* defaultRecord = new CDefaultRecord();
std::string value;
bool bOk = defaultRecordNode->GetPropVal(CAliasesDictionary::m_NAME_ATTR, &value);
if (!bOk)
{
std::string msg = CTools::Format("Unable to create default record - Default record name is empty - "
"Please check all '%s' attributes of the '%s' elements in the aliases dictionary '%s'.",
CAliasesDictionary::m_NAME_ATTR.c_str(),
CAliasesDictionary::m_DEFAULT_RECORD_ELT.c_str(),
m_fullFileName.c_str());
delete defaultRecord;
defaultRecord = NULL;
throw CXMLException(msg, BRATHL_ERROR);
}
defaultRecord->SetName(value);
CObArray arrayNodes(false);
FindAllNodesByName(CAliasesDictionary::m_PRODUCT_TYPE_ELT, defaultRecordNode, arrayNodes, false);
CObArray::const_iterator it;
for(it = arrayNodes.begin() ; it != arrayNodes.end() ; it++)
{
CXmlNode* node = dynamic_cast<CXmlNode*>(*it);
if (node == NULL)
{
continue;
}
CXmlNode* textNode = node->GetChildren();
if (textNode == NULL)
{
continue;
}
std::string productType = textNode->GetContent().c_str();
if (productType.empty())
{
continue;
}
defaultRecord->AddProductType(productType);
}
return defaultRecord;
}
示例2: GetAliases
//----------------------------------------------------
bool CAliasesDictionary::GetAliases(CProduct* product)
{
if (product == NULL)
{
return false;
}
CXmlNode* productNode = this->FindProductNode(product->GetProductClass());
if (productNode == NULL)
{
return false;
}
CXmlNode* child = productNode->GetChildren();
while (child != NULL)
{
if (!str_icmp(child->GetName(), CAliasesDictionary::m_PRODUCT_ELT))
{
child = child->GetNext();
continue;
}
child = child->GetNext();
}
return true;
}
示例3: FindAliasNode
//----------------------------------------------------
CXmlNode* CAliasesDictionary::FindAliasNode(const std::string& name, CXmlNode* parent, bool allDepths /* = false */)
{
if (parent == NULL)
{
return NULL;
}
CXmlNode* child = parent->GetChildren();
std::string value;
while (child != NULL)
{
if (str_icmp(child->GetName(), CAliasesDictionary::m_ALIAS_ELT))
{
bool bOk = child->GetPropVal(CAliasesDictionary::m_NAME_ATTR, &value);
if (bOk)
{
if (str_icmp(name, value))
{
break;
}
}
}
if ((allDepths) && (child->GetChildren() != NULL))
{
CXmlNode* newChild = FindAliasNode(name, child, allDepths);
if (newChild != NULL)
{
child = newChild;
break;
}
}
child = child->GetNext();
}
return child;
}
示例4: CreateAlias
//----------------------------------------
CAlias* CAliasesDictionary::CreateAlias(CXmlNode* aliasNode)
{
if (aliasNode == NULL)
{
return NULL;
}
CAlias* alias = new CAlias();
std::string value;
bool bOk = aliasNode->GetPropVal(CAliasesDictionary::m_NAME_ATTR, &value);
if (!bOk)
{
std::string msg = CTools::Format("Unable to create alias - Alias name is empty - "
"Please check all '%s' attributes of the '%s' elements in the aliases dictionary '%s'.",
CAliasesDictionary::m_NAME_ATTR.c_str(),
CAliasesDictionary::m_ALIAS_ELT.c_str(),
m_fullFileName.c_str());
delete alias;
alias = NULL;
throw CXMLException(msg, BRATHL_ERROR);
}
alias->SetName(value);
value.clear();
bOk = aliasNode->GetPropVal(CAliasesDictionary::m_REF_ATTR, &value);
alias->SetRef(value);
bOk = aliasNode->GetPropVal(CAliasesDictionary::m_DESCR_ATTR, &value);
alias->SetDescription(value);
CXmlNode* textNode = aliasNode->GetChildren();
std::string aliasValue;
if (textNode != NULL)
{
aliasValue = textNode->GetContent().c_str();
}
if ((aliasValue.empty()) && (!alias->IsSynonym()))
{
std::string msg = CTools::Format("Unable to create alias '%s' - Alias value is empty and alias ref. attribute is empty. "
"One of two values has to be filled (but not both of them)."
"Please check all '%s' attributes of the '%s' elements in the aliases dictionary '%s'.",
alias->GetName().c_str(),
CAliasesDictionary::m_NAME_ATTR.c_str(),
CAliasesDictionary::m_ALIAS_ELT.c_str(),
m_fullFileName.c_str());
delete alias;
alias = NULL;
throw CXMLException(msg, BRATHL_ERROR);
}
if ((!aliasValue.empty()) && (alias->IsSynonym()))
{
std::string msg = CTools::Format("Unable to create alias '%s' - Alias value is not empty ('%s') and alias ref. attribute is not empty ('%s'). "
"Only one of two values has to be filled, not both of them."
"Please check all '%s' attributes of the '%s' elements in the aliases dictionary '%s'.",
alias->GetName().c_str(),
aliasValue.c_str(),
alias->GetRef().c_str(),
CAliasesDictionary::m_NAME_ATTR.c_str(),
CAliasesDictionary::m_ALIAS_ELT.c_str(),
m_fullFileName.c_str());
delete alias;
alias = NULL;
throw CXMLException(msg, BRATHL_ERROR);
}
if (alias->IsSynonym())
{
CXmlNode* aliasRefNode = FindAliasNode(alias->GetRef(), aliasNode->GetParent());
if (aliasRefNode == NULL)
{
std::string msg = CTools::Format("Unable to create alias '%s' - Alias is as synonym, but the referenced alias ('%s') is not found. "
"Please check all '%s' attributes of the '%s' elements in the aliases dictionary '%s'.",
alias->GetName().c_str(),
alias->GetRef().c_str(),
CAliasesDictionary::m_NAME_ATTR.c_str(),
CAliasesDictionary::m_ALIAS_ELT.c_str(),
m_fullFileName.c_str());
delete alias;
alias = NULL;
throw CXMLException(msg, BRATHL_ERROR);
}
alias->SetDescription(CTools::Format("%s (Synonym of %s).", alias->GetDescription().c_str(), alias->GetRef().c_str()));
//.........这里部分代码省略.........