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

C++ XMLPrinter类代码示例

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

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



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

示例1: VToString

//  *******************************************************************************************************************
cString cXMLNode::VToString() const
{
	XMLPrinter printer;
	m_pDoc->Accept(&printer);

	return printer.CStr();
}
开发者ID:AnkurSheel,项目名称:RoutePlanner,代码行数:8,代码来源:XMLNode.cpp


示例2: save

void QDomDocument::save(QTextStream& stream,int)
{
    if ( document )
    {
        XMLPrinter printer;
        document->Print(&printer);
        stream << printer.CStr();
    }
}
开发者ID:gonboy,项目名称:aqemu,代码行数:9,代码来源:QDom.cpp


示例3: GetName

void
GameObject::Save( XMLPrinter & p )
{
  p.OpenElement("Item");
  p.PushAttribute("name", GetName().c_str());
  p.PushAttribute("id", GetId().c_str());
  p.PushAttribute("description", GetDescription().c_str());
  p.PushAttribute("match", GetNamePattern().str().c_str());
  SaveProperties(p);

  p.CloseElement();
}
开发者ID:Caennalla,项目名称:sdlcoursetasks,代码行数:12,代码来源:GameObject.cpp


示例4: while

void ReminderManager::Save()
{
    ReminderQueue queue;

    // Create the document
    tinyxml2::XMLDocument document;
    XMLDeclaration *declaration = document.NewDeclaration();
    document.InsertEndChild(declaration);

    // Create the root node (<reminders>)
    XMLElement *rootElement = document.NewElement("reminders");
    document.InsertEndChild(rootElement);
    g_vbox->Log(ADDON::LOG_INFO, "Save(1): %u reminders", m_reminders.size());

    // Create one <reminder> for every reminder
    while (!m_reminders.empty())
    {
        ReminderPtr reminder = m_reminders.top();
        g_vbox->Log(ADDON::LOG_INFO, "Save(2): got reminder", m_reminders.size());
        XMLElement *reminderElement = document.NewElement("reminder");
        reminderElement->SetText(reminder->m_progName.c_str());
        reminderElement->SetAttribute("channel", reminder->m_channelXmltvName.c_str());
        reminderElement->SetAttribute("start-time", g_vbox->CreateTimestamp(reminder->m_startTime).c_str());
        rootElement->InsertFirstChild(reminderElement);
        m_reminders.pop();
        g_vbox->Log(ADDON::LOG_INFO, "Save(3): popped. Now pushing to queue", m_reminders.size());
        queue.push(reminder);
    }
    g_vbox->Log(ADDON::LOG_INFO, "Save(4): queue size %d, m_reminders size %d", queue.size(), m_reminders.size());
    m_reminders = queue;
    g_vbox->Log(ADDON::LOG_INFO, "Save(5): queue size %d, m_reminders size %d", queue.size(), m_reminders.size());

    XBMC->DeleteFile(REMINDERS_XML.c_str());
    // Save the file
    void *fileHandle = XBMC->OpenFileForWrite(REMINDERS_XML.c_str(), false);

    if (fileHandle)
    {
        XMLPrinter printer;
        document.Accept(&printer);

        //XBMC->TruncateFile()
        std::string xml = printer.CStr();
        XBMC->WriteFile(fileHandle, xml.c_str(), xml.length());

        XBMC->CloseFile(fileHandle);
    }
}
开发者ID:relipo,项目名称:pvr.vbox,代码行数:48,代码来源:ReminderManager.cpp


示例5: main

int	main (void) {
    XMLDocument doc (false);
    doc.Parse (input);

    std::cout << "INPUT:\n" << input << "\n\n";

    XMLPrinter prn (NULL, true);
    doc.Print (&prn);
    std::cout << "XMLPrinter (not valid HTML5):\n" << prn.CStr() << "\n\n";

    XMLPrinterHTML5 html5 (NULL, true);
    doc.Print (&html5);
    std::cout << "XMLPrinterHTML5:\n" << html5.CStr() << "\n";

    return 0;
}
开发者ID:ARTSAT,项目名称:ground_station,代码行数:16,代码来源:html5-printer.cpp


