ReactOS 0.4.15-dev-8348-gc1b9bb5
tinyxml2::XMLPrinter Class Reference

#include <tinyxml2.h>

Inheritance diagram for tinyxml2::XMLPrinter:
Collaboration diagram for tinyxml2::XMLPrinter:

Public Member Functions

 XMLPrinter (FILE *file=0, bool compact=false, int depth=0)
 
virtual ~XMLPrinter ()
 
void PushHeader (bool writeBOM, bool writeDeclaration)
 
void OpenElement (const char *name, bool compactMode=false)
 
void PushAttribute (const char *name, const char *value)
 If streaming, add an attribute to an open element.
 
void PushAttribute (const char *name, int value)
 
void PushAttribute (const char *name, unsigned value)
 
void PushAttribute (const char *name, bool value)
 
void PushAttribute (const char *name, double value)
 
virtual void CloseElement (bool compactMode=false)
 If streaming, close the Element.
 
void PushText (const char *text, bool cdata=false)
 Add a text node.
 
void PushText (int value)
 Add a text node from an integer.
 
void PushText (unsigned value)
 Add a text node from an unsigned.
 
void PushText (bool value)
 Add a text node from a bool.
 
void PushText (float value)
 Add a text node from a float.
 
void PushText (double value)
 Add a text node from a double.
 
void PushComment (const char *comment)
 Add a comment.
 
void PushDeclaration (const char *value)
 
void PushUnknown (const char *value)
 
virtual bool VisitEnter (const XMLDocument &)
 Visit a document.
 
virtual bool VisitExit (const XMLDocument &)
 Visit a document.
 
virtual bool VisitEnter (const XMLElement &element, const XMLAttribute *attribute)
 Visit an element.
 
virtual bool VisitExit (const XMLElement &element)
 Visit an element.
 
virtual bool Visit (const XMLText &text)
 Visit a text node.
 
virtual bool Visit (const XMLComment &comment)
 Visit a comment node.
 
virtual bool Visit (const XMLDeclaration &declaration)
 Visit a declaration.
 
virtual bool Visit (const XMLUnknown &unknown)
 Visit an unknown node.
 
const charCStr () const
 
int CStrSize () const
 
void ClearBuffer ()
 
- Public Member Functions inherited from tinyxml2::XMLVisitor
virtual ~XMLVisitor ()
 
virtual bool VisitEnter (const XMLDocument &)
 Visit a document.
 
virtual bool VisitExit (const XMLDocument &)
 Visit a document.
 
virtual bool VisitEnter (const XMLElement &, const XMLAttribute *)
 Visit an element.
 
virtual bool VisitExit (const XMLElement &)
 Visit an element.
 
virtual bool Visit (const XMLDeclaration &)
 Visit a declaration.
 
virtual bool Visit (const XMLText &)
 Visit a text node.
 
virtual bool Visit (const XMLComment &)
 Visit a comment node.
 
virtual bool Visit (const XMLUnknown &)
 Visit an unknown node.
 

Protected Member Functions

virtual bool CompactMode (const XMLElement &)
 
virtual void PrintSpace (int depth)
 
void Print (const char *format,...)
 
void SealElementIfJustOpened ()
 

Protected Attributes

bool _elementJustOpened
 
DynArray< const char *, 10 > _stack
 

Private Types

enum  { ENTITY_RANGE = 64 , BUF_SIZE = 200 }
 

Private Member Functions

void PrintString (const char *, bool restrictedEntitySet)
 

Private Attributes

bool _firstElement
 
FILE_fp
 
int _depth
 
int _textDepth
 
bool _processEntities
 
bool _compactMode
 
bool _entityFlag [ENTITY_RANGE]
 
bool _restrictedEntityFlag [ENTITY_RANGE]
 
DynArray< char, 20 > _buffer
 

Detailed Description

Printing functionality. The XMLPrinter gives you more options than the XMLDocument::Print() method.

It can:

  1. Print to memory.
  2. Print to a file you provide.
  3. Print XML without a XMLDocument.

Print to Memory

XMLPrinter printer;
doc.Print( &printer );
SomeFunction( printer.CStr() );

Print to a File

You provide the file pointer.

XMLPrinter printer( fp );
doc.Print( &printer );

Print without a XMLDocument

When loading, an XML parser is very useful. However, sometimes when saving, it just gets in the way. The code is often set up for streaming, and constructing the DOM is just overhead.

