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.
diff --git a/tinyxml2.h b/tinyxml2.h
index df9e049..e2e3e11 100644
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -1329,7 +1329,7 @@
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 @@
*/
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 @@
int depth;
int textDepth;
bool processEntities;
+ bool compactMode;
enum {
ENTITY_RANGE = 64,