Add compact mode to XMLPrinter, for printing without '\n' and space.
let output file smaller. usage: //------------------------------------------------ XMLPrinter printer; printer->SetCompactMode( true ); //enable compact mode doc->Print( &printer ); SomeFunction( printer.CStr() ); //------------------------------------------------ or //------------------------------------------------ //enable at construction XMLPrinter printer( file, true ); // to file //XMLPrinter printer( NULL, true ); // to men doc->Print( &printer ); SomeFunction( printer.CStr() ); //------------------------------------------------ The '\n' and space in Text or Attribute will be kept.
This commit is contained in:
11
tinyxml2.h
11
tinyxml2.h
@@ -1329,7 +1329,7 @@ public:
|
||||
this will print to the FILE. Else it will print
|
||||
to memory, and the result is available in CStr()
|
||||
*/
|
||||
XMLPrinter( FILE* file=0 );
|
||||
XMLPrinter( FILE* file=0, bool compact = false );
|
||||
~XMLPrinter() {}
|
||||
|
||||
/** If streaming, write the BOM and declaration. */
|
||||
@@ -1378,6 +1378,14 @@ public:
|
||||
*/
|
||||
const int CStrSize()const{ return buffer.Size(); }
|
||||
|
||||
/**
|
||||
Set printer to compact mode, for printing without '\n' and space,
|
||||
let output file smaller.
|
||||
*/
|
||||
void SetCompactMode( bool on ){ compactMode = on; }
|
||||
bool IsCompactMode()const{ return compactMode; };
|
||||
|
||||
|
||||
private:
|
||||
void SealElement();
|
||||
void PrintSpace( int depth );
|
||||
@@ -1390,6 +1398,7 @@ private:
|
||||
int depth;
|
||||
int textDepth;
|
||||
bool processEntities;
|
||||
bool compactMode;
|
||||
|
||||
enum {
|
||||
ENTITY_RANGE = 64,
|
||||
|
||||
Reference in New Issue
Block a user