• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pugi::xml_document类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: appendValue

pugi::xml_node appendValue(pugi::xml_document & doc, string tag, string attribute, string newValue, bool overwriteMultiple){

    if (overwriteMultiple == true){
        // find the existing node...
        char xpathExpression[1024];
        sprintf(xpathExpression, "//%s[@%s='%s']", tag.c_str(), attribute.c_str(), newValue.c_str());
        pugi::xpath_node node = doc.select_single_node(xpathExpression);
        if(string(node.node().attribute(attribute.c_str()).value()).size() > 0){ // for some reason we get nulls here?
            // ...delete the existing node
            cout << "DELETING: " << node.node().name() << ": " << " " << node.node().attribute(attribute.c_str()).value() << endl;
            node.node().parent().remove_child(node.node());
        }
    }

    if (!doesTagAndAttributeExist(doc, tag, attribute, newValue)){
        // otherwise, add it please:
        char xpathExpression[1024];
        sprintf(xpathExpression, "//%s[@%s]", tag.c_str(), attribute.c_str());
        //cout << xpathExpression << endl;
        pugi::xpath_node_set add = doc.select_nodes(xpathExpression);
        pugi::xml_node node = add[add.size()-1].node();
        pugi::xml_node nodeAdded = node.parent().append_copy(node);
        nodeAdded.attribute(attribute.c_str()).set_value(newValue.c_str());
        return nodeAdded;
    }else{
    	return pugi::xml_node();
    }

}
开发者ID:CaterTsai,项目名称:openFrameworks,代码行数:29,代码来源:Utils.cpp


示例2: writer

void
docEdit::repaint( const pugi::xml_document& doc )
{
    if ( const pugi::xpath_node node = doc.select_single_node( "/article|/book" ) ) {
        try {
            detail::text_writer writer( *this );
            writer( node );
            auto cursor = textCursor();
            cursor.movePosition( QTextCursor::Start );
            ensureCursorVisible();
        } catch ( pugi::xpath_exception& ex ) {
            QMessageBox::warning( this, "adpublisher::docEdit", ex.what() );
        }
    }
    else if ( const pugi::xpath_node node = doc.select_single_node( "/qtplatz_document" ) ) {
        // do nothing
    }
    else {
        try {
            detail::xhtml_writer writer( *this );
            writer( doc.select_single_node( "/" ) );
            auto cursor = textCursor();
            cursor.movePosition( QTextCursor::Start );
            ensureCursorVisible();
        }
        catch ( pugi::xpath_exception& ex ) {
            QMessageBox::warning( this, "adpublisher::docEdit", ex.what() );
        }
    }
}
开发者ID:hermixy,项目名称:qtplatz,代码行数:30,代码来源:docedit.cpp


示例3: _LoadXmlDocment

BOOL SApplication::_LoadXmlDocment( LPCTSTR pszXmlName ,LPCTSTR pszType ,pugi::xml_document & xmlDoc,IResProvider *pResProvider/* = NULL*/)
{
    if(!pResProvider) 
    {
        if(IsFileType(pszType))
        {
            pugi::xml_parse_result result= xmlDoc.load_file(pszXmlName,pugi::parse_default,pugi::encoding_utf8);
            SASSERT_FMTW(result,L"parse xml error! xmlName=%s,desc=%s,offset=%d",pszXmlName,result.description(),result.offset);
            return result;
        }else
        {
            pResProvider = GetMatchResProvider(pszType,pszXmlName);
        }
    }
    if(!pResProvider) return FALSE;
    
    DWORD dwSize=pResProvider->GetRawBufferSize(pszType,pszXmlName);
    if(dwSize==0) return FALSE;

    CMyBuffer<char> strXml;
    strXml.Allocate(dwSize);
    pResProvider->GetRawBuffer(pszType,pszXmlName,strXml,dwSize);

    pugi::xml_parse_result result= xmlDoc.load_buffer(strXml,strXml.size(),pugi::parse_default,pugi::encoding_utf8);
    SASSERT_FMTW(result,L"parse xml error! xmlName=%s,desc=%s,offset=%d",pszXmlName,result.description(),result.offset);
    return result;
}
开发者ID:FuckGOV,项目名称:soui,代码行数:27,代码来源:SApp.cpp


