CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Macros | Functions
tinyxml.cc File Reference
#include <sstream>
#include <iostream>
#include "FWCore/Utilities/interface/tinyxml.h"
#include <boost/lexical_cast.hpp>

Go to the source code of this file.

Macros

#define TIXML_USE_STL
 

Functions

std::ostream & operator<< (std::ostream &out, const TiXmlNode &base)
 
std::string & operator<< (std::string &out, const TiXmlNode &base)
 
std::istream & operator>> (std::istream &in, TiXmlNode &base)
 
FILE * TiXmlFOpen (const char *filename, const char *mode)
 

Macro Definition Documentation

#define TIXML_USE_STL

Definition at line 32 of file tinyxml.cc.

Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const TiXmlNode base 
)

An output stream operator, for every class. Note that this outputs without any newlines or formatting, as opposed to Print(), which includes tabs and new lines.

The operator<< and operator>> are not completely symmetric. Writing a node to a stream is very well defined. You'll get a nice stream of output, without any extra whitespace or newlines.

But reading is not as well defined. (As it always is.) If you create a TiXmlElement (for example) and read that from an input stream, the text needs to define an element or junk will result. This is true of all input streams, but it's worth keeping in mind.

A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element.

Definition at line 1629 of file tinyxml.cc.

References TiXmlNode::Accept(), dbtoconf::out, TiXmlPrinter::SetStreamPrinting(), and TiXmlPrinter::Str().

1630 {
1631  TiXmlPrinter printer;
1632  printer.SetStreamPrinting();
1633  base.Accept( &printer );
1634  out << printer.Str();
1635 
1636  return out;
1637 }
virtual bool Accept(TiXmlVisitor *visitor) const =0
tuple out
Definition: dbtoconf.py:99
const std::string & Str()
Return the result.
Definition: tinyxml.h:1780
void SetStreamPrinting()
Definition: tinyxml.h:1770
std::string& operator<< ( std::string &  out,
const TiXmlNode base 
)

Definition at line 1640 of file tinyxml.cc.

References TiXmlNode::Accept(), dbtoconf::out, TiXmlPrinter::SetStreamPrinting(), and TiXmlPrinter::Str().

1641 {
1642  TiXmlPrinter printer;
1643  printer.SetStreamPrinting();
1644  base.Accept( &printer );
1645  out.append( printer.Str() );
1646 
1647  return out;
1648 }
virtual bool Accept(TiXmlVisitor *visitor) const =0
tuple out
Definition: dbtoconf.py:99
const std::string & Str()
Return the result.
Definition: tinyxml.h:1780
void SetStreamPrinting()
Definition: tinyxml.h:1770
std::istream& operator>> ( std::istream &  in,
TiXmlNode base 
)

An input stream operator, for every class. Tolerant of newlines and formatting, but doesn't expect them.

Definition at line 1616 of file tinyxml.cc.

References recoMuon::in, TiXmlBase::Parse(), TiXmlNode::StreamIn(), GlobalPosition_Frontier_DevDB_cff::tag, TIXML_DEFAULT_ENCODING, and TIXML_STRING.

1617 {
1618  TIXML_STRING tag;
1619  tag.reserve( 8 * 1000 );
1620  base.StreamIn( &in, &tag );
1621 
1622  base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
1623  return in;
1624 }
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:174
virtual void StreamIn(std::istream *in, std::string *tag)=0
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
#define TIXML_STRING
Definition: tinyxml.h:57
FILE* TiXmlFOpen ( const char *  filename,
const char *  mode 
)

Definition at line 46 of file tinyxml.cc.

Referenced by TiXmlDocument::LoadFile(), and TiXmlDocument::SaveFile().

47 {
48  #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
49  FILE* fp = 0;
50  errno_t err = fopen_s( &fp, filename, mode );
51  if ( !err && fp )
52  return fp;
53  return 0;
54  #else
55  return fopen( filename, mode );
56  #endif
57 }
tuple filename
Definition: lut2db_cfg.py:20