Added SetForceCompactMode() for overriding the compact setting on a per-node level. All sub-nodes will be printed compact as well.

This commit is contained in:
Uli Kusterer
2014-02-01 12:48:51 +01:00
parent 5bb2d8079b
commit d5c9e8b81d
3 changed files with 34 additions and 7 deletions

View File

@@ -580,7 +580,8 @@ XMLNode::XMLNode( XMLDocument* doc ) :
_parent( 0 ),
_firstChild( 0 ), _lastChild( 0 ),
_prev( 0 ), _next( 0 ),
_memPool( 0 )
_memPool( 0 ),
_forceCompactMode( false )
{
}
@@ -1945,17 +1946,17 @@ void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
}
void XMLPrinter::OpenElement( const char* name )
void XMLPrinter::OpenElement( const char* name, bool compactMode )
{
if ( _elementJustOpened ) {
SealElement();
}
_stack.Push( name );
if ( _textDepth < 0 && !_firstElement && !_compactMode ) {
if ( _textDepth < 0 && !_firstElement && !compactMode ) {
Print( "\n" );
}
if ( !_compactMode ) {
if ( !compactMode ) {
PrintSpace( _depth );
}
@@ -2151,7 +2152,7 @@ bool XMLPrinter::VisitEnter( const XMLDocument& doc )
bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
{
OpenElement( element.Name() );
OpenElement( element.Name(), _compactMode ? true : element.Parent()->GetForceCompactMode() );
while ( attribute ) {
PushAttribute( attribute->Name(), attribute->Value() );
attribute = attribute->Next();