示例4: writer

void
docTree::repaint( const pugi::xml_document& doc )
{
    QStandardItemModel& model = *model_;

    std::string xml;
    doc_->save( xml );

    model.clear();
    model.setColumnCount( 2 );

    if ( const pugi::xpath_node node = doc.select_single_node( "/article|/book" ) ) {
        try {
            detail::model_writer writer( *model_ );
            writer( node, QModelIndex() );
            expandAll();
        }
        catch ( pugi::xpath_exception& ex ) {
            QMessageBox::warning( this, "adpublisher::docTree", ex.what() );
        }
    }
    else if ( const pugi::xpath_node node = doc.select_single_node( "/qtplatz_document" ) ) {
        try {
            detail::model_writer writer( *model_ );
            writer( node, QModelIndex() );
            expandAll();
        }
        catch ( pugi::xpath_exception& ex ) {
            QMessageBox::warning( this, "adpublisher::docTree", ex.what() );
        }
    }

}
开发者ID:hermixy,项目名称:qtplatz,代码行数:33,代码来源:doctree.cpp


示例5: initFromXML

bool XCScheme::initFromXML(const pugi::xml_document& doc)
{
  // Create an error reporter for parsing
  ErrorReporter reporter(SB_INFO, "Error parsing \"" + m_name + "\" scheme for \"" + m_parentProject->getName() + "\" project. ");
  
  // Find and process all BuildActionEntry nodes
  pugi::xpath_node_set baSet = doc.select_nodes("/Scheme/BuildAction/BuildActionEntries/BuildActionEntry");
  for (pugi::xpath_node_set::const_iterator it = baSet.begin(); it != baSet.end(); ++it)
    parseBuildAction(it->node(), reporter);
    
  // Find and process all ArchiveAction nodes
  pugi::xpath_node_set aaSet = doc.select_nodes("/Scheme/ArchiveAction");
  for (pugi::xpath_node_set::const_iterator it = aaSet.begin(); it != aaSet.end(); ++it)
    parseArchiveAction(it->node(), reporter);
  
  // Make sure we got enough information
  if (m_targets.empty()) {
    reporter.reportError("Failed to read any archiveable targets.");
    return false;
  } else if (m_configName.empty()) {
    reporter.reportError("Failed to read a valid build configuration name.");
    return false;
  } else {
    return true;
  }
}
开发者ID:GoogleInternetAuthorityG2SUNGHAN,项目名称:WinObjC,代码行数:26,代码来源:XCScheme.cpp


示例6: create_readings_xml

void Device::create_readings_xml(pugi::xml_document &doc, int n_readings)
{
        doc.reset();
        
        // client base node
        pugi::xml_node node = doc.append_child("client");
        
        xml_header(doc);
        xml_readings(doc, false, n_readings);
}
开发者ID:drkozuch,项目名称:CHARM,代码行数:10,代码来源:device.cpp


示例7: create_confirm_xml

void Device::create_confirm_xml(pugi::xml_document &doc, int n_readings)
{
        doc.reset();
        
        // client base node
        pugi::xml_node node = doc.append_child("server");
        
        xml_header(doc);
        xml_latest_readings(doc, true, n_readings);
}
开发者ID:drkozuch,项目名称:CHARM,代码行数:10,代码来源:device.cpp


示例8: deserialization

	bool FontExportSerializer::deserialization(pugi::xml_document& _doc)
	{
		if (_doc.select_single_node("MyGUI[@type=\"Resource\"]").node().empty())
			return false;

		pugi::xpath_node_set nodes = _doc.select_nodes("MyGUI/Resource[@type=\"ResourceTrueTypeFont\"]");
		for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
			parseFont((*node).node());

		return true;
	}
开发者ID:2asoft,项目名称:MMO-Framework,代码行数:11,代码来源:FontExportSerializer.cpp


示例9: saveXML

static bool saveXML(pugi::xml_document& document, const std::string& outputFile)
{
	pugi::xml_node decl = document.prepend_child(pugi::node_declaration);
	decl.append_attribute("version").set_value("1.0");
	decl.append_attribute("encoding").set_value("utf-8");
	if(!document.save_file(outputFile.c_str(), " ", 1U, pugi::encoding_utf8))
	{
		return false;
	}

	return true;
}
开发者ID:,项目名称:,代码行数:12,代码来源:


