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


C++ xml_node::text方法代码示例

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


在下文中一共展示了xml_node::text方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

void Editor_Html2Usfm::processNode (xml_node node)
{
  switch (node.type ()) {
    case node_element:
    {
      openElementNode (node);
      for (xml_node child : node.children()) {
        processNode (child);
      }
      closeElementNode (node);
      break;
    }
    case node_pcdata:
    {
      // Add the text to the current USFM line.
      string text = node.text ().get ();
      currentLine += text;
      break;
    }
    default:
    {
      string nodename = node.name ();
      Database_Logs::log ("Unknown XML node " + nodename + " while saving editor text");
      break;
    }
  }
}
开发者ID:alerque,项目名称:bibledit,代码行数:27,代码来源:html2usfm.cpp

示例2: vectorFromNode

Vector3 Scene::vectorFromNode(const xml_node &node)
{
	stringstream ss;
	ss << node.text().as_string();
	float x,y,z;
	ss >> x >> y >> z;
	if(ss.fail())
		throw domain_error("Bad vector format. Couldn't read all coordinates");
	return Vector3(x, y, z);
}
开发者ID:mvignale1987,项目名称:computer-graphics,代码行数:10,代码来源:Scene.cpp

示例3: idoc_create_direct

/// @brief Creates an IDoc file based on an XML template and returns it as a string
/// @param a string containing the IDoc's XML template
/// @return a string containing a new flat-text IDoc
IDOCREPLAYDLL_API LPCSTR idoc_create_direct(const LPCSTR idocXml)
{
    if (idocXml == NULL)
    {
        lr_error_message("[%s] IDoc XML cannot be NULL.", __FUNCTION__);
        return FALSE;
    }

    if (!ensure_valid_license())
    {
        return NULL;
    }

    const LPCSTR idocXmlPartiallyProcessed = idoc_eval_string(idocXml);
    const char* idocXmlProcessed = lr_eval_string(idocXmlPartiallyProcessed);
    const char* idocXmlFinal = idocXmlProcessed == NULL ? idocXmlPartiallyProcessed : idocXmlProcessed;

    xml_document doc;
    doc.load(idocXmlFinal);
    if (doc.empty())
    {
        lr_error_message("[%s] The specified IDoc XML document is empty.", __FUNCTION__);
        return NULL;
    }

    const xpath_node_set segmentNodeSet = doc.root().select_nodes("//IDOC/*[@SEGMENT='1']");
    if (segmentNodeSet.empty())
    {
        lr_error_message("[%s] The specified IDoc XML is not a valid IDoc.", __FUNCTION__);
        return NULL;
    }

    stringstream resultStream;

    for (xpath_node_set::const_iterator segmentIterator = segmentNodeSet.begin();
        segmentIterator != segmentNodeSet.end();
        ++segmentIterator)
    {
        const xml_node segmentNode = segmentIterator->node();
        const xpath_node_set fieldNodeSet = segmentNode.select_nodes("./*");
        if (fieldNodeSet.empty())
        {
            lr_error_message(
                "[%s] The specified IDoc XML contains segment '%s' without fields.",
                __FUNCTION__,
                segmentNode.name());
            return NULL;
        }

        for (xpath_node_set::const_iterator fieldIterator = fieldNodeSet.begin();
            fieldIterator != fieldNodeSet.end();
            ++fieldIterator)
        {
            static const unsigned int InvalidLength = 0xFFFFFFFF;

            const xml_node fieldNode = fieldIterator->node();
            const unsigned int length = fieldNode.attribute("length").as_uint(InvalidLength);
            if (length == InvalidLength)
            {
                lr_error_message(
                    "[%s]: The specified IDoc XML contains field '%s:%s' without length or with invalid one.",
                    __FUNCTION__,
                    segmentNode.name(),
                    fieldNode.name());
                return NULL;
            }

            string fieldText(fieldNode.text().as_string());
            if (fieldText.length() > length)
            {
                lr_error_message(
                    "[%s] The specified IDoc XML contains field '%s:%s' which actual length (%u) is greater"
                        " than declared (%u).",
                    __FUNCTION__,
                    segmentNode.name(),
                    fieldNode.name(),
                    fieldText.length(),
                    length);
                return NULL;
            }

            const size_t padCount = length - fieldText.length();
            if (padCount > 0)
            {
                fieldText.append(padCount, ' ');
            }

            resultStream << fieldText;
        }

        resultStream << endl;
    }

    g_allocatedStrings.push_back(resultStream.str());
    const string& resultingDocument = g_allocatedStrings.back();

    return resultingDocument.c_str();
//.........这里部分代码省略.........
开发者ID:MyLoadTest,项目名称:IDocWizard,代码行数:101,代码来源:IDocReplayDLL.cpp

示例4: idoc_eval_string

/// @brief Replaces any IDoc parameters with a the specified value from the input IDoc. IDoc
///     parameters should be in the format {IDoc:SegmentName:FieldName}
///     Note you must specify the input IDoc to use by first calling idoc_select_input_file
/// @param a new string with the IDoc parameters replaced with their values
/// @return a new string with the IDoc parameters replaced
IDOCREPLAYDLL_API LPCSTR idoc_eval_string(const LPCSTR parameterizedString)
{
    if (!ensure_valid_license())
    {
        return parameterizedString;
    }

    if (parameterizedString == NULL)
    {
        lr_error_message("Parameterized string cannot be empty.");
        return parameterizedString;
    }

    // TODO: move this check so that it only throws an error when parameterizedString contains something that looks like an IDoc parameter (i.e. {IDoc:xxx:yyy}
    // We don't want an error to be raised when idoc_create() is called with standard LoadRunner parameters.
    if (g_idocParamInputFilePath.empty())
    {
    //    lr_error_message("Input file is not selected. (Call idoc_select_input_file first.)");
        return parameterizedString;
    }

    g_allocatedStrings.push_back(std::string());

    string& result = g_allocatedStrings.back();

    const char* currentString = parameterizedString;

    cmatch matchResults;
    while (regex_search(currentString, matchResults, g_parameterRegex) && matchResults.size() == 3)
    {
        const cmatch::difference_type offset = matchResults.position();
        if (offset > 0)
        {
            result.append(currentString, offset);
            currentString += offset;
        }

        const sub_match<const char*> entireMatch = matchResults[0];
        const sub_match<const char*> segmentMatch = matchResults[1];
        const sub_match<const char*> fieldMatch = matchResults[2];

        const string segment(segmentMatch.first, segmentMatch.length());
        const string field(fieldMatch.first, fieldMatch.length());

        const xml_node segmentNode = get_node_value(g_idocParamInputFile.root(), segment);
        const xml_node fieldNode = get_node_value(segmentNode, field);

        if (segmentNode.empty() || fieldNode.empty())
        {
            result.append(currentString, entireMatch.length());
            currentString += entireMatch.length();

            if (is_param_log_enabled())
            {
                lr_output_message(
                    "Warning: [IDoc] Unable to find IDoc parameter '%s:%s'.",
                    segment.c_str(),
                    field.c_str());
            }

            continue;
        }

        const char_t* value = fieldNode.text().as_string();
        result.append(value);

        if (is_param_log_enabled())
        {
            lr_output_message(
                "[IDoc] Parameter substitution: '%s:%s' => '%s'.",
                segment.c_str(),
                field.c_str(),
                value);
        }

        currentString += entireMatch.length();
    }

    result.append(currentString);

    return result.c_str();
}
开发者ID:MyLoadTest,项目名称:IDocWizard,代码行数:87,代码来源:IDocReplayDLL.cpp


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