The Printer supports the streaming case. The following code prints out a trivially simple XML file without ever creating an XML document.

XMLPrinter printer( fp );
printer.OpenElement( "foo" );
printer.PushAttribute( "foo", "bar" );
printer.CloseElement();

Definition at line 1979 of file tinyxml2.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ENTITY_RANGE 
BUF_SIZE 

Definition at line 2085 of file tinyxml2.h.

2085 {
2086 ENTITY_RANGE = 64,
2087 BUF_SIZE = 200
2088 };

Constructor & Destructor Documentation

◆ XMLPrinter()

tinyxml2::XMLPrinter::XMLPrinter ( FILE file = 0,
bool  compact = false,
int  depth = 0 
)

Construct the printer. If the FILE* is specified, this will print to the FILE. Else it will print to memory, and the result is available in CStr(). If 'compact' is set to true, then output is created with only required whitespace and newlines.

Definition at line 2105 of file tinyxml2.cpp.

2105 :
2106 _elementJustOpened( false ),
2107 _firstElement( true ),
2108 _fp( file ),
2109 _depth( depth ),
2110 _textDepth( -1 ),
2111 _processEntities( true ),
2112 _compactMode( compact )
2113{
2114 for( int i=0; i<ENTITY_RANGE; ++i ) {
2115 _entityFlag[i] = false;
2116 _restrictedEntityFlag[i] = false;
2117 }
2118 for( int i=0; i<NUM_ENTITIES; ++i ) {
2119 const char entityValue = entities[i].value;
2120 TIXMLASSERT( 0 <= entityValue && entityValue < ENTITY_RANGE );
2121 _entityFlag[ (unsigned char)entityValue ] = true;
2122 }
2123 _restrictedEntityFlag[(unsigned char)'&'] = true;
2124 _restrictedEntityFlag[(unsigned char)'<'] = true;
2125 _restrictedEntityFlag[(unsigned char)'>'] = true; // not required, but consistency is nice
2126 _buffer.Push( 0 );
2127}
void Push(T t)
Definition: tinyxml2.h:203
DynArray< char, 20 > _buffer
Definition: tinyxml2.h:2092
bool _entityFlag[ENTITY_RANGE]
Definition: tinyxml2.h:2089
bool _restrictedEntityFlag[ENTITY_RANGE]
Definition: tinyxml2.h:2090
unsigned char
Definition: typeof.h:29
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const Entity entities[NUM_ENTITIES]
Definition: tinyxml2.cpp:129
static const int NUM_ENTITIES
Definition: tinyxml2.cpp:128
Definition: fci.c:127
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88

◆ ~XMLPrinter()

virtual tinyxml2::XMLPrinter::~XMLPrinter ( )
inlinevirtual

Definition at line 1989 of file tinyxml2.h.

1989{}

Member Function Documentation

◆ ClearBuffer()

void tinyxml2::XMLPrinter::ClearBuffer ( )
inline

If in print to memory mode, reset the buffer to the beginning.

Definition at line 2057 of file tinyxml2.h.

2057 {
2058 _buffer.Clear();
2059 _buffer.Push(0);
2060 }

◆ CloseElement()

void tinyxml2::XMLPrinter::CloseElement ( bool  compactMode = false)
virtual

If streaming, close the Element.

Definition at line 2282 of file tinyxml2.cpp.

2283{
2284 --_depth;
2285 const char* name = _stack.Pop();
2286
2287 if ( _elementJustOpened ) {
2288 Print( "/>" );
2289 }
2290 else {
2291 if ( _textDepth < 0 && !compactMode) {
2292 Print( "\n" );
2293 PrintSpace( _depth );
2294 }
2295 Print( "</%s>", name );
2296 }
2297
2298 if ( _textDepth == _depth ) {
2299 _textDepth = -1;
2300 }
2301 if ( _depth == 0 && !compactMode) {
2302 Print( "\n" );
2303 }
2304 _elementJustOpened = false;
2305}
virtual void PrintSpace(int depth)
Definition: tinyxml2.cpp:2152
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:2073
void Print(const char *format,...)
Definition: tinyxml2.cpp:2130
Definition: name.c:39

Referenced by VisitExit().

◆ CompactMode()

virtual bool tinyxml2::XMLPrinter::CompactMode ( const XMLElement )
inlineprotectedvirtual