示例10: deserialization

	bool ImageExportSerializer::deserialization(pugi::xml_document& _doc)
	{
		if (_doc.select_single_node("MyGUI[@type=\"Resource\"]").node().empty())
			return false;

		pugi::xpath_node_set nodes = _doc.select_nodes("MyGUI/Resource[@type=\"ResourceImageSet\"]");
		for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
			parseImage((*node).node());

		updateImageProperty(DataManager::getInstance().getRoot());
		return true;
	}
开发者ID:MyGUI,项目名称:mygui,代码行数:12,代码来源:ImageExportSerializer.cpp


示例11: while

int HLR2::_exec(const char *url, const char *payload, unsigned short timeout, pugi::xml_document& doc, std::string& headers)
{
    const short maxTry = 3;
    short retry = 0;

    if (!url || !*url) {
        LOG_ERROR("%s::%s: Invalid URL!", __class__, __func__);
        return -1;
    }

    while (maxTry >= ++retry) {
        short status = _hc.httpPost(url, payload, "text/xml", timeout);
        LOG_INFO("%s::%s: url: %s, payload: %s, timeout: %d, status: %d, headers: %s, body: %s", __class__, __func__,
                url, payload, timeout, status, _hc.getResponseHeaders(), _hc.getResponseBody());

        if (200 != status && 307 != status) {
            return -1;
        }

        headers = _hc.getResponseHeaders();
        std::string body = _hc.getResponseBody();

        if (!doc.load(body.c_str())) {
            LOG_ERROR("%s::%s: Malformed XML response!: %s", __class__, __func__, body.c_str());
            return -1;
        }

        pugi::xml_node result = doc.find_node(_isResult);
        int resultCode = atoi(result.child("ResultCode").child_value());

        switch (resultCode) {
            case 0:
            case 3016:
            case 3810:
                //-- success, exit...
                return 0;
            case 5004:
                //-- invalid session, retry...
                LOG_INFO("%s::%s: Will retry: %d", __class__, __func__, retry);
                break;
            default:
                LOG_ERROR("%s::%s: ResultCode: %s, ResultDesc: %s", __class__, __func__,
                        result.child("ResultCode").child_value(), result.child("ResultDesc").child_value());
                return -1;
        }

        //-- wait for a while...
        sys_msleep(1000);
    }

    return -1;
}
开发者ID:zand3rs,项目名称:fun2,代码行数:52,代码来源:hlr2.cpp


示例12: InitConfig

int InitConfig(pugi::xml_document& config) {
	//check folders, create in dont exist
	wstring appDataPath = AppPath();

	wstring logPath;
	wstring rawCurrentPath;
	wstring logDailyPath;
	//config
	wstring configFile = appDataPath + L"\\etc\\sdr.xml";
	//because service runs at windows/System32 folder
	//we forced to use absolute path

	pugi::xml_parse_result result = config.load_file(configFile.data());
	if (result.status != pugi::status_ok) {
		return status_config_file_not_found;
	}
	//first install build directory tree

	logPath = L"\\log";
	rawCurrentPath = logPath + L"\\current\\";
	logDailyPath = logPath + L"\\daily\\";

	config.select_single_node(L"/sdr/recording/logs/base").node().attribute(
			L"path").set_value(logPath.data());
	config.select_single_node(L"/sdr/recording/logs/current").node().attribute(
			L"path").set_value(rawCurrentPath.data());
	config.select_single_node(L"/sdr/recording/logs/daily").node().attribute(
			L"path").set_value(logDailyPath.data());

	config.save_file(configFile.data());

	logPath = appDataPath + logPath;
	rawCurrentPath = appDataPath + rawCurrentPath;
	logDailyPath = appDataPath + logDailyPath;

	//create config folderst
	CreateDirectory(logPath.data(), 0);
	if (GetLastError() == ERROR_PATH_NOT_FOUND)
		return status_path_not_found;
	CreateDirectory(rawCurrentPath.data(), 0);
	if (GetLastError() == ERROR_PATH_NOT_FOUND)
		return status_path_not_found;
	CreateDirectory(logDailyPath.data(), 0);
	if (GetLastError() == ERROR_PATH_NOT_FOUND)
		return status_path_not_found;

	return status_ok;
}
开发者ID:systemdatarecorder,项目名称:recording,代码行数:48,代码来源:shared.cpp


