Added depth as constructor argument to XMLPrinter. This way, XML files that are not written with XMLDocument can be properly indented.
Removed unused forward declaration
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 6567520..5611614 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -1729,11 +1729,11 @@
}
-XMLPrinter::XMLPrinter( FILE* file, bool compact ) :
+XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
_elementJustOpened( false ),
_firstElement( true ),
_fp( file ),
- _depth( 0 ),
+ _depth( depth ),
_textDepth( -1 ),
_processEntities( true ),
_compactMode( compact )
@@ -1840,7 +1840,7 @@
void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
{
if ( writeBOM ) {
- static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 };
+ static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 };
Print( "%s", bom );
}
if ( writeDec ) {
@@ -1858,6 +1858,8 @@
if ( _textDepth < 0 && !_firstElement && !_compactMode ) {
Print( "\n" );
+ }
+ if ( !_compactMode ) {
PrintSpace( _depth );
}