本文整理汇总了C++中TiXmlElement::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::Print方法的具体用法?C++ TiXmlElement::Print怎么用?C++ TiXmlElement::Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::Print方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeConfigXML
bool ProRataConfig::writeConfigXML( string sOutputFile, int iTabDepth, bool bSicExtract, bool bPeptideQuan, bool bProteinQuan )
{
FILE * pFILE;
if( ( pFILE = fopen( sOutputFile.c_str(), "a" ) ) == NULL )
{
cout << "ERROR: cannot write Config XML to the file: " << sOutputFile << endl;
return false;
}
// TiXmlElement * pElementConfig = new TiXmlElement( "CONFIG" );
// pElementConfig->SetAttribute( "version", getProRataVersion() );
TiXmlDocument txdConfigFile;
// Try loading the file.
if ( ! ( txdConfigFile.LoadFile( sFilename.c_str() ) ) )
{
cout << "ERROR: Loading Configuration file!" << endl;
return false;
}
TiXmlElement * pElementConfig = txdConfigFile.FirstChildElement( "CONFIG" );
if( !pElementConfig )
{
cout << "ERROR: cannot find the CONFIG element in the given Configuration file! " << endl;
return false;
}
TiXmlNode * pElementSIC = pElementConfig->FirstChild( "SIC_EXTRACTION" );
TiXmlNode * pElementPeptideQuan = pElementConfig->FirstChild( "PEPTIDE_QUANTIFICATION" );
TiXmlNode * pElementProteinQuan = pElementConfig->FirstChild( "PROTEIN_QUANTIFICATION" );
if( (!bSicExtract) && pElementSIC )
{
pElementConfig->RemoveChild(pElementSIC);
}
if( (!bPeptideQuan) && pElementPeptideQuan )
{
pElementConfig->RemoveChild(pElementPeptideQuan);
}
if( (!bProteinQuan) && pElementProteinQuan )
{
pElementConfig->RemoveChild(pElementProteinQuan);
}
pElementConfig->Print( pFILE, iTabDepth );
fputs( "\n", pFILE );
fclose( pFILE );
return true;
}
示例2: storeToXML
/**
* 将键值对按照类似java中Properties类的xml格式存储 store "key-value" to xml file
* @param filename 要保存的xml文件名
* @return 布尔值,代表操作执行成功与否
*/
bool Properties::storeToXML(const string filename) const
{
TiXmlDocument doc;
TiXmlDeclarationWithoutStandalone *decl =
new TiXmlDeclarationWithoutStandalone("1.0", "UTF-8");
doc.LinkEndChild(decl);
TiXmlDoctype *doctype = new TiXmlDoctype();
doctype->SetValue("properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\"");
doc.LinkEndChild(doctype);
TiXmlComment *comment1 = new TiXmlComment();
comment1->SetValue("This file is created by libproperties");
doc.LinkEndChild(comment1);
TiXmlComment *comment2 = new TiXmlComment();
comment2->SetValue("read more from http://code.google.com/p/libproperties");
doc.LinkEndChild(comment2);
TiXmlElement *propertiesElement = new TiXmlElement("properties");
doc.LinkEndChild(propertiesElement);
for (const_iterator it = key_value.begin()
; it!=key_value.end() ;
++it
)
{
TiXmlElement *entryElement = new TiXmlElement("entry");
entryElement->LinkEndChild(new TiXmlText((*it).second));
#ifdef DEBUG_PROPERTIES_H
propertiesElement->Print(stdout, 1);
cout << endl;
#endif
propertiesElement->LinkEndChild(entryElement);
entryElement->SetAttribute("key", (*it).first);
}
bool result = doc.SaveFile(filename);
doc.Clear();
return result;
}
示例3: main
int main()
{
//
// We start with the 'demoStart' todo list. Process it. And
// should hopefully end up with the todo list as illustrated.
//
const char* demoStart =
"<?xml version=\"1.0\" standalone='no' >\n"
"<!-- Our to do list data -->"
"<ToDo>\n"
"<!-- Do I need a secure PDA? -->\n"
"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
"<Item priority=\"2\" distance='none'> Do bills </Item>"
"<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>"
"</ToDo>";
{
#ifdef TIXML_USE_STL
// What the todo list should look like after processing.
// In stream (no formatting) representation.
const char* demoEnd =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<!-- Our to do list data -->"
"<ToDo>"
"<!-- Do I need a secure PDA? -->"
"<Item priority=\"2\" distance=\"close\">Go to the"
"<bold>Toy store!"
"</bold>"
"</Item>"
"<Item priority=\"1\" distance=\"far\">Talk to:"
"<Meeting where=\"School\">"
"<Attendee name=\"Marple\" position=\"teacher\" />"
"<Attendee name=\"Voel\" position=\"counselor\" />"
"</Meeting>"
"<Meeting where=\"Lunch\" />"
"</Item>"
"<Item priority=\"2\" distance=\"here\">Do bills"
"</Item>"
"</ToDo>";
#endif
// The example parses from the character string (above):
#if defined( WIN32 ) && defined( TUNE )
_CrtMemCheckpoint( &startMemState );
#endif
{
// Write to a file and read it back, to check file I/O.
TiXmlDocument doc( "demotest.xml" );
doc.Parse( demoStart );
if ( doc.Error() )
{
printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
exit( 1 );
}
doc.SaveFile();
}
TiXmlDocument doc( "demotest.xml" );
bool loadOkay = doc.LoadFile();
if ( !loadOkay )
{
printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
exit( 1 );
}
printf( "** Demo doc read from disk: ** \n\n" );
printf( "** Printing via doc.Print **\n" );
doc.Print( stdout );
{
printf( "** Printing via TiXmlPrinter **\n" );
TiXmlPrinter printer;
doc.Accept( &printer );
fprintf( stdout, "%s", printer.CStr() );
}
#ifdef TIXML_USE_STL
{
printf( "** Printing via operator<< **\n" );
std::cout << doc;
}
#endif
TiXmlNode* node = 0;
TiXmlElement* todoElement = 0;
TiXmlElement* itemElement = 0;
// --------------------------------------------------------
// An example of changing existing attributes, and removing
// an element from the document.
// --------------------------------------------------------
// Get the "ToDo" element.
// It is a child of the document, and can be selected by name.
node = doc.FirstChild( "ToDo" );
//.........这里部分代码省略.........
示例4: close
bool FileSamplesOut::close () {
ssi_msg (SSI_LOG_LEVEL_DETAIL, "close files '%s'", _path);
if (!_console) {
if (!_file_data->close ()) {
ssi_wrn ("could not close data file '%s'", _path);
return false;
}
switch (_version) {
case File::V2: {
TiXmlElement info ("info" );
info.SetAttribute ("ftype", File::TYPE_NAMES[_file_data->getType ()]);
info.SetAttribute ("size", _n_samples);
info.SetAttribute ("missing", _has_missing_data ? 1 : 0);
info.SetAttribute ("garbage", _n_garbage_class);
TiXmlElement streams ("streams");
for (ssi_size_t i = 0; i < _n_streams; i++) {
TiXmlElement item ("item");
item.SetDoubleAttribute ("sr", _streams[i].sr);
item.SetAttribute ("dim", _streams[i].dim);
item.SetAttribute ("byte", _streams[i].byte);
item.SetAttribute ("type", SSI_TYPE_NAMES[_streams[i].type]);
streams.InsertEndChild (item);
}
info.InsertEndChild (streams);
TiXmlElement classes ("classes");
for (ssi_size_t i = 0; i < _n_classes; i++) {
TiXmlElement item ("item");
item.SetAttribute ("name", _classes[i]);
item.SetAttribute ("size", _n_per_class[i]);
classes.InsertEndChild (item);
}
info.InsertEndChild (classes);
TiXmlElement users ("users");
for (ssi_size_t i = 0; i < _n_users; i++) {
TiXmlElement item ("item");
item.SetAttribute ("name", _users[i]);
item.SetAttribute ("size", _n_per_user[i]);
users.InsertEndChild (item);
}
info.InsertEndChild (users);
info.Print (_file_info->getFile (), 1);
_file_info->writeLine ("\n</samples>");
if (!_file_info->close ()) {
ssi_wrn ("could not close info file '%s'", _file_info->getPath ());
return false;
}
}
break;
case File::V3: {
TiXmlElement info ("info" );
info.SetAttribute ("ftype", File::TYPE_NAMES[_file_data->getType ()]);
info.SetAttribute ("size", _n_samples);
info.SetAttribute ("missing", _has_missing_data ? "true" : "false");
info.SetAttribute ("garbage", _n_garbage_class);
TiXmlElement streams ("streams");
for (ssi_size_t i = 0; i < _n_streams; i++) {
TiXmlElement item ("item");
FilePath fp (_file_streams[i].getInfoFile ()->getPath ());
item.SetAttribute ("path", fp.getName ());
streams.InsertEndChild (item);
}
TiXmlElement classes ("classes");
for (ssi_size_t i = 0; i < _n_classes; i++) {
TiXmlElement item ("item");
item.SetAttribute ("name", _classes[i]);
item.SetAttribute ("size", _n_per_class[i]);
classes.InsertEndChild (item);
}
TiXmlElement users ("users");
for (ssi_size_t i = 0; i < _n_users; i++) {
TiXmlElement item ("item");
item.SetAttribute ("name", _users[i]);
item.SetAttribute ("size", _n_per_user[i]);
users.InsertEndChild (item);
}
info.Print (_file_info->getFile (), 1);
_file_info->writeLine ("");
streams.Print (_file_info->getFile (), 1);
_file_info->writeLine ("");
classes.Print (_file_info->getFile (), 1);
_file_info->writeLine ("");
users.Print (_file_info->getFile (), 1);
//.........这里部分代码省略.........
示例5: main
int main()
{
//
// We start with the 'demoStart' todo list. Process it. And
// should hopefully end up with the todo list as illustrated.
//
const char* demoStart =
"<?xml version=\"1.0\" standalone='no' >\n"
"<!-- Our to do list data -->"
"<ToDo>\n"
"<!-- Do I need a secure PDA? -->\n"
"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
"<Item priority=\"2\" distance='none'> Do bills </Item>"
"<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>"
"</ToDo>";
#ifdef TIXML_USE_STL
/* What the todo list should look like after processing.
In stream (no formatting) representation. */
const char* demoEnd =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<!-- Our to do list data -->"
"<ToDo>"
"<!-- Do I need a secure PDA? -->"
"<Item priority=\"2\" distance=\"close\">Go to the"
"<bold>Toy store!"
"</bold>"
"</Item>"
"<Item priority=\"1\" distance=\"far\">Talk to:"
"<Meeting where=\"School\">"
"<Attendee name=\"Marple\" position=\"teacher\" />"
"<Attendee name=\"Voel\" position=\"counselor\" />"
"</Meeting>"
"<Meeting where=\"Lunch\" />"
"</Item>"
"<Item priority=\"2\" distance=\"here\">Do bills"
"</Item>"
"</ToDo>";
#endif
// The example parses from the character string (above):
#if defined( WIN32 ) && defined( TUNE )
QueryPerformanceCounter( (LARGE_INTEGER*) (&start) );
#endif
{
// Write to a file and read it back, to check file I/O.
TiXmlDocument doc( "demotest.xml" );
doc.Parse( demoStart );
if ( doc.Error() )
{
printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
exit( 1 );
}
doc.SaveFile();
}
TiXmlDocument doc( "demotest.xml" );
bool loadOkay = doc.LoadFile();
if ( !loadOkay )
{
printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
exit( 1 );
}
printf( "** Demo doc read from disk: ** \n\n" );
doc.Print( stdout );
TiXmlNode* node = 0;
TiXmlElement* todoElement = 0;
TiXmlElement* itemElement = 0;
// --------------------------------------------------------
// An example of changing existing attributes, and removing
// an element from the document.
// --------------------------------------------------------
// Get the "ToDo" element.
// It is a child of the document, and can be selected by name.
node = doc.FirstChild( "ToDo" );
assert( node );
todoElement = node->ToElement();
assert( todoElement );
// Going to the toy store is now our second priority...
// So set the "priority" attribute of the first item in the list.
node = todoElement->FirstChildElement(); // This skips the "PDA" comment.
assert( node );
itemElement = node->ToElement();
assert( itemElement );
itemElement->SetAttribute( "priority", 2 );
// Change the distance to "doing bills" from
// "none" to "here". It's the next sibling element.
itemElement = itemElement->NextSiblingElement();
assert( itemElement );
//.........这里部分代码省略.........
示例6: writeFileQPR
//.........这里部分代码省略.........
// creat CONFIDENCE_INTERVAL
TiXmlElement * pElementCI = new TiXmlElement( "CONFIDENCE_INTERVAL" );
TiXmlElement * pElementUpperLimitCI = new TiXmlElement( "UPPER_LIMIT" );
ossStream.str("");
ossStream << vpProteinInfo[i]->getUpperLimitCI();
TiXmlText * pTextUpperLimitCI = new TiXmlText( ossStream.str().c_str() );
pElementUpperLimitCI->LinkEndChild( pTextUpperLimitCI );
pElementCI->LinkEndChild( pElementUpperLimitCI );
TiXmlElement * pElementLowerLimitCI = new TiXmlElement( "LOWER_LIMIT" );
ossStream.str("");
ossStream << vpProteinInfo[i]->getLowerLimitCI();
TiXmlText * pTextLowerLimitCI = new TiXmlText( ossStream.str().c_str() );
pElementLowerLimitCI->LinkEndChild( pTextLowerLimitCI );
pElementCI->LinkEndChild(pElementLowerLimitCI );
pElementProtein->LinkEndChild( pElementCI );
vector< PeptideInfo * > vpTempPeptideInfo = vpProteinInfo[i]->getPeptideInfo();
sortPeptideInfo( vpTempPeptideInfo, "sequence" );
for( j = 0; j < vpTempPeptideInfo.size(); ++j )
{
TiXmlElement * pElementPeptide = new TiXmlElement( "PEPTIDE" );
TiXmlElement * pElementChroFilename = new TiXmlElement( "XIC_FILE" );
TiXmlText * pTextChroFilename = new TiXmlText( vpTempPeptideInfo[j]->getFilename().c_str() );
pElementChroFilename->LinkEndChild( pTextChroFilename );
pElementPeptide->LinkEndChild( pElementChroFilename );
TiXmlElement * pElementIdentifier = new TiXmlElement( "XIC_IDENTIFIER" );
ossStream.str("");
ossStream << vpTempPeptideInfo[j]->getIdentifier();
TiXmlText * pTextIdentifier = new TiXmlText( ossStream.str().c_str() );
pElementIdentifier->LinkEndChild( pTextIdentifier );
pElementPeptide->LinkEndChild( pElementIdentifier );
TiXmlElement * pElementValidity = new TiXmlElement( "VALIDITY" );
ossStream.str("");
ossStream << boolalpha << vpTempPeptideInfo[j]->getValidity();
TiXmlText * pTextValidity = new TiXmlText( ossStream.str().c_str() );
pElementValidity->LinkEndChild( pTextValidity );
pElementPeptide->LinkEndChild( pElementValidity );
TiXmlElement * pElementPCALog2Ratio = new TiXmlElement( "LOG2RATIO" );
ossStream.str("");
ossStream << vpTempPeptideInfo[j]->getPCALog2Ratio();
TiXmlText * pTextPCALog2Ratio = new TiXmlText( ossStream.str().c_str() );
pElementPCALog2Ratio->LinkEndChild( pTextPCALog2Ratio );
pElementPeptide->LinkEndChild( pElementPCALog2Ratio );
TiXmlElement * pElementLog2SNR = new TiXmlElement( "LOG2SN" );
ossStream.str("");
ossStream << vpTempPeptideInfo[j]->getPCALog2SNR();
TiXmlText * pTextPCALog2SNR = new TiXmlText( ossStream.str().c_str() );
pElementLog2SNR->LinkEndChild( pTextPCALog2SNR );
pElementPeptide->LinkEndChild( pElementLog2SNR );
TiXmlElement * pElementSequence = new TiXmlElement( "SEQUENCE" );
TiXmlText * pTextSequence = new TiXmlText( vpTempPeptideInfo[j]->getSequence().c_str() );
pElementSequence->LinkEndChild( pTextSequence );
pElementPeptide->LinkEndChild( pElementSequence );
TiXmlElement * pElementChargeState = new TiXmlElement( "Z" );
ossStream.str("");
ossStream << vpTempPeptideInfo[j]->getChargeState();
TiXmlText * pTextChargeState = new TiXmlText( ossStream.str().c_str() );
pElementChargeState->LinkEndChild( pTextChargeState );
pElementPeptide->LinkEndChild( pElementChargeState );
TiXmlElement * pElementScore = new TiXmlElement( "ID_SCORE" );
ossStream.str("");
ossStream << vpTempPeptideInfo[j]->getMaximumScore();
TiXmlText * pTextScore = new TiXmlText( ossStream.str().c_str() );
pElementScore ->LinkEndChild( pTextScore );
pElementPeptide->LinkEndChild( pElementScore );
vector< string > vsLocus = vpTempPeptideInfo[j]->getLocus();
for( k = 0; k < vsLocus.size(); ++k )
{
TiXmlElement * pElementLocus = new TiXmlElement( "LOCUS" );
TiXmlText * pTextLocus = new TiXmlText( vsLocus[k].c_str() );
pElementLocus->LinkEndChild( pTextLocus );
pElementPeptide->LinkEndChild( pElementLocus );
}
pElementProtein->LinkEndChild( pElementPeptide );
}
pElementProtein->Print( pFILE, 1 );
fputs( "\n", pFILE );
delete pElementProtein;
}
ossStream.str("");
ossStream << "</QUANTITATIVE_PROTEOMICS>" << "\n";
fputs( ossStream.str().c_str(), pFILE );
fclose( pFILE );
}
示例7: main
int main()
{
//
// We start with the 'demoStart' todo list. Process it. And
// should hopefully end up with the todo list as illustrated.
//
const char* demoStart =
"<?xml version=\"1.0\" standalone='no' >\n"
"<!-- Our to do list data -->"
"<ToDo>\n"
"<!-- Do I need a secure PDA? -->\n"
"<Item priority=\"1\" distance='close'> Go to the <bold>Toy store!</bold></Item>"
"<Item priority=\"2\" distance='none'> Do bills </Item>"
"<Item priority=\"2\" distance='far & back'> Look for Evil Dinosaurs! </Item>"
"</ToDo>";
#ifdef TIXML_USE_STL
/* What the todo list should look like after processing.
In stream (no formatting) representation. */
const char* demoEnd =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<!-- Our to do list data -->"
"<ToDo>"
"<!-- Do I need a secure PDA? -->"
"<Item priority=\"2\" distance=\"close\">Go to the"
"<bold>Toy store!"
"</bold>"
"</Item>"
"<Item priority=\"1\" distance=\"far\">Talk to:"
"<Meeting where=\"School\">"
"<Attendee name=\"Marple\" position=\"teacher\" />"
"<Attendee name=\"Vo‚\" position=\"counselor\" />"
"</Meeting>"
"<Meeting where=\"Lunch\" />"
"</Item>"
"<Item priority=\"2\" distance=\"here\">Do bills"
"</Item>"
"</ToDo>";
#endif
// The example parses from the character string (above):
#if defined( WIN32 ) && defined( TUNE )
QueryPerformanceCounter( (LARGE_INTEGER*) (&start) );
#endif
{
// Write to a file and read it back, to check file I/O.
TiXmlDocument doc( "demotest.xml" );
doc.Parse( demoStart );
if ( doc.Error() )
{
printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() );
exit( 1 );
}
doc.SaveFile();
}
ostringstream outputStream( ostringstream::out );
{
TiXmlDocument doc( "demotest.xml" );
bool loadOkay = doc.LoadFile();
if ( !loadOkay )
{
printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() );
exit( 1 );
}
printf( "** Demo doc read from disk: ** \n\n" );
doc.Print( stdout );
TiXmlNode* node = 0;
TiXmlElement* todoElement = 0;
TiXmlElement* itemElement = 0;
// --------------------------------------------------------
// An example of changing existing attributes, and removing
// an element from the document.
// --------------------------------------------------------
// Get the "ToDo" element.
// It is a child of the document, and can be selected by name.
node = doc.FirstChild( "ToDo" );
assert( node );
todoElement = node->ToElement();
assert( todoElement );
// Going to the toy store is now our second priority...
// So set the "priority" attribute of the first item in the list.
node = todoElement->FirstChildElement(); // This skips the "PDA" comment.
assert( node );
itemElement = node->ToElement();
assert( itemElement );
itemElement->SetAttribute( "priority", 2 );
// Change the distance to "doing bills" from
// "none" to "here". It's the next sibling element.
itemElement = itemElement->NextSiblingElement();
//.........这里部分代码省略.........