示例13: read

bool program_data::read(const pugi::xml_document & doc)
{
    pugi::xml_node root_node = doc.child("program");
    if(root_node.empty())
        return false;

    pugi::xml_node vertex_node = root_node.child("shaders").child("vertex");
    if(vertex_node.text().empty())
        return false;
    pugi::xml_node fragment_node = root_node.child("shaders").child("fragment");
    if(fragment_node.text().empty())
        return false;

    v_shader_ = vertex_node.text().get();
    f_shader_ = fragment_node.text().get();

    pugi::xml_node a_locations_node = root_node.child("a_locations");
    for(const auto & value : a_locations_node.children("location"))
    {
        attribute_locations_.emplace_back(value.attribute("name").value(),
                                          value.attribute("index").as_int());
    }

    pugi::xml_node u_locations_node = root_node.child("u_locations");
    for(const auto & value : u_locations_node.children("location"))
    {
        uniform_locations_.emplace_back(value.attribute("name").value(),
                                        value.attribute("index").as_int());
    }

    return true;
}
开发者ID:jauseg,项目名称:elements,代码行数:32,代码来源:program_loader.cpp


示例14: _init

void Patent::_init(const pugi::xml_document& doc, const bool& loadAbstract, const bool& loadDescription) {
	pugi::xml_node root = doc.child("patent");

	text.clear();
	source_tfvec.clear();
	target_tfvec.clear();

	// walk through nodes below the root node to collect abstracts and descriptions
	for (pugi::xml_node node = root.first_child(); node; node = node.next_sibling()) {

		if ( strcmp(node.name(), "ucid") == 0 )
			ucid = node.text().as_string();
		else if ( strcmp(node.name(), "lang") == 0 )
			lang = node.text().as_string();
		else if ( loadAbstract
			 && strcmp(node.name(), "abstract") == 0 )
			this->loadText(node);
		else if ( loadDescription
			 && strcmp(node.name(), "description") == 0 )
			this->loadText(node);

	}

	s_count = text.size();

	isParsed = true;
}
开发者ID:fhieber,项目名称:cdec,代码行数:27,代码来源:patent.cpp


示例15: AppendDocumentCopy

	void AppendDocumentCopy(pugi::xml_node& target, pugi::xml_document& doc) {
		auto doc_children = doc.children();

		for(auto doc_child : doc_children) {
			target.append_copy(doc_child);
		}
	}
开发者ID:sashavolv2,项目名称:ge-xml,代码行数:7,代码来源:DOMUtils.cpp


示例16: serialize_xml

void shader_configuration::serialize_xml(pugi::xml_document& document, const std::string& path)
{
pugi::xpath_node node;
node = document.select_single_node((path + "/shader").c_str());
std::string filename = node.node().attribute("filename").as_string();
configuration::set_attribute("/shader/filename", std::make_shared<configuration_attribute>(filename));
}
开发者ID:codeoneclick,项目名称:game-box,代码行数:7,代码来源:shader_configuration.cpp


示例17: xml_header

void Device::xml_header(pugi::xml_document &doc)
{
        char uid_c[sizeof(int)];
        sprintf(uid_c, "%d", uid);
        char battery_c[sizeof(int)];
        sprintf(battery_c, "%d", battery);

        pugi::xml_node node = doc.first_child();
        
        // UID
        pugi::xml_node node_uid = node.append_child("uid");
        node_uid.append_child(pugi::node_pcdata).set_value(uid_c);
        
        // msg_version
        pugi::xml_node node_msg_version = node.append_child("msg_version");
        node_msg_version.append_child(pugi::node_pcdata).set_value(msg_version);
        
        // fw
        pugi::xml_node node_fw = node.append_child("fw");
        node_fw.append_child(pugi::node_pcdata).set_value(fw_version);
        
        // battery
        pugi::xml_node node_battery = node.append_child("battery");
        node_battery.append_child(pugi::node_pcdata).set_value(battery_c);
        
        pugi::xml_node node_shutdown = node.append_child("shut_down");
        
        // shutdown
        if(state == SHUTDOWN)
                node_shutdown.append_child(pugi::node_pcdata).set_value("true");
        else
                node_shutdown.append_child(pugi::node_pcdata).set_value("false");
}
开发者ID:drkozuch,项目名称:CHARM,代码行数:33,代码来源:device.cpp


