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


C++ xml_document::allocate_node方法代码示例

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


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

示例1: add_to_toc

void add_to_toc(int level, xml_node<char> *title, xml_attribute<char> *id, bool not_numbered)
{
    char *style_class;
    char *fulltitle = doc.allocate_string(0, title->value_size() + 100);
    if (level == 0)
    {
        style_class = "toc1";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i. %s", ++numbering[0], title->value());
            numbering[1] = 0;
            numbering[2] = 0;
        }
    }
    else if (level == 1)
    {
        style_class = "toc2";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i.%i %s", numbering[0], ++numbering[1], title->value());
            numbering[2] = 0;
        }
    }
    else if (level == 2)
    {
        style_class = "toc3";
        if (not_numbered)
        {
            sprintf(fulltitle, title->value());
        }
        else
        {
            sprintf(fulltitle, "%i.%i.%i %s", numbering[0], numbering[1], ++numbering[2], title->value());
        }
    }
    else
        throw std::exception("Invalid TOC level");
    xml_node<char> *tocentry = doc.allocate_node(node_element, "a", fulltitle);
    char *link = doc.allocate_string(0, id->value_size() + 1);
    memcpy(link + 1, id->value(), id->value_size());
    link[0] = '#';
    tocentry->append_attribute(doc.allocate_attribute("href", link, 0, id->value_size() + 1));
    tocentry->append_attribute(doc.allocate_attribute("class", style_class));
    toc.append_node(tocentry);
    toc.append_node(doc.allocate_node(node_element, "br"));
    xml_node<char> *title_data = title->first_node();
    if (title_data)
        title->remove_node(title_data);
    title->value(fulltitle);
}
开发者ID:timniederhausen,项目名称:rapidxml,代码行数:58,代码来源:postprocessor.cpp

示例2: writeCreateSchemeXml

/**
 * @brief WrapperXml::writeXml, metodo para escribir un xml
 * @param pRuta, directorio en el que se guardara el documento
 * @param pRoot, raiz del documento
 * @param pSon, hijo del documento
 */
void WrapperXml::writeCreateSchemeXml(std::string pMsg, xml_document<> &pDocument){
    xml_node<>* decl = pDocument.allocate_node(node_declaration);
    decl->append_attribute(pDocument.allocate_attribute(VERSION, NUMVERSION));
    decl->append_attribute(pDocument.allocate_attribute(ENCODE, TYPEENCODE));
    pDocument.append_node(decl);

    xml_node<>* root = pDocument.allocate_node(node_element, SCHEME);
    pDocument.append_node(root);

    std::istringstream pBuffer(pMsg);
    std::string subString;
    pBuffer >> subString;
    xml_node<>* childSN = pDocument.allocate_node(node_element, SCHEMENAME);
    childSN->value(strdup(subString.c_str()));
    root->append_node(childSN);
    pBuffer >> subString;
    xml_node<>* childR = pDocument.allocate_node(node_element, RAID);
    childR->value(strdup(subString.c_str()));
    root->append_node(childR);

    while(pBuffer){
        pBuffer >> subString;
        if(subString==HASH)
            break;
        else{
            xml_node<>* childD = pDocument.allocate_node(node_element, DATA);
            xml_node<>* childDT = pDocument.allocate_node(node_element, DATATYPE);
            childDT->value(strdup(subString.c_str()));
            childD->append_node(childDT);
            pBuffer >> subString;
            xml_node<>* childDL = pDocument.allocate_node(node_element, DATANAME );
            childDL->value(strdup(subString.c_str()));
            childD->append_node(childDL);
            pBuffer >> subString;
            xml_node<>* childDN= pDocument.allocate_node(node_element, DATANAME);
            childDN->value(strdup(subString.c_str()));
            childD->append_node(childDN);
            root->append_node(childD);
        }
    }

}
开发者ID:DatosII,项目名称:ClienteInmemdb,代码行数:48,代码来源:wrapperxml.cpp

示例3:

 inline xml_node<>* allocate_append_node(xml_node<>* top, const char* name)
 {
     xml_node<>* node = xml_doc.allocate_node(node_element, name);
     top->append_node(node);
     return node;
 }
开发者ID:forsyde,项目名称:ForSyDe-SystemC,代码行数:6,代码来源:xml.hpp


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