Definition at line 2063 of file tinyxml2.h.

2063{ return _compactMode; }

Referenced by VisitEnter(), and VisitExit().

◆ CStr()

const char * tinyxml2::XMLPrinter::CStr ( ) const
inline

If in print to memory mode, return a pointer to the XML file in memory.

Definition at line 2042 of file tinyxml2.h.

2042 {
2043 return _buffer.Mem();
2044 }
const T * Mem() const
Definition: tinyxml2.h:257

◆ CStrSize()

int tinyxml2::XMLPrinter::CStrSize ( ) const
inline

If in print to memory mode, return the size of the XML file in memory. (Note the size returned includes the terminating null.)

Definition at line 2050 of file tinyxml2.h.

2050 {
2051 return _buffer.Size();
2052 }
int Size() const
Definition: tinyxml2.h:247

◆ OpenElement()

void tinyxml2::XMLPrinter::OpenElement ( const char name,
bool  compactMode = false 
)

If streaming, start writing an element. The element must be closed with CloseElement()

Definition at line 2222 of file tinyxml2.cpp.

2223{
2225 _stack.Push( name );
2226
2227 if ( _textDepth < 0 && !_firstElement && !compactMode ) {
2228 Print( "\n" );
2229 }
2230 if ( !compactMode ) {
2231 PrintSpace( _depth );
2232 }
2233
2234 Print( "<%s", name );
2235 _elementJustOpened = true;
2236 _firstElement = false;
2237 ++_depth;
2238}
void SealElementIfJustOpened()
Definition: tinyxml2.cpp:2308

Referenced by VisitEnter().

◆ Print()

void tinyxml2::XMLPrinter::Print ( const char format,
  ... 
)
protected

Definition at line 2130 of file tinyxml2.cpp.

2131{
2132 va_list va;
2133 va_start( va, format );
2134
2135 if ( _fp ) {
2136 vfprintf( _fp, format, va );
2137 }
2138 else {
2139 const int len = TIXML_VSCPRINTF( format, va );
2140 // Close out and re-start the va-args
2141 va_end( va );
2142 TIXMLASSERT( len >= 0 );
2143 va_start( va, format );
2144 TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 );
2145 char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.
2146 TIXML_VSNPRINTF( p, len+1, format, va );
2147 }
2148 va_end( va );
2149}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
T * PushArr(int count)
Definition: tinyxml2.h:209
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
static int TIXML_VSCPRINTF(const char *format, va_list va)
Definition: tinyxml2.cpp:94
#define TIXML_VSNPRINTF
Definition: tinyxml2.cpp:93

Referenced by CloseElement(), OpenElement(), PrintSpace(), PrintString(), PushAttribute(), PushComment(), PushDeclaration(), PushHeader(), PushText(), PushUnknown(), and SealElementIfJustOpened().

◆ PrintSpace()

void tinyxml2::XMLPrinter::PrintSpace ( int  depth)
protectedvirtual

Prints out the space before an element. You may override to change the space and tabs used. A PrintSpace() override should call Print().

Definition at line 2152 of file tinyxml2.cpp.

2153{
2154 for( int i=0; i<depth; ++i ) {
2155 Print( " " );
2156 }
2157}

Referenced by CloseElement(), OpenElement(), PushComment(), PushDeclaration(), and PushUnknown().

◆ PrintString()

void tinyxml2::XMLPrinter::PrintString ( const char p,
bool  restrictedEntitySet 
)
private

Definition at line 2160 of file tinyxml2.cpp.