示例18:

// ---------------------------------------------
pugi::xml_node j1App::LoadConfig(pugi::xml_document& config_file) const
{
	pugi::xml_node ret;

	char* buf;
	int size = App->fs->Load("config.xml", &buf);
	pugi::xml_parse_result result = config_file.load_buffer(buf, size);
	RELEASE(buf);

	if(result == NULL)
		LOG("Could not load map xml file config.xml. pugi error: %s", result.description());
	else
		ret = config_file.child("config");

	return ret;
}
开发者ID:Jconrega,项目名称:ExamFinal,代码行数:17,代码来源:j1App.cpp


示例19: writeHeader

pugi::xml_node SvgPrinter::writeHeader(pugi::xml_document &doc)
{
	pugi::xml_node rootNode = doc.append_child("svg");
	rootNode.append_attribute("xmlns") = "http://www.w3.org/2000/svg";
	rootNode.append_attribute("xmlns:xlink") = "http://www.w3.org/1999/xlink";
	rootNode.append_attribute("xmlns:ev") = "http://www.w3.org/2001/xml-events";
	rootNode.append_attribute("version") = "1.1";
	rootNode.append_attribute("baseProfile") = "full";

	if(!m_settings.width().empty()) {
		rootNode.append_attribute("width") = m_settings.width().c_str();
	}

	if(!m_settings.height().empty()) {
		rootNode.append_attribute("height") = m_settings.height().c_str();
	}

	DRect box = m_clsAttr ? m_clsAttr->boundingBox() : m_attr.boundingBox();

	double margin = m_settings.margin();
	std::stringstream is;
	is << (box.p1().m_x - margin);
	is << " " << (box.p1().m_y - margin);
	is << " " << (box.width() + 2*margin);
	is << " " << (box.height() + 2*margin);
	rootNode.append_attribute("viewBox") = is.str().c_str();

	pugi::xml_node style_node = rootNode.append_child("style");
	style_node.text() = (".font_style {font: " + std::to_string(m_settings.fontSize()) + "px monospace;}").c_str();


	return rootNode;
}
开发者ID:PJ-Leyden,项目名称:srcYUML,代码行数:33,代码来源:SvgPrinter.cpp


示例20: ConvertStoryboard

void ConvertStoryboard(pugi::xml_document& doc) {
    pugi::xml_node curNode = doc.first_child();

    //  Storyboard XIB file - get topmost controller, then export it
    const char* initialController = curNode.attribute("initialViewController").value();

    for (; curNode; curNode = curNode.next_sibling()) {
        if (curNode.type() == pugi::xml_node_type::node_element) {
            XIBArray* root = new XIBArray();
            root->ScanStoryObjects(curNode);
        }
    }

    XIBObject::ParseAllStoryMembers();

    // Print which XML nodes we did not handle during the parse for diagnostic purpose.
    XIBObject::getDocumentCoverage(doc);

    NIBWriter::ExportController(initialController);

    Plist::dictionary_type viewControllerInfo;
    viewControllerInfo[std::string("UIStoryboardDesignatedEntryPointIdentifier")] =
        std::string("UIViewController-") + std::string(initialController);
    viewControllerInfo[std::string("UIStoryboardVersion")] = (int)1;

    Plist::dictionary_type viewControllerMappings;
    for (auto curController : _g_exportedControllers) {
        viewControllerMappings[curController.first] = curController.second;
    }
    viewControllerInfo[std::string("UIViewControllerIdentifiersToNibNames")] = viewControllerMappings;

    printf("Writing %s\n", GetOutputFilename("Info.plist").c_str());
    Plist::writePlistBinary(GetOutputFilename("Info.plist").c_str(), viewControllerInfo);
}
开发者ID:GoogleInternetAuthorityG2SUNGHAN,项目名称:WinObjC,代码行数:34,代码来源:xib2nib.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pugi::xml_node类代码示例发布时间:2022-05-31
下一篇:
C++ ptr_lib::shared_ptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap