本文整理汇总了C++中TiXmlNode::ToComment方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::ToComment方法的具体用法?C++ TiXmlNode::ToComment怎么用?C++ TiXmlNode::ToComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::ToComment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readComment
const char* SimXMLDocument::readComment( S32 index )
{
// Clear the current attribute pointer
m_CurrentAttribute = 0;
// Push the first element found under the current element of the given name
if(!m_paNode.empty())
{
const int iLastElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iLastElement];
if(!pNode)
{
return "";
}
TiXmlNode* node = pNode->FirstChild();
for( S32 i = 0; i < index; i++ )
{
if( !node )
return "";
node = node->NextSiblingElement();
}
if( node )
{
TiXmlComment* comment = node->ToComment();
if( comment )
return comment->Value();
}
}
else
{
if(!m_qDocument)
{
return "";
}
TiXmlNode* node = m_qDocument->FirstChild();
for( S32 i = 0; i < index; i++ )
{
if( !node )
return "";
node = node->NextSibling();
}
if( node )
{
TiXmlComment* comment = node->ToComment();
if( comment )
return comment->Value();
}
}
return "";
}
示例2: main
//.........这里部分代码省略.........
printf( "\n** Demo doc processed: ** \n\n" );
doc.Print( stdout );
#ifdef TIXML_USE_STL
printf( "** Demo doc processed to stream: ** \n\n" );
cout << doc << endl << endl;
#endif
// --------------------------------------------------------
// Different tests...do we have what we expect?
// --------------------------------------------------------
int count = 0;
TiXmlElement* element;
//////////////////////////////////////////////////////
#ifdef TIXML_USE_STL
cout << "** Basic structure. **\n";
ostringstream outputStream( ostringstream::out );
outputStream << doc;
XmlTest( "Output stream correct.", string( demoEnd ).c_str(),
outputStream.str().c_str(), true );
#endif
node = doc.RootElement();
assert( node );
XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Root element value is 'ToDo'.", "ToDo", node->Value());
node = node->FirstChild();
XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) );
node = node->NextSibling();
XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Value is 'Item'.", "Item", node->Value() );
node = node->FirstChild();
XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) );
XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() );
//////////////////////////////////////////////////////
printf ("\n** Iterators. **\n");
// Walk all the top level nodes of the document.
count = 0;
for( node = doc.FirstChild();
node;
node = node->NextSibling() )
{
count++;
}
XmlTest( "Top level nodes, using First / Next.", 3, count );
count = 0;
for( node = doc.LastChild();
node;
node = node->PreviousSibling() )
{
count++;
}
XmlTest( "Top level nodes, using Last / Previous.", 3, count );
// Walk all the top level nodes of the document,
示例3: SwitchTo
void CfgMgrBldr::SwitchTo(const wxString& fileName)
{
doc = new TiXmlDocument();
if (!TinyXML::LoadDocument(fileName, doc))
{
doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
doc->InsertEndChild(TiXmlElement("CodeBlocksConfig"));
doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version);
}
if (doc->ErrorId())
cbThrow(wxString::Format(_T("TinyXML error: %s\nIn file: %s\nAt row %d, column: %d."), cbC2U(doc->ErrorDesc()).c_str(), fileName.c_str(), doc->ErrorRow(), doc->ErrorCol()));
TiXmlElement* docroot = doc->FirstChildElement("CodeBlocksConfig");
if (doc->ErrorId())
cbThrow(wxString::Format(_T("TinyXML error: %s\nIn file: %s\nAt row %d, column: %d."), cbC2U(doc->ErrorDesc()).c_str(), fileName.c_str(), doc->ErrorRow(), doc->ErrorCol()));
const char *vers = docroot->Attribute("version");
if (!vers || atoi(vers) != 1)
cbMessageBox(_("ConfigManager encountered an unknown config file version. Continuing happily."), _("Warning"), wxICON_WARNING);
doc->ClearError();
wxString info;
#ifndef __GNUC__
info.Printf(_T( " application info:\n"
"\t svn_revision:\t%u\n"
"\t build_date:\t%s, %s "), ConfigManager::GetRevisionNumber(), wxT(__DATE__), wxT(__TIME__));
#else
info.Printf(_T( " application info:\n"
"\t svn_revision:\t%u\n"
"\t build_date:\t%s, %s\n"
"\t gcc_version:\t%d.%d.%d "), ConfigManager::GetRevisionNumber(), wxT(__DATE__), wxT(__TIME__),
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif
if (platform::windows)
info.append(_T("\n\t Windows "));
if (platform::linux)
info.append(_T("\n\t Linux "));
if (platform::macosx)
info.append(_T("\n\t Mac OS X "));
if (platform::unix)
info.append(_T("\n\t Unix "));
info.append(platform::unicode ? _T("Unicode ") : _T("ANSI "));
TiXmlComment c;
c.SetValue((const char*) info.mb_str());
TiXmlNode *firstchild = docroot->FirstChild();
if (firstchild && firstchild->ToComment())
{
docroot->RemoveChild(firstchild);
firstchild = docroot->FirstChild();
}
if (firstchild)
docroot->InsertBeforeChild(firstchild, c);
else
docroot->InsertEndChild(c);
}
示例4: main
//.........这里部分代码省略.........
todoElement->InsertAfterChild( itemElement, item );
printf( "\n** Demo doc processed: ** \n\n" );
doc.Print( stdout );
#ifdef TIXML_USE_STL
printf( "** Demo doc processed to stream: ** \n\n" );
cout << doc << endl << endl;
#endif
// --------------------------------------------------------
// Different tests...do we have what we expect?
// --------------------------------------------------------
int count = 0;
TiXmlElement* element;
//////////////////////////////////////////////////////
#ifdef TIXML_USE_STL
cout << "** Basic structure. **\n";
ostringstream outputStream( ostringstream::out );
outputStream << doc;
XmlTest( "Output stream correct.", string( demoEnd ).c_str(),
outputStream.str().c_str(), true );
#endif
node = doc.RootElement();
XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Root element value is 'ToDo'.", "ToDo", node->Value());
node = node->FirstChild();
XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) );
node = node->NextSibling();
XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Value is 'Item'.", "Item", node->Value() );
node = node->FirstChild();
XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) );
XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() );
//////////////////////////////////////////////////////
printf ("\n** Iterators. **\n");
// Walk all the top level nodes of the document.
count = 0;
for( node = doc.FirstChild();
node;
node = node->NextSibling() )
{
count++;
}
XmlTest( "Top level nodes, using First / Next.", 3, count );
count = 0;
for( node = doc.LastChild();
node;
node = node->PreviousSibling() )
{
count++;
}
XmlTest( "Top level nodes, using Last / Previous.", 3, count );
// Walk all the top level nodes of the document,
示例5: main
//.........这里部分代码省略.........
todoElement->InsertAfterChild( itemElement, item );
printf( "\n** Demo doc processed: ** \n\n" );
doc.Print( stdout );
#ifdef TIXML_USE_STL
printf( "** Demo doc processed to stream: ** \n\n" );
cout << doc << endl << endl;
#endif
// --------------------------------------------------------
// Different tests...do we have what we expect?
// --------------------------------------------------------
int count = 0;
TiXmlElement* element;
//////////////////////////////////////////////////////
#ifdef TIXML_USE_STL
cout << "** Basic structure. **\n";
outputStream << doc;
XmlTest( "Output stream correct.", string( demoEnd ).c_str(),
outputStream.str().c_str(), true );
#endif
node = doc.RootElement();
XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Root element value is 'ToDo'.", "ToDo", node->Value());
node = node->FirstChild();
XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) );
node = node->NextSibling();
XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) );
XmlTest ( "Value is 'Item'.", "Item", node->Value() );
node = node->FirstChild();
XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) );
XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() );
//////////////////////////////////////////////////////
printf ("\n** Iterators. **\n");
// Walk all the top level nodes of the document.
count = 0;
for( node = doc.FirstChild();
node;
node = node->NextSibling() )
{
count++;
}
XmlTest( "Top level nodes, using First / Next.", 3, count );
count = 0;
for( node = doc.LastChild();
node;
node = node->PreviousSibling() )
{
count++;
}
XmlTest( "Top level nodes, using Last / Previous.", 3, count );
// Walk all the top level nodes of the document,