2161{
2162 // Look for runs of bytes between entities to print.
2163 const char* q = p;
2164
2165 if ( _processEntities ) {
2166 const bool* flag = restricted ? _restrictedEntityFlag : _entityFlag;
2167 while ( *q ) {
2168 TIXMLASSERT( p <= q );
2169 // Remember, char is sometimes signed. (How many times has that bitten me?)
2170 if ( *q > 0 && *q < ENTITY_RANGE ) {
2171 // Check for entities. If one is found, flush
2172 // the stream up until the entity, write the
2173 // entity, and keep looking.
2174 if ( flag[(unsigned char)(*q)] ) {
2175 while ( p < q ) {
2176 const size_t delta = q - p;
2177 // %.*s accepts type int as "precision"
2178 const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
2179 Print( "%.*s", toPrint, p );
2180 p += toPrint;
2181 }
2182 bool entityPatternPrinted = false;
2183 for( int i=0; i<NUM_ENTITIES; ++i ) {
2184 if ( entities[i].value == *q ) {
2185 Print( "&%s;", entities[i].pattern );
2186 entityPatternPrinted = true;
2187 break;
2188 }
2189 }
2190 if ( !entityPatternPrinted ) {
2191 // TIXMLASSERT( entityPatternPrinted ) causes gcc -Wunused-but-set-variable in release
2192 TIXMLASSERT( false );
2193 }
2194 ++p;
2195 }
2196 }
2197 ++q;
2198 TIXMLASSERT( p <= q );
2199 }
2200 }
2201 // Flush the remaining string. This will be the entire
2202 // string if an entity wasn't found.
2203 TIXMLASSERT( p <= q );
2204 if ( !_processEntities || ( p < q ) ) {
2205 Print( "%s", p );
2206 }
2207}
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLubyte * pattern
Definition: glext.h:7787
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
#define INT_MAX
Definition: limits.h:40
Definition: pdh_main.c:94

Referenced by PushAttribute(), and PushText().

◆ PushAttribute() [1/5]

void tinyxml2::XMLPrinter::PushAttribute ( const char name,
bool  value 
)

Definition at line 2266 of file tinyxml2.cpp.

2267{
2268 char buf[BUF_SIZE];
2271}
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
Definition: tinyxml2.cpp:2241
static void ToStr(int v, char *buffer, int bufferSize)
Definition: tinyxml2.cpp:526
const GLdouble * v
Definition: gl.h:2040
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

◆ PushAttribute() [2/5]

void tinyxml2::XMLPrinter::PushAttribute ( const char name,
const char value 
)

If streaming, add an attribute to an open element.

Definition at line 2241 of file tinyxml2.cpp.

2242{
2244 Print( " %s=\"", name );
2245 PrintString( value, false );
2246 Print( "\"" );
2247}
void PrintString(const char *, bool restrictedEntitySet)
Definition: tinyxml2.cpp:2160

Referenced by PushAttribute(), and VisitEnter().

◆ PushAttribute() [3/5]

void tinyxml2::XMLPrinter::PushAttribute ( const char name,
double  value 
)

Definition at line 2274 of file tinyxml2.cpp.

2275{
2276 char buf[BUF_SIZE];
2279}

◆ PushAttribute() [4/5]

void tinyxml2::XMLPrinter::PushAttribute ( const char name,
int  value 
)

Definition at line 2250 of file tinyxml2.cpp.

2251{
2252 char buf[BUF_SIZE];
2255}

◆ PushAttribute() [5/5]

void tinyxml2::XMLPrinter::PushAttribute ( const char name,
unsigned  value 
)

Definition at line 2258 of file tinyxml2.cpp.

2259{
2260 char buf[BUF_SIZE];
2263}

◆ PushComment()

void tinyxml2::XMLPrinter::PushComment ( const char comment)

Add a comment.

Definition at line 2371 of file tinyxml2.cpp.

2372{
2374 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2375 Print( "\n" );
2376 PrintSpace( _depth );
2377 }
2378 _firstElement = false;
2379 Print( "<!--%s-->", comment );
2380}
#define comment(fmt, arg1)
Definition: rebar.c:820

Referenced by Visit().

◆ PushDeclaration()

void tinyxml2::XMLPrinter::PushDeclaration ( const char value)

Definition at line 2383 of file tinyxml2.cpp.

2384{
2386 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2387 Print( "\n" );
2388 PrintSpace( _depth );
2389 }
2390 _firstElement = false;
2391 Print( "<?%s?>", value );
2392}

Referenced by PushHeader(), and Visit().

◆ PushHeader()

void tinyxml2::XMLPrinter::PushHeader ( bool  writeBOM,
bool  writeDeclaration 
)

If streaming, write the BOM and declaration.

Definition at line 2210 of file tinyxml2.cpp.

2211{
2212 if ( writeBOM ) {
2213 static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 };
2214 Print( "%s", bom );
2215 }
2216 if ( writeDec ) {
2217 PushDeclaration( "xml version=\"1.0\"" );
2218 }
2219}
void PushDeclaration(const char *value)
Definition: tinyxml2.cpp:2383
static const unsigned char TIXML_UTF_LEAD_0
Definition: tinyxml2.cpp:115
static const unsigned char TIXML_UTF_LEAD_1
Definition: tinyxml2.cpp:116
static const unsigned char TIXML_UTF_LEAD_2
Definition: tinyxml2.cpp:117

