本文整理汇总了C++中TiXmlComment类的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlComment类的具体用法?C++ TiXmlComment怎么用?C++ TiXmlComment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TiXmlComment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TiXmlDocument
bool cSubMenu::SaveXml(char *fname )
{
if (_fname)
{
TiXmlDocument xml = TiXmlDocument(fname );
TiXmlComment comment;
comment.SetValue(
" Mini-VDR cSetupConfiguration File\n"
" (c) Ralf Dotzert\n"
"\n\n"
" for Example see vdr-menu.xml.example\n\n"
);
TiXmlElement root("menus");
root.SetAttribute("suffix", _menuSuffix);
for (cSubMenuNode *node = _menuTree.First(); node; node = _menuTree.Next(node))
node->SaveXml(&root);
if (xml.InsertEndChild(comment) != NULL &&
xml.InsertEndChild(root) != NULL)
{
return xml.SaveFile(fname);
}
}
else
{
return false;
}
return true;
}
示例2: TiXmlDeclaration
void kore::ProjectLoader::saveProject(const std::string& path) const {
ResourceManager* ResMgr = ResourceManager::getInstance();
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "yes");
doc.LinkEndChild(decl);
TiXmlComment * comment = new TiXmlComment();
time_t rawtime;
time(&rawtime);
comment->SetValue(ctime(&rawtime));
doc.LinkEndChild(comment);
// Resources
TiXmlElement* resources = new TiXmlElement("Resources");
doc.LinkEndChild(resources);
// Textures
TiXmlElement* texture;
std::map<std::string, TexturePtr>::iterator texIt;
for(texIt = ResMgr->_textures.begin();
texIt != ResMgr->_textures.end();
texIt++) {
texture = new TiXmlElement("Texture");
STextureProperties prop = texIt->second->getProperties();
texture->SetAttribute("name", texIt->second->getName().c_str());
texture->SetAttribute("width", prop.width);
texture->SetAttribute("height", prop.height);
resources->LinkEndChild(texture);
}
// TODO(dospelt) the rest
TiXmlElement* scene = new TiXmlElement("Scene");
doc.LinkEndChild(scene);
kore::SceneNodePtr root = kore::SceneManager::getInstance()->getRootNode();
//saveSceneNode(scene, root);
// finally, save to file
if(doc.SaveFile(path.c_str())) {
kore::Log::getInstance()->write("[DEBUG] writing file '%s'\n",
path.c_str());
} else {
kore::Log::getInstance()->write("[ERROR] could not write file '%s'\n",
path.c_str());
}
// TODO(dospelt) runtime error when deleting created pointers.
// it seems they get automatically deleted when saving File -> tinyxmlDoku?
// delete resources;
// delete comment;
}
示例3: TiXmlDeclaration
/* Method save_xml */
void ClusterSettings::save_xml (const Glib::ustring& filename)
{
/* Create xml document */
TiXmlDocument doc;
/* XML Declaration */
TiXmlDeclaration *decl = new TiXmlDeclaration ("0.0", "", "");
doc.LinkEndChild (decl);
/* Root element */
TiXmlElement *root = new TiXmlElement ("SensorsClusterSettings");
doc.LinkEndChild (root);
/* Comment */
Glib::ustring message;
message.assign (" File created by ComLibSim at [");
message.append (filename);
message.append ("] ");
TiXmlComment *comment = new TiXmlComment ();
comment->SetValue (message.c_str ());
root->LinkEndChild (comment);
/* Cluster element */
TiXmlElement *cluster = new TiXmlElement ("Cluster");
root->LinkEndChild (cluster);
/* Set cluster attribute */
cluster->SetAttribute ("name", m_Name.c_str ());
/* Sensors element */
TiXmlElement *sensorsNode = new TiXmlElement ("Sensors");
root->LinkEndChild (sensorsNode);
/* Set sensor element and attributes */
std::list<SensorSettings>::iterator iter;
for (iter=m_Sensors.begin (); iter != m_Sensors.end (); iter++)
{
const SensorSettings& sensor_iter = *iter;
/* Sensor element */
TiXmlElement *sensor = new TiXmlElement ("Sensor");
sensorsNode->LinkEndChild (sensor);
/* Set sensor attributes */
sensor->SetAttribute ("tag", iter->get_tag ().c_str ());
sensor->SetAttribute ("online", iter->get_online ());
sensor->SetDoubleAttribute ("x", iter->get_x_coord ());
sensor->SetDoubleAttribute ("y", iter->get_y_coord ());
sensor->SetAttribute ("adata", iter->get_amount_data ());
sensor->SetAttribute ("type", iter->get_type ().c_str ());
}
/* Save xml to file */
doc.SaveFile (filename.c_str ());
}
示例4: 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 "";
}
示例5: assert
BOOL __stdcall DefaultLaserPen::save(LPCTSTR lpszFileName)
{
assert( lpszFileName);
FILE* stream = _tfopen(lpszFileName, _T("wb"));
if (NULL == stream)
return FALSE;
//tinyxml lib
TiXmlDocument doc;
TiXmlDeclaration* pDecl = new TiXmlDeclaration("1.0", "euc-kr", "");
doc.LinkEndChild(pDecl);
TiXmlElement* pRoot = new TiXmlElement("laserpen");
pRoot->SetAttribute("version", DA0LIB_VERSION);
pRoot->SetAttribute("count", this->size() );
doc.LinkEndChild(pRoot);
TiXmlComment * pComment = new TiXmlComment();
pComment->SetValue("2014 copyright to KOSES. all rights reserved. created by da0lib." );
pRoot->LinkEndChild( pComment );
CONTAINER_IT it = _pPimpl->container.begin();
for (; it != _pPimpl->container.end(); it++)
{
LASERPEN* pPen = it->second;
assert(pPen);
TiXmlElement* p = new TiXmlElement("pen");
p->SetAttribute("id", pPen->penid);
p->SetAttribute("frequency", pPen->frequency);
p->SetDoubleAttribute("pulsewidth", pPen->pulsewidth);
p->SetDoubleAttribute("output", pPen->output);
p->SetDoubleAttribute("speedmark" , pPen->speedmark);
p->SetDoubleAttribute("speedjump" , pPen->speedjump);
p->SetDoubleAttribute("delayoff" , pPen->delayoff);
p->SetDoubleAttribute("delayon" , pPen->delayon);
p->SetDoubleAttribute("delayjump" , pPen->delayjump);
p->SetDoubleAttribute("delaymark" , pPen->delaymark);
p->SetDoubleAttribute("delaypolygon" , pPen->delaypolygon);
p->SetAttribute("wobbelfrequency" , pPen->wobbelfrequency);
p->SetDoubleAttribute("wobbelamplitude" , pPen->wobbelamplitude);
pRoot->LinkEndChild(p);
}
doc.SaveFile(stream);
fclose( stream );
return TRUE;
}
示例6: TiXmlDeclaration
/*
* Generates setting placeholders for any missing sections
* ** Plugins should verify that their settings exist and
* ** create new placeholders if they do not exist!
*/
void Configuration::generateConfig()
{
TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
configs.LinkEndChild(decl);
TiXmlElement* root = new TiXmlElement("osdb");
configs.LinkEndChild(root);
TiXmlComment* comment = new TiXmlComment();
comment->SetValue(" Settings for OSDB ");
root->LinkEndChild(comment);
setConfigSetting("main", "logFilePath", "osdb.log");
setConfigSetting("main", "useStdOut", "true");
}
示例7: Visit
bool TiXmlPrinter::Visit( const TiXmlComment& comment )
{
DoIndent();
buffer += "<!--";
buffer += comment.Value();
buffer += "-->";
DoLineBreak();
return true;
}
示例8: addComment
void SimXMLDocument::addComment(const char* comment)
{
TiXmlComment cComment;
cComment.SetValue(comment);
if(m_paNode.empty())
{
Con::warnf("Cannot add comment without any elements: '%s'", comment);
return;
}
const int iFinalElement = m_paNode.size() - 1;
TiXmlElement* pNode = m_paNode[iFinalElement];
if(!pNode)
{
return;
}
pNode->InsertEndChild( cComment );
}
示例9: main
//.........这里部分代码省略.........
}
{
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
" <!-- Silly example -->\n"
" <door wall='north'>A great door!</door>\n"
"\t<door wall='east'/>"
"</room>";
TiXmlDocument doc;
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
TiXmlHandle commentHandle = docHandle.FirstChildElement( "room" ).FirstChild();
TiXmlHandle textHandle = docHandle.FirstChildElement( "room" ).ChildElement( "door", 0 ).FirstChild();
TiXmlHandle door0Handle = docHandle.FirstChildElement( "room" ).ChildElement( 0 );
TiXmlHandle door1Handle = docHandle.FirstChildElement( "room" ).ChildElement( 1 );
assert( docHandle.Node() );
assert( roomHandle.Element() );
assert( commentHandle.Node() );
assert( textHandle.Text() );
assert( door0Handle.Element() );
assert( door1Handle.Element() );
TiXmlDeclaration* declaration = doc.FirstChild()->ToDeclaration();
assert( declaration );
TiXmlElement* room = roomHandle.Element();
assert( room );
TiXmlAttribute* doors = room->FirstAttribute();
assert( doors );
TiXmlText* text = textHandle.Text();
TiXmlComment* comment = commentHandle.Node()->ToComment();
assert( comment );
TiXmlElement* door0 = door0Handle.Element();
TiXmlElement* door1 = door1Handle.Element();
XmlTest( "Location tracking: Declaration row", declaration->Row(), 1 );
XmlTest( "Location tracking: Declaration col", declaration->Column(), 5 );
XmlTest( "Location tracking: room row", room->Row(), 1 );
XmlTest( "Location tracking: room col", room->Column(), 45 );
XmlTest( "Location tracking: doors row", doors->Row(), 1 );
XmlTest( "Location tracking: doors col", doors->Column(), 51 );
XmlTest( "Location tracking: Comment row", comment->Row(), 2 );
XmlTest( "Location tracking: Comment col", comment->Column(), 3 );
XmlTest( "Location tracking: text row", text->Row(), 3 );
XmlTest( "Location tracking: text col", text->Column(), 24 );
XmlTest( "Location tracking: door0 row", door0->Row(), 3 );
XmlTest( "Location tracking: door0 col", door0->Column(), 5 );
XmlTest( "Location tracking: door1 row", door1->Row(), 4 );
XmlTest( "Location tracking: door1 col", door1->Column(), 5 );
}
// --------------------------------------------------------
// UTF-8 testing. It is important to test:
// 1. Making sure name, value, and text read correctly
// 2. Row, Col functionality
// 3. Correct output
// --------------------------------------------------------
printf ("\n** UTF-8 **\n");
{
TiXmlDocument doc( "utf8test.xml" );
doc.LoadFile();
if ( doc.Error() && doc.ErrorId() == TiXmlBase::TIXML_ERROR_OPENING_FILE ) {
示例10: TiXmlDeclaration
void COptions::WriteXMLData()
{
// Create document
TiXmlDocument newConfig;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF-8", "" );
newConfig.LinkEndChild( decl );
// Root node
TiXmlElement * root = new TiXmlElement( "Bombermaaan" );
newConfig.LinkEndChild( root );
// Comment
TiXmlComment * comment = new TiXmlComment();
comment->SetValue(" Configuration settings for the Bombermaaan game (http://bombermaaan.sf.net/) " );
root->LinkEndChild( comment );
// Configuration tree node - all options have this node as parent
TiXmlElement * config = new TiXmlElement( "Configuration" );
root->LinkEndChild( config );
//! The revision number is currently 1
TiXmlElement* configRev = new TiXmlElement( "ConfigRevision" );
configRev->SetAttribute( "value", 1 );
config->LinkEndChild( configRev );
// TimeUp (when will arena close begin)
TiXmlElement* configTimeUp = new TiXmlElement( "TimeUp" );
configTimeUp->SetAttribute( "minutes", m_TimeUpMinutes );
configTimeUp->SetAttribute( "seconds", m_TimeUpSeconds );
config->LinkEndChild( configTimeUp );
// TimeStart (the duration of a match)
TiXmlElement* configTimeStart = new TiXmlElement( "TimeStart" );
configTimeStart->SetAttribute( "minutes", m_TimeStartMinutes );
configTimeStart->SetAttribute( "seconds", m_TimeStartSeconds );
config->LinkEndChild( configTimeStart );
// BattleMode
TiXmlElement* configBattleMode = new TiXmlElement("BattleMode");
configBattleMode->SetAttribute("value", m_BattleMode);
config->LinkEndChild(configBattleMode);
// BattleCount
TiXmlElement* configBattleCount = new TiXmlElement( "BattleCount" );
configBattleCount->SetAttribute( "value", m_BattleCount );
config->LinkEndChild( configBattleCount );
// LevelFileNumber
TiXmlElement* configLevel = new TiXmlElement( "LevelFileNumber" );
configLevel->SetAttribute( "value", m_Level );
config->LinkEndChild( configLevel );
// DisplayMode
TiXmlElement* configDisplayMode = new TiXmlElement( "DisplayMode" );
configDisplayMode->SetAttribute( "value", (int) m_DisplayMode );
config->LinkEndChild( configDisplayMode );
int i;
// BomberTypes
TiXmlElement* configBomberTypes = new TiXmlElement( "BomberTypes" );
for ( i = 0; i < MAX_PLAYERS; i++ ) {
std::ostringstream oss;
oss << "bomber" << i;
std::string attributeName = oss.str();
configBomberTypes->SetAttribute( attributeName, (int) m_BomberType[i] );
}
config->LinkEndChild( configBomberTypes );
// BomberTeams
TiXmlElement* configBomberTeams = new TiXmlElement("BomberTeams");
for (i = 0; i < MAX_PLAYERS; i++) {
std::ostringstream oss;
oss << "bomber" << i;
std::string attributeName = oss.str();
configBomberTeams->SetAttribute(attributeName, (int)m_BomberTeam[i]);
}
config->LinkEndChild(configBomberTeams);
// PlayerInputs
TiXmlElement* configPlayerInputs = new TiXmlElement( "PlayerInputs" );
for ( i = 0; i < MAX_PLAYERS; i++ ) {
std::ostringstream oss;
oss << "bomber" << i;
std::string attributeName = oss.str();
configPlayerInputs->SetAttribute( attributeName, (int) m_PlayerInput[i] );
}
config->LinkEndChild( configPlayerInputs );
// ControlList
TiXmlElement* configControlList = new TiXmlElement( "ControlList" );
for ( unsigned int j = 0; j < MAX_PLAYER_INPUT; j++ )
{
TiXmlElement* configControl = new TiXmlElement( "Control" );
configControl->SetAttribute( "id", j );
for ( unsigned int ctrl = 0; ctrl < NUM_CONTROLS; ctrl++ )
{
std::ostringstream oss;
oss << "control" << ctrl;
std::string attributeName = oss.str();
//.........这里部分代码省略.........
示例11: TiXmlDocument
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);
}
示例12: TiXmlDeclaration
void input::saveKeys()
{
// printf("saving control file\n");
TiXmlDocument doc;
TiXmlElement* msg;
TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "", "");
doc.LinkEndChild(decl );
TiXmlElement * root = new TiXmlElement("controls");
doc.LinkEndChild(root );
TiXmlComment * comment = new TiXmlComment();
comment->SetValue("Keyboard mappings");
root->LinkEndChild(comment );
TiXmlElement * msgs = new TiXmlElement("keys");
root->LinkEndChild(msgs );
msg = new TiXmlElement("accept");
msg->SetAttribute("value", input::keys[KEY_ACCEPT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("accept_d1");
msg->SetAttribute("value", input::keys[KEY_DBG_ACCEPT1]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("accept_d2");
msg->SetAttribute("value", input::keys[KEY_DBG_ACCEPT2]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("cancel");
msg->SetAttribute("value", input::keys[KEY_CANCEL]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("up");
msg->SetAttribute("value", input::keys[KEY_UP]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("up_d");
msg->SetAttribute("value", input::keys[KEY_DBG_UP]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("down");
msg->SetAttribute("value", input::keys[KEY_DOWN]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("down_d");
msg->SetAttribute("value", input::keys[KEY_DBG_DOWN]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("left");
msg->SetAttribute("value", input::keys[KEY_LEFT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("left_d");
msg->SetAttribute("value", input::keys[KEY_DBG_LEFT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("right");
msg->SetAttribute("value", input::keys[KEY_RIGHT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("right_d");
msg->SetAttribute("value", input::keys[KEY_DBG_RIGHT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("upleft");
msg->SetAttribute("value", input::keys[KEY_UPLEFT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("upright");
msg->SetAttribute("value", input::keys[KEY_UPRIGHT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("downleft");
msg->SetAttribute("value", input::keys[KEY_DOWNLEFT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("downright");
msg->SetAttribute("value", input::keys[KEY_DOWNRIGHT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("attack");
msg->SetAttribute("value", input::keys[KEY_ATTACK]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("spells");
msg->SetAttribute("value", input::keys[KEY_SPELLS]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("inventory");
msg->SetAttribute("value", input::keys[KEY_INVENTORY]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("interact");
msg->SetAttribute("value", input::keys[KEY_INTERACT]->binding);
msgs->LinkEndChild(msg);
msg = new TiXmlElement("search");
//.........这里部分代码省略.........
示例13: main
//.........这里部分代码省略.........
}
{
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
" <!-- Silly example -->\n"
" <door wall='north'>A great door!</door>\n"
"\t<door wall='east'/>"
"</room>";
TiXmlDocument doc;
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
TiXmlHandle commentHandle = docHandle.FirstChildElement( "room" ).FirstChild();
TiXmlHandle textHandle = docHandle.FirstChildElement( "room" ).ChildElement( "door", 0 ).FirstChild();
TiXmlHandle door0Handle = docHandle.FirstChildElement( "room" ).ChildElement( 0 );
TiXmlHandle door1Handle = docHandle.FirstChildElement( "room" ).ChildElement( 1 );
assert( docHandle.Node() );
assert( roomHandle.Element() );
assert( commentHandle.Node() );
assert( textHandle.Text() );
assert( door0Handle.Element() );
assert( door1Handle.Element() );
TiXmlDeclaration* declaration = doc.FirstChild()->ToDeclaration();
assert( declaration );
TiXmlElement* room = roomHandle.Element();
assert( room );
TiXmlAttribute* doors = room->FirstAttribute();
assert( doors );
TiXmlText* text = textHandle.Text();
TiXmlComment* comment = commentHandle.Node()->ToComment();
assert( comment );
TiXmlElement* door0 = door0Handle.Element();
TiXmlElement* door1 = door1Handle.Element();
XmlTest( "Location tracking: Declaration row", declaration->Row(), 1 );
XmlTest( "Location tracking: Declaration col", declaration->Column(), 5 );
XmlTest( "Location tracking: room row", room->Row(), 1 );
XmlTest( "Location tracking: room col", room->Column(), 45 );
XmlTest( "Location tracking: doors row", doors->Row(), 1 );
XmlTest( "Location tracking: doors col", doors->Column(), 51 );
XmlTest( "Location tracking: Comment row", comment->Row(), 2 );
XmlTest( "Location tracking: Comment col", comment->Column(), 3 );
XmlTest( "Location tracking: text row", text->Row(), 3 );
XmlTest( "Location tracking: text col", text->Column(), 24 );
XmlTest( "Location tracking: door0 row", door0->Row(), 3 );
XmlTest( "Location tracking: door0 col", door0->Column(), 5 );
XmlTest( "Location tracking: door1 row", door1->Row(), 4 );
XmlTest( "Location tracking: door1 col", door1->Column(), 5 );
}
{
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
"</room>";
TiXmlDocument doc;
doc.SetTabSize( 8 );
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
assert( docHandle.Node() );
assert( roomHandle.Element() );
示例14: main
//.........这里部分代码省略.........
//printf( "error=%d id='%s' row %d col%d\n", (int) doc.Error(), doc.ErrorDesc(), doc.ErrorRow()+1, doc.ErrorCol() + 1 );
}
{
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
" <!-- Silly example -->\n"
" <door wall='north'>A great door!</door>\n"
"\t<door wall='east'/>"
"</room>";
TiXmlDocument doc;
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
TiXmlHandle commentHandle = docHandle.FirstChildElement( "room" ).FirstChild();
TiXmlHandle textHandle = docHandle.FirstChildElement( "room" ).ChildElement( "door", 0 ).FirstChild();
TiXmlHandle door0Handle = docHandle.FirstChildElement( "room" ).ChildElement( 0 );
TiXmlHandle door1Handle = docHandle.FirstChildElement( "room" ).ChildElement( 1 );
assert( docHandle.Node() );
assert( roomHandle.Element() );
assert( commentHandle.Node() );
assert( textHandle.Text() );
assert( door0Handle.Element() );
assert( door1Handle.Element() );
TiXmlDeclaration* declaration = doc.FirstChild()->ToDeclaration();
assert( declaration );
TiXmlElement* room = roomHandle.Element();
assert( room );
TiXmlAttribute* doors = room->FirstAttribute();
assert( doors );
TiXmlText* text = textHandle.Text();
TiXmlComment* comment = commentHandle.Node()->ToComment();
assert( comment );
TiXmlElement* door0 = door0Handle.Element();
TiXmlElement* door1 = door1Handle.Element();
XmlTest( "Location tracking: Declaration row", declaration->Row(), 1 );
XmlTest( "Location tracking: Declaration col", declaration->Column(), 5 );
XmlTest( "Location tracking: room row", room->Row(), 1 );
XmlTest( "Location tracking: room col", room->Column(), 45 );
XmlTest( "Location tracking: doors row", doors->Row(), 1 );
XmlTest( "Location tracking: doors col", doors->Column(), 51 );
XmlTest( "Location tracking: Comment row", comment->Row(), 2 );
XmlTest( "Location tracking: Comment col", comment->Column(), 3 );
XmlTest( "Location tracking: text row", text->Row(), 3 );
XmlTest( "Location tracking: text col", text->Column(), 24 );
XmlTest( "Location tracking: door0 row", door0->Row(), 3 );
XmlTest( "Location tracking: door0 col", door0->Column(), 5 );
XmlTest( "Location tracking: door1 row", door1->Row(), 4 );
XmlTest( "Location tracking: door1 col", door1->Column(), 5 );
}
{
const char* str = "\t<?xml version=\"1.0\" standalone=\"no\" ?>\t<room doors='2'>\n"
"</room>";
TiXmlDocument doc;
doc.SetTabSize( 8 );
doc.Parse( str );
TiXmlHandle docHandle( &doc );
TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" );
assert( docHandle.Node() );
assert( roomHandle.Element() );
示例15: TiXmlNode
TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT )
{
copy.CopyTo( this );
}