aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
tinyxml.cpp File Reference
#include "tinyxml.h"
#include <ctype.h>
#include <iostream>
#include <sstream>
+ Include dependency graph for tinyxml.cpp:

Go to the source code of this file.

Functions

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

Function Documentation

◆ operator<<() [1/2]

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

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 1516 of file tinyxml.cpp.

References TiXmlPrinter::SetStreamPrinting().

1516  {
1517  TiXmlPrinter printer;
1518  printer.SetStreamPrinting();
1519  base.Accept(&printer);
1520  out << printer.Str();
1521 
1522  return out;
1523 }
virtual bool Accept(TiXmlVisitor *visitor) const =0
Accept a hierchical visit the nodes in the TinyXML DOM.
Print to memory functionality.
Definition: tinyxml.h:2070
const std::string & Str()
Return the result.
Definition: tinyxml.h:2123
void SetStreamPrinting()
Switch over to "stream printing" which is the most dense formatting without linebreaks.
Definition: tinyxml.h:2112
+ Here is the call graph for this function:

◆ operator<<() [2/2]

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

Definition at line 1525 of file tinyxml.cpp.

References TiXmlPrinter::SetStreamPrinting().

1525  {
1526  TiXmlPrinter printer;
1527  printer.SetStreamPrinting();
1528  base.Accept(&printer);
1529  out.append(printer.Str());
1530 
1531  return out;
1532 }
virtual bool Accept(TiXmlVisitor *visitor) const =0
Accept a hierchical visit the nodes in the TinyXML DOM.
Print to memory functionality.
Definition: tinyxml.h:2070
const std::string & Str()
Return the result.
Definition: tinyxml.h:2123
void SetStreamPrinting()
Switch over to "stream printing" which is the most dense formatting without linebreaks.
Definition: tinyxml.h:2112
+ Here is the call graph for this function:

◆ operator>>()

std::istream& operator>> ( std::istream &  in,
TiXmlNode base 
)

Tolerant of newlines and formatting, but doesn't expect them.

Definition at line 1505 of file tinyxml.cpp.

1505  {
1506  TIXML_STRING tag;
1507  tag.reserve(8 * 1000);
1508  base.StreamIn(&in, &tag);
1509 
1510  base.Parse(tag.c_str(), 0, TIXML_DEFAULT_ENCODING);
1511  return in;
1512 }
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
const TiXmlEncoding TIXML_DEFAULT_ENCODING
Definition: tinyxml.h:185
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
#define TIXML_STRING
Definition: tinyxml.h:60

◆ TiXmlFOpen()

FILE* TiXmlFOpen ( const char *  filename,
const char *  mode 
)

Definition at line 37 of file tinyxml.cpp.

Referenced by TiXmlDocument::SaveFile().

37  {
38 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
39  FILE* fp = 0;
40  errno_t err = fopen_s(&fp, filename, mode);
41 
42  if (!err && fp) return fp;
43 
44  return 0;
45 #else
46  return fopen(filename, mode);
47 #endif
48 }
+ Here is the caller graph for this function: