当前位置: 首页>>代码示例>>C++>>正文


C++ CXmlNode::GetContent方法代码示例

本文整理汇总了C++中CXmlNode::GetContent方法的典型用法代码示例。如果您正苦于以下问题:C++ CXmlNode::GetContent方法的具体用法?C++ CXmlNode::GetContent怎么用?C++ CXmlNode::GetContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CXmlNode的用法示例。


在下文中一共展示了CXmlNode::GetContent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:BRAT-DEV,项目名称:main,代码行数:61,代码来源:AliasesDictionary.cpp

示例2: 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()));

//.........这里部分代码省略.........
开发者ID:BRAT-DEV,项目名称:main,代码行数:101,代码来源:AliasesDictionary.cpp


注:本文中的CXmlNode::GetContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。