示例6: print

void iCubTestMotorsStictionIncrementalReportEntry::print(XMLPrinter& printer)
{
    printer.xmlOpen("output");
    if (!m_Name.empty())
    {
        printer.xml("name",m_Name.c_str());
    }
    if (!m_trial.empty())
    {
        printer.xml("trial",m_trial.c_str());
    }
    if (!m_PWM.empty())
    {
        printer.xml("PWM",m_PWM.c_str());
    }
    if (!m_PWM.empty())
    {
        printer.xml("displacement",m_displacement.c_str());
    }
    if (!m_PWM.empty())
    {
        printer.xml("speed",m_speed.c_str());
    }

    printer.xmlClose(); 
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:26,代码来源:TestMotorsStictionIncrementalReportEntry.cpp


示例7: writeToFile

void CSettings::writeToFile() {
  XMLDocument doc;
  XMLElement *pSettingsElem = doc.NewElement("settings");
  doc.InsertEndChild(pSettingsElem);

  // Input
  XMLElement *pInput = doc.NewElement("input");
  pSettingsElem->InsertEndChild(pInput);

  pInput->SetAttribute("map_editor_button_size",
		       m_InputSettings.m_fMapEditorButtonSize);
  
  XMLElement *pInputTouch = doc.NewElement("touch");
  pInput->InsertEndChild(pInputTouch);

  pInputTouch->SetAttribute("button_size", m_InputSettings.m_fTouchButtonSize);

  // video
  XMLElement *pVideo = doc.NewElement("video");
  pSettingsElem->InsertEndChild(pVideo);
  
  pVideo->SetAttribute("hud_size", m_VideoSettings.m_fHUDSize);

  // social gaming
  XMLElement *pSocialGaming = doc.NewElement("social_gaming");
  pSettingsElem->InsertEndChild(pSocialGaming);
  
  pSocialGaming->SetAttribute("login_on_start", m_SocialGamingSettings.m_bLoginOnStart ? "true" : "false");


  // do the output
  XMLPrinter xmlprinter;
  doc.Accept(&xmlprinter);

  std::string header("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  std::string text(xmlprinter.CStr());

  std::fstream stream;
  if (CFileManager::openFile(stream, SETTINGS_FILE_PATH, std::ofstream::out | std::ofstream::trunc)) {
    stream << header;
    stream << text;
    stream.close();
  }
}
开发者ID:ChWick,项目名称:Mencus,代码行数:44,代码来源:Settings.cpp


示例8: GetName

void
Player::Save( XMLPrinter & p )
{
  p.OpenElement("Player");
  p.PushAttribute("name", GetName().c_str());
  p.PushAttribute("id", GetId().c_str());
  p.PushAttribute("description", GetDescription().c_str());
  p.OpenElement("Items");
  for(auto i : GetItems() ) i->Save(p);
  p.CloseElement();
  SaveProperties(p);
  p.CloseElement();
}
开发者ID:jjalo,项目名称:SDL,代码行数:13,代码来源:Player.cpp


示例9:

void
GameObject::SaveProperties( XMLPrinter & p )
{
  p.OpenElement("Properties");
  for(auto property : GetProperties())
  {
    p.OpenElement("Property");
    p.PushAttribute("id",property.second->GetId().c_str());
    p.PushAttribute("type", "string");
    string tmp = (*property.second).As<string>();
    p.PushAttribute("value", tmp.c_str());
    p.CloseElement();
  }
  p.CloseElement();
}
开发者ID:Caennalla,项目名称:sdlcoursetasks,代码行数:15,代码来源:GameObject.cpp


示例10: main


//.........这里部分代码省略.........

		XMLElement* sub[3] = { doc->NewElement( "sub" ), doc->NewElement( "sub" ), doc->NewElement( "sub" ) };
		for( int i=0; i<3; ++i ) {
			sub[i]->SetAttribute( "attrib", i );
		}
		element->InsertEndChild( sub[2] );
		XMLNode* comment = element->InsertFirstChild( doc->NewComment( "comment" ) );
		element->InsertAfterChild( comment, sub[0] );
		element->InsertAfterChild( sub[0], sub[1] );
		sub[2]->InsertFirstChild( doc->NewText( "& Text!" ));
		doc->Print();
		XMLTest( "Programmatic DOM", "comment", doc->FirstChildElement( "element" )->FirstChild()->Value() );
		XMLTest( "Programmatic DOM", "0", doc->FirstChildElement( "element" )->FirstChildElement()->Attribute( "attrib" ) );
		XMLTest( "Programmatic DOM", 2, doc->FirstChildElement()->LastChildElement( "sub" )->IntAttribute( "attrib" ) );
		XMLTest( "Programmatic DOM", "& Text!",
				 doc->FirstChildElement()->LastChildElement( "sub" )->FirstChild()->ToText()->Value() );

		// And now deletion:
		element->DeleteChild( sub[2] );
		doc->DeleteNode( comment );

		element->FirstChildElement()->SetAttribute( "attrib", true );
		element->LastChildElement()->DeleteAttribute( "attrib" );

		XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) );
		int value = 10;
		int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value );
		XMLTest( "Programmatic DOM", result, (int)XML_NO_ATTRIBUTE );
		XMLTest( "Programmatic DOM", value, 10 );

		doc->Print();

		{
			XMLPrinter streamer;
			doc->Print( &streamer );
			printf( "%s", streamer.CStr() );
		}
		{
			XMLPrinter streamer( 0, true );
			doc->Print( &streamer );
			XMLTest( "Compact mode", "<element><sub attrib=\"1\"/><sub/></element>", streamer.CStr(), false );
		}
		doc->SaveFile( "./resources/out/pretty.xml" );
		doc->SaveFile( "./resources/out/compact.xml", true );
		delete doc;
	}
	{
		// Test: Dream
		// XML1 : 1,187,569 bytes	in 31,209 allocations
		// XML2 :   469,073	bytes	in    323 allocations
		//int newStart = gNew;
		XMLDocument doc;
		doc.LoadFile( "resources/dream.xml" );

		doc.SaveFile( "resources/out/dreamout.xml" );
		doc.PrintError();

		XMLTest( "Dream", "xml version=\"1.0\"",
						  doc.FirstChild()->ToDeclaration()->Value() );
		XMLTest( "Dream", true, doc.FirstChild()->NextSibling()->ToUnknown() ? true : false );
		XMLTest( "Dream", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
						  doc.FirstChild()->NextSibling()->ToUnknown()->Value() );
		XMLTest( "Dream", "And Robin shall restore amends.",
						  doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
		XMLTest( "Dream", "And Robin shall restore amends.",
						  doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
开发者ID:AlejandorLazaro,项目名称:tinyxml2,代码行数:67,代码来源:xmltest.cpp


示例11: main


//.........这里部分代码省略.........
		XMLNode* element = doc->InsertEndChild( doc->NewElement( "element" ) );

		XMLElement* sub[3] = { doc->NewElement( "sub" ), doc->NewElement( "sub" ), doc->NewElement( "sub" ) };
		for( int i=0; i<3; ++i ) {
			sub[i]->SetAttribute( "attrib", i );
		}
		element->InsertEndChild( sub[2] );
		XMLNode* comment = element->InsertFirstChild( doc->NewComment( "comment" ) );
		element->InsertAfterChild( comment, sub[0] );
		element->InsertAfterChild( sub[0], sub[1] );
		sub[2]->InsertFirstChild( doc->NewText( "& Text!" ));
		doc->Print();
		XMLTest( "Programmatic DOM", "comment", doc->FirstChildElement( "element" )->FirstChild()->Value() );
		XMLTest( "Programmatic DOM", "0", doc->FirstChildElement( "element" )->FirstChildElement()->Attribute( "attrib" ) );
		XMLTest( "Programmatic DOM", 2, doc->FirstChildElement()->LastChildElement( "sub" )->IntAttribute( "attrib" ) );
		XMLTest( "Programmatic DOM", "& Text!", 
				 doc->FirstChildElement()->LastChildElement( "sub" )->FirstChild()->ToText()->Value() );

		// And now deletion:
		element->DeleteChild( sub[2] );
		doc->DeleteNode( comment );

		element->FirstChildElement()->SetAttribute( "attrib", true );
		element->LastChildElement()->DeleteAttribute( "attrib" );

		XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) );
		int value = 10;
		int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value );
		XMLTest( "Programmatic DOM", result, XML_NO_ATTRIBUTE );
		XMLTest( "Programmatic DOM", value, 10 );

		doc->Print();

		XMLPrinter streamer;
		doc->Print( &streamer );
		printf( "%s", streamer.CStr() );

		delete doc;
	}
	{
		// Test: Dream
		// XML1 : 1,187,569 bytes	in 31,209 allocations
		// XML2 :   469,073	bytes	in    323 allocations
		//int newStart = gNew;
		XMLDocument doc;
		doc.LoadFile( "dream.xml" );

		doc.SaveFile( "dreamout.xml" );
		doc.PrintError();

		XMLTest( "Dream", "xml version=\"1.0\"",
			              doc.FirstChild()->ToDeclaration()->Value() );
		XMLTest( "Dream", true, doc.FirstChild()->NextSibling()->ToUnknown() ? true : false );
		XMLTest( "Dream", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
						  doc.FirstChild()->NextSibling()->ToUnknown()->Value() );
		XMLTest( "Dream", "And Robin shall restore amends.",
			              doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );
		XMLTest( "Dream", "And Robin shall restore amends.",
			              doc.LastChild()->LastChild()->LastChild()->LastChild()->LastChildElement()->GetText() );

		XMLDocument doc2;
		doc2.LoadFile( "dreamout.xml" );
		XMLTest( "Dream-out", "xml version=\"1.0\"",
			              doc2.FirstChild()->ToDeclaration()->Value() );
		XMLTest( "Dream-out", true, doc2.FirstChild()->NextSibling()->ToUnknown() ? true : false );
		XMLTest( "Dream-out", "DOCTYPE PLAY SYSTEM \"play.dtd\"",
开发者ID:qaisjp,项目名称:green-candy,代码行数:67,代码来源:xmltest.cpp


示例12: SaveToString

std::string Document::SaveToString() const
{
	XMLPrinter printer;
	m_pDoc->Accept(&printer);
	return printer.CStr();
}
开发者ID:molip,项目名称:libKernel,代码行数:6,代码来源:Xml.cpp


示例13: Reject

//---------------------------------------------------------------------------
void File_Ttml::Read_Buffer_Continue()
{
    tinyxml2::XMLDocument document;

    if (!FileHeader_Begin_XML(document))
        return;

    XMLElement* Root=document.FirstChildElement("tt");
    if (!Root)
    {
        Reject();
        return;
    }

    if (!Status[IsAccepted])
    {
        Accept();

        #if MEDIAINFO_EVENTS
            MuxingMode=(int8u)-1;
            if (StreamIDs_Size>=2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_Mpeg4)
                MuxingMode=11; //MPEG-4
            if (StreamIDs_Size>2 && ParserIDs[StreamIDs_Size-2]==MediaInfo_Parser_Mxf) //Only if referenced MXF
                MuxingMode=13; //MXF
        #endif //MEDIAINFO_EVENTS

        #if MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
            if (Config->NextPacket_Get() && Config->Event_CallBackFunction_IsSet())
                return; // Waiting for NextPacket
        #endif //MEDIAINFO_DEMUX && MEDIAINFO_NEXTPACKET
    }

    tinyxml2::XMLElement*       div=NULL;
    #if MEDIAINFO_EVENTS
    tinyxml2::XMLElement*       p=NULL;
    #endif //MEDIAINFO_EVENTS
    for (XMLElement* tt_element=Root->FirstChildElement(); tt_element; tt_element=tt_element->NextSiblingElement())
    {
        //body
        if (!strcmp(tt_element->Value(), "body"))
        {
            for (XMLElement* body_element=tt_element->FirstChildElement(); body_element; body_element=body_element->NextSiblingElement())
            {
                //div
                if (!strcmp(body_element->Value(), "div"))
                {
                    for (XMLElement* div_element=body_element->FirstChildElement(); div_element; div_element=div_element->NextSiblingElement())
                    {
                        //p
                        if (!strcmp(div_element->Value(), "p"))
                        {
                            div=body_element;
                            #if MEDIAINFO_EVENTS
                                p=div_element;
                            #endif //MEDIAINFO_EVENTS
                            break;
                        }
                    }

                    if (div)
                        break;
                }
            }

            if (div)
                break;
        }
    }

    #if MEDIAINFO_DEMUX
        Demux(Buffer, Buffer_Size, ContentType_MainStream);
    #endif //MEDIAINFO_DEMUX

    // Output
    #if MEDIAINFO_EVENTS
        for (; p; p=p->NextSiblingElement())
        {
            //p
            if (!strcmp(p->Value(), "p"))
            {
                int64u DTS_Begin=(int64u)-1;
                const char* Attribute=p->Attribute("begin");
                if (Attribute)
                    DTS_Begin=Ttml_str2timecode(Attribute);
                int64u DTS_End=(int64u)-1;
                Attribute=p->Attribute("end");
                if (Attribute)
                    DTS_End=Ttml_str2timecode(Attribute);
                string ContentUtf8;
                XMLPrinter printer;
                p->Accept(&printer);
                ContentUtf8+=printer.CStr();
                while (!ContentUtf8.empty() && (ContentUtf8[ContentUtf8.size()-1]=='\r' || ContentUtf8[ContentUtf8.size()-1]=='\n'))
                    ContentUtf8.resize(ContentUtf8.size()-1);
                Ztring Content; Content.From_UTF8(ContentUtf8.c_str());

                Frame_Count_NotParsedIncluded=Frame_Count;
                EVENT_BEGIN (Global, SimpleText, 0)
                    //Hack: remove "p", "span", "br"
//.........这里部分代码省略.........
开发者ID:pavel-pimenov,项目名称:sandbox,代码行数:101,代码来源:File_Ttml.cpp


示例14: print

void iCubTestMotorsStictionReportEntry::print(XMLPrinter& printer)
{
    printer.xmlOpen("output");
    if (!m_Name.empty())
    {
        printer.xml("name",m_Name.c_str());
    }
    if (!m_Result.empty())
    {
        printer.xml("result",m_Result.c_str());
    }
    if (!m_PWM.empty())
    {
        printer.xml("PWM",m_PWM.c_str());
    }
    if (!m_MinLim.empty())
    {
        printer.xml("MinLim",m_MinLim.c_str());
    }
    if (!m_MinLimReached.empty())
    {
        printer.xml("MinLimReached",m_MinLimReached.c_str());
    }
    if (!m_MaxLim.empty())
    {
        printer.xml("MaxLim",m_MaxLim.c_str());
    }
    if (!m_MaxLimReached.empty())
    {
        printer.xml("MaxLimReached",m_MaxLimReached.c_str());
    }
    if (!m_Tolerance.empty())
    {
        printer.xml("Tolerance",m_Tolerance.c_str());
    }
    if (!m_Timeout.empty())
    {
        printer.xml("Timeout",m_Timeout.c_str());
    }
    printer.xmlClose(); 
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:41,代码来源:TestMotorsStictionReportEntry.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ XMLReader类代码示例发布时间:2022-05-31
下一篇:
C++ XMLParser类代码示例发布时间: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