antioch-0.4.0
|
#include <tinyxml2.h>
Public Member Functions | |
XMLPrinter (FILE *file=0, bool compact=false) | |
~XMLPrinter () | |
void | PushHeader (bool writeBOM, bool writeDeclaration) |
void | OpenElement (const char *name) |
void | PushAttribute (const char *name, const char *value) |
If streaming, add an attribute to an open element. More... | |
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) |
void | CloseElement () |
If streaming, close the Element. More... | |
void | PushText (const char *text, bool cdata=false) |
Add a text node. More... | |
void | PushText (int value) |
Add a text node from an integer. More... | |
void | PushText (unsigned value) |
Add a text node from an unsigned. More... | |
void | PushText (bool value) |
Add a text node from a bool. More... | |
void | PushText (float value) |
Add a text node from a float. More... | |
void | PushText (double value) |
Add a text node from a double. More... | |
void | PushComment (const char *comment) |
Add a comment. More... | |
void | PushDeclaration (const char *value) |
void | PushUnknown (const char *value) |
virtual bool | VisitEnter (const XMLDocument &) |
Visit a document. More... | |
virtual bool | VisitExit (const XMLDocument &) |
Visit a document. More... | |
virtual bool | VisitEnter (const XMLElement &element, const XMLAttribute *attribute) |
Visit an element. More... | |
virtual bool | VisitExit (const XMLElement &element) |
Visit an element. More... | |
virtual bool | Visit (const XMLText &text) |
Visit a text node. More... | |
virtual bool | Visit (const XMLComment &comment) |
Visit a comment node. More... | |
virtual bool | Visit (const XMLDeclaration &declaration) |
Visit a declaration. More... | |
virtual bool | Visit (const XMLUnknown &unknown) |
Visit an unknown node. More... | |
const char * | CStr () const |
int | CStrSize () const |
Private Types | |
enum | { ENTITY_RANGE = 64, BUF_SIZE = 200 } |
Private Member Functions | |
void | SealElement () |
void | PrintSpace (int depth) |
void | PrintString (const char *, bool restrictedEntitySet) |
void | Print (const char *format,...) |
Private Attributes | |
bool | elementJustOpened |
bool | firstElement |
FILE * | fp |
int | depth |
int | textDepth |
bool | processEntities |
bool | compactMode |
bool | entityFlag [ENTITY_RANGE] |
bool | restrictedEntityFlag [ENTITY_RANGE] |
DynArray< const char *, 10 > | stack |
DynArray< char, 20 > | buffer |
Printing functionality. The XMLPrinter gives you more options than the XMLDocument::Print() method.
It can:
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 1407 of file tinyxml2.h.
|
private |
Enumerator | |
---|---|
ENTITY_RANGE | |
BUF_SIZE |
Definition at line 1490 of file tinyxml2.h.
|
inline |
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 1801 of file tinyxml2_imp.h.
References buffer, ENTITY_RANGE, entityFlag, std::int, tinyxml2::DynArray< T, INIT >::Push(), restrictedEntityFlag, and TIXMLASSERT.
|
inline |
Definition at line 1417 of file tinyxml2.h.
|
inline |
If streaming, close the Element.
Definition at line 1992 of file tinyxml2_imp.h.
References compactMode, depth, elementJustOpened, tinyxml2::DynArray< T, INIT >::Pop(), Print(), PrintSpace(), stack, and textDepth.
Referenced by VisitExit().
|
inline |
If in print to memory mode, return a pointer to the XML file in memory.
Definition at line 1468 of file tinyxml2.h.
References buffer, and tinyxml2::DynArray< T, INIT >::Mem().
|
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 1474 of file tinyxml2.h.
References buffer, and tinyxml2::DynArray< T, INIT >::Size().
|
inline |
If streaming, start writing an element. The element must be closed with CloseElement()
Definition at line 1926 of file tinyxml2_imp.h.
References compactMode, depth, elementJustOpened, firstElement, Print(), PrintSpace(), tinyxml2::DynArray< T, INIT >::Push(), SealElement(), stack, and textDepth.
Referenced by VisitEnter().
|
inlineprivate |
Definition at line 1828 of file tinyxml2_imp.h.
References buffer, and tinyxml2::DynArray< T, INIT >::PushArr().
Referenced by CloseElement(), OpenElement(), PrintSpace(), PrintString(), PushAttribute(), PushComment(), PushDeclaration(), PushHeader(), PushText(), PushUnknown(), and SealElement().
|
inlineprivate |
Definition at line 1865 of file tinyxml2_imp.h.
References depth, and Print().
Referenced by CloseElement(), OpenElement(), PushComment(), PushDeclaration(), and PushUnknown().
|
inlineprivate |
Definition at line 1874 of file tinyxml2_imp.h.
References ENTITY_RANGE, entityFlag, Print(), processEntities, and restrictedEntityFlag.
Referenced by PushAttribute(), and PushText().
|
inline |
If streaming, add an attribute to an open element.
Definition at line 1946 of file tinyxml2_imp.h.
References elementJustOpened, Print(), PrintString(), and TIXMLASSERT.
Referenced by PushAttribute(), and VisitEnter().
|
inline |
Definition at line 1956 of file tinyxml2_imp.h.
References BUF_SIZE, PushAttribute(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Definition at line 1965 of file tinyxml2_imp.h.
References BUF_SIZE, PushAttribute(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Definition at line 1974 of file tinyxml2_imp.h.
References BUF_SIZE, PushAttribute(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Definition at line 1983 of file tinyxml2_imp.h.
References BUF_SIZE, PushAttribute(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Add a comment.
Definition at line 2089 of file tinyxml2_imp.h.
References compactMode, depth, elementJustOpened, firstElement, Print(), PrintSpace(), SealElement(), and textDepth.
Referenced by Visit().
|
inline |
Definition at line 2104 of file tinyxml2_imp.h.
References compactMode, depth, elementJustOpened, firstElement, Print(), PrintSpace(), SealElement(), and textDepth.
Referenced by PushHeader(), and Visit().
|
inline |
If streaming, write the BOM and declaration.
Definition at line 1913 of file tinyxml2_imp.h.
References Print(), and PushDeclaration().
Referenced by VisitEnter().
|
inline |
Add a text node.
Definition at line 2025 of file tinyxml2_imp.h.
References depth, elementJustOpened, Print(), PrintString(), SealElement(), and textDepth.
Referenced by PushText(), and Visit().
|
inline |
Add a text node from an integer.
Definition at line 2044 of file tinyxml2_imp.h.
References BUF_SIZE, PushText(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Add a text node from an unsigned.
Definition at line 2053 of file tinyxml2_imp.h.
References BUF_SIZE, PushText(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Add a text node from a bool.
Definition at line 2062 of file tinyxml2_imp.h.
References BUF_SIZE, PushText(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Add a text node from a float.
Definition at line 2071 of file tinyxml2_imp.h.
References BUF_SIZE, PushText(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Add a text node from a double.
Definition at line 2080 of file tinyxml2_imp.h.
References BUF_SIZE, PushText(), and tinyxml2::XMLUtil::ToStr().
|
inline |
Definition at line 2119 of file tinyxml2_imp.h.
References compactMode, depth, elementJustOpened, firstElement, Print(), PrintSpace(), SealElement(), and textDepth.
Referenced by Visit().
|
inlineprivate |
Definition at line 2017 of file tinyxml2_imp.h.
References elementJustOpened, and Print().
Referenced by OpenElement(), PushComment(), PushDeclaration(), PushText(), and PushUnknown().
|
inlinevirtual |
Visit a text node.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 2165 of file tinyxml2_imp.h.
References tinyxml2::XMLText::CData(), PushText(), and tinyxml2::XMLNode::Value().
|
inlinevirtual |
Visit a comment node.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 2173 of file tinyxml2_imp.h.
References PushComment(), and tinyxml2::XMLNode::Value().
|
inlinevirtual |
Visit a declaration.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 2180 of file tinyxml2_imp.h.
References PushDeclaration(), and tinyxml2::XMLNode::Value().
|
inlinevirtual |
Visit an unknown node.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 2188 of file tinyxml2_imp.h.
References PushUnknown(), and tinyxml2::XMLNode::Value().
|
inlinevirtual |
Visit a document.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 2134 of file tinyxml2_imp.h.
References tinyxml2::XMLDocument::HasBOM(), tinyxml2::XMLDocument::ProcessEntities(), processEntities, and PushHeader().
|
inlinevirtual |
Visit an element.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 2145 of file tinyxml2_imp.h.
References tinyxml2::XMLAttribute::Name(), tinyxml2::XMLElement::Name(), tinyxml2::XMLAttribute::Next(), OpenElement(), PushAttribute(), and tinyxml2::XMLAttribute::Value().
|
inlinevirtual |
Visit a document.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 1454 of file tinyxml2.h.
|
inlinevirtual |
Visit an element.
Reimplemented from tinyxml2::XMLVisitor.
Definition at line 2157 of file tinyxml2_imp.h.
References CloseElement().
|
private |
Definition at line 1498 of file tinyxml2.h.
Referenced by CStr(), CStrSize(), Print(), and XMLPrinter().
|
private |
Definition at line 1488 of file tinyxml2.h.
Referenced by CloseElement(), OpenElement(), PushComment(), PushDeclaration(), and PushUnknown().
|
private |
Definition at line 1485 of file tinyxml2.h.
Referenced by CloseElement(), OpenElement(), PrintSpace(), PushComment(), PushDeclaration(), PushText(), and PushUnknown().
|
private |
Definition at line 1482 of file tinyxml2.h.
Referenced by CloseElement(), OpenElement(), PushAttribute(), PushComment(), PushDeclaration(), PushText(), PushUnknown(), and SealElement().
|
private |
Definition at line 1494 of file tinyxml2.h.
Referenced by PrintString(), and XMLPrinter().
|
private |
Definition at line 1483 of file tinyxml2.h.
Referenced by OpenElement(), PushComment(), PushDeclaration(), and PushUnknown().
|
private |
Definition at line 1484 of file tinyxml2.h.
|
private |
Definition at line 1487 of file tinyxml2.h.
Referenced by PrintString(), and VisitEnter().
|
private |
Definition at line 1495 of file tinyxml2.h.
Referenced by PrintString(), and XMLPrinter().
|
private |
Definition at line 1497 of file tinyxml2.h.
Referenced by CloseElement(), and OpenElement().
|
private |
Definition at line 1486 of file tinyxml2.h.
Referenced by CloseElement(), OpenElement(), PushComment(), PushDeclaration(), PushText(), and PushUnknown().