Referenced by VisitEnter().

◆ PushText() [1/6]

void tinyxml2::XMLPrinter::PushText ( bool  value)

Add a text node from a bool.

Definition at line 2347 of file tinyxml2.cpp.

2348{
2349 char buf[BUF_SIZE];
2351 PushText( buf, false );
2352}
void PushText(const char *text, bool cdata=false)
Add a text node.
Definition: tinyxml2.cpp:2318

◆ PushText() [2/6]

void tinyxml2::XMLPrinter::PushText ( const char text,
bool  cdata = false 
)

Add a text node.

Definition at line 2318 of file tinyxml2.cpp.

2319{
2320 _textDepth = _depth-1;
2321
2323 if ( cdata ) {
2324 Print( "<![CDATA[%s]]>", text );
2325 }
2326 else {
2327 PrintString( text, true );
2328 }
2329}
const WCHAR * text
Definition: package.c:1799

Referenced by PushText(), and Visit().

◆ PushText() [3/6]

void tinyxml2::XMLPrinter::PushText ( double  value)

Add a text node from a double.

Definition at line 2363 of file tinyxml2.cpp.

2364{
2365 char buf[BUF_SIZE];
2367 PushText( buf, false );
2368}

◆ PushText() [4/6]

void tinyxml2::XMLPrinter::PushText ( float  value)

Add a text node from a float.

Definition at line 2355 of file tinyxml2.cpp.

2356{
2357 char buf[BUF_SIZE];
2359 PushText( buf, false );
2360}

◆ PushText() [5/6]

void tinyxml2::XMLPrinter::PushText ( int  value)

Add a text node from an integer.

Definition at line 2331 of file tinyxml2.cpp.

2332{
2333 char buf[BUF_SIZE];
2335 PushText( buf, false );
2336}

◆ PushText() [6/6]

void tinyxml2::XMLPrinter::PushText ( unsigned  value)

Add a text node from an unsigned.

Definition at line 2339 of file tinyxml2.cpp.

2340{
2341 char buf[BUF_SIZE];
2343 PushText( buf, false );
2344}

◆ PushUnknown()

void tinyxml2::XMLPrinter::PushUnknown ( const char value)

Definition at line 2395 of file tinyxml2.cpp.

2396{
2398 if ( _textDepth < 0 && !_firstElement && !_compactMode) {
2399 Print( "\n" );
2400 PrintSpace( _depth );
2401 }
2402 _firstElement = false;
2403 Print( "<!%s>", value );
2404}

Referenced by Visit().

◆ SealElementIfJustOpened()

void tinyxml2::XMLPrinter::SealElementIfJustOpened ( )
protected

Definition at line 2308 of file tinyxml2.cpp.

2309{
2310 if ( !_elementJustOpened ) {
2311 return;
2312 }
2313 _elementJustOpened = false;
2314 Print( ">" );
2315}

Referenced by OpenElement(), PushComment(), PushDeclaration(), PushText(), and PushUnknown().

◆ Visit() [1/4]

bool tinyxml2::XMLPrinter::Visit ( const XMLComment )
virtual

Visit a comment node.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2447 of file tinyxml2.cpp.

2448{
2449 PushComment( comment.Value() );
2450 return true;
2451}
void PushComment(const char *comment)
Add a comment.
Definition: tinyxml2.cpp:2371

◆ Visit() [2/4]

bool tinyxml2::XMLPrinter::Visit ( const XMLDeclaration )
virtual

Visit a declaration.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2453 of file tinyxml2.cpp.

2454{
2455 PushDeclaration( declaration.Value() );
2456 return true;
2457}

◆ Visit() [3/4]

bool tinyxml2::XMLPrinter::Visit ( const XMLText )
virtual

Visit a text node.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2440 of file tinyxml2.cpp.

2441{
2442 PushText( text.Value(), text.CData() );
2443 return true;
2444}

◆ Visit() [4/4]

bool tinyxml2::XMLPrinter::Visit ( const XMLUnknown )
virtual

Visit an unknown node.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2460 of file tinyxml2.cpp.

2461{
2462 PushUnknown( unknown.Value() );
2463 return true;
2464}
void PushUnknown(const char *value)
Definition: tinyxml2.cpp:2395
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605

◆ VisitEnter() [1/2]

bool tinyxml2::XMLPrinter::VisitEnter ( const XMLDocument )
virtual

Visit a document.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2407 of file tinyxml2.cpp.

2408{
2409 _processEntities = doc.ProcessEntities();
2410 if ( doc.HasBOM() ) {
2411 PushHeader( true, false );
2412 }
2413 return true;
2414}
void PushHeader(bool writeBOM, bool writeDeclaration)
Definition: tinyxml2.cpp:2210

◆ VisitEnter() [2/2]

bool tinyxml2::XMLPrinter::VisitEnter ( const XMLElement ,
const XMLAttribute  
)
virtual

Visit an element.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2417 of file tinyxml2.cpp.

2418{
2419 const XMLElement* parentElem = 0;
2420 if ( element.Parent() ) {
2421 parentElem = element.Parent()->ToElement();
2422 }
2423 const bool compactMode = parentElem ? CompactMode( *parentElem ) : _compactMode;
2424 OpenElement( element.Name(), compactMode );
2425 while ( attribute ) {
2426 PushAttribute( attribute->Name(), attribute->Value() );
2427 attribute = attribute->Next();
2428 }
2429 return true;
2430}
void OpenElement(const char *name, bool compactMode=false)
Definition: tinyxml2.cpp:2222
virtual bool CompactMode(const XMLElement &)
Definition: tinyxml2.h:2063

◆ VisitExit() [1/2]

virtual bool tinyxml2::XMLPrinter::VisitExit ( const XMLDocument )
inlinevirtual

Visit a document.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2026 of file tinyxml2.h.

2026 {
2027 return true;
2028 }

◆ VisitExit() [2/2]

bool tinyxml2::XMLPrinter::VisitExit ( const XMLElement )
virtual

Visit an element.

Reimplemented from tinyxml2::XMLVisitor.

Definition at line 2433 of file tinyxml2.cpp.

2434{
2436 return true;
2437}
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
Definition: tinyxml2.cpp:2282

Member Data Documentation

◆ _buffer

DynArray< char, 20 > tinyxml2::XMLPrinter::_buffer
private

Definition at line 2092 of file tinyxml2.h.

Referenced by Print(), and XMLPrinter().

◆ _compactMode

bool tinyxml2::XMLPrinter::_compactMode
private

Definition at line 2083 of file tinyxml2.h.

Referenced by PushComment(), PushDeclaration(), PushUnknown(), and VisitEnter().

◆ _depth

int tinyxml2::XMLPrinter::_depth
private

◆ _elementJustOpened

bool tinyxml2::XMLPrinter::_elementJustOpened
protected

Definition at line 2072 of file tinyxml2.h.

Referenced by CloseElement(), OpenElement(), PushAttribute(), and SealElementIfJustOpened().

◆ _entityFlag

bool tinyxml2::XMLPrinter::_entityFlag[ENTITY_RANGE]
private

Definition at line 2089 of file tinyxml2.h.

Referenced by PrintString(), and XMLPrinter().

◆ _firstElement

bool tinyxml2::XMLPrinter::_firstElement
private

Definition at line 2078 of file tinyxml2.h.

Referenced by OpenElement(), PushComment(), PushDeclaration(), and PushUnknown().

◆ _fp

FILE* tinyxml2::XMLPrinter::_fp
private

Definition at line 2079 of file tinyxml2.h.

Referenced by Print().

◆ _processEntities

bool tinyxml2::XMLPrinter::_processEntities
private

Definition at line 2082 of file tinyxml2.h.

Referenced by PrintString(), and VisitEnter().

◆ _restrictedEntityFlag

bool tinyxml2::XMLPrinter::_restrictedEntityFlag[ENTITY_RANGE]
private

Definition at line 2090 of file tinyxml2.h.

Referenced by PrintString(), and XMLPrinter().

◆ _stack

DynArray< const char*, 10 > tinyxml2::XMLPrinter::_stack
protected

Definition at line 2073 of file tinyxml2.h.

Referenced by CloseElement(), and OpenElement().

◆ _textDepth

int tinyxml2::XMLPrinter::_textDepth
private

The documentation for this class was generated from the following files: