mirror of
https://github.com/AxioDL/tinyxml2.git
synced 2025-05-15 03:41:30 +00:00
Keep indentation control fully inside the XMLPrinter. You'll have to subclass it to override its standard behaviour by overwriting CompactMode().
This commit is contained in:
parent
07ac762b80
commit
5d1d27e88b
@ -1323,7 +1323,6 @@ void XMLElement::SetBoolFirstChild( bool inBool )
|
|||||||
else if( !FirstChild() ) {
|
else if( !FirstChild() ) {
|
||||||
theBoolElem = GetDocument()->NewElement( inBool ? "true" : "false" );
|
theBoolElem = GetDocument()->NewElement( inBool ? "true" : "false" );
|
||||||
InsertFirstChild( theBoolElem );
|
InsertFirstChild( theBoolElem );
|
||||||
SetForceCompactMode(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2190,7 +2189,9 @@ bool XMLPrinter::VisitEnter( const XMLDocument& doc )
|
|||||||
|
|
||||||
bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
|
bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
|
||||||
{
|
{
|
||||||
OpenElement( element.Name(), _compactMode ? true : element.Parent()->GetForceCompactMode() );
|
const XMLElement* parentElem = element.Parent()->ToElement();
|
||||||
|
bool compactMode = parentElem ? CompactMode(*parentElem) : _compactMode;
|
||||||
|
OpenElement( element.Name(), compactMode );
|
||||||
while ( attribute ) {
|
while ( attribute ) {
|
||||||
PushAttribute( attribute->Name(), attribute->Value() );
|
PushAttribute( attribute->Name(), attribute->Value() );
|
||||||
attribute = attribute->Next();
|
attribute = attribute->Next();
|
||||||
@ -2201,7 +2202,7 @@ bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attr
|
|||||||
|
|
||||||
bool XMLPrinter::VisitExit( const XMLElement& element )
|
bool XMLPrinter::VisitExit( const XMLElement& element )
|
||||||
{
|
{
|
||||||
CloseElement( _compactMode ? true : element.GetForceCompactMode() );
|
CloseElement( CompactMode(element) );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,9 +822,6 @@ public:
|
|||||||
// internal
|
// internal
|
||||||
virtual char* ParseDeep( char*, StrPair* );
|
virtual char* ParseDeep( char*, StrPair* );
|
||||||
|
|
||||||
bool GetForceCompactMode() const { if( _forceCompactMode || !Parent() ) return _forceCompactMode; return Parent()->GetForceCompactMode(); };
|
|
||||||
void SetForceCompactMode( bool b ) { _forceCompactMode = b; };
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XMLNode( XMLDocument* );
|
XMLNode( XMLDocument* );
|
||||||
virtual ~XMLNode();
|
virtual ~XMLNode();
|
||||||
@ -2079,6 +2076,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual bool CompactMode( const XMLElement& elem ) { return _compactMode; };
|
||||||
|
|
||||||
void SealElement();
|
void SealElement();
|
||||||
bool _elementJustOpened;
|
bool _elementJustOpened;
|
||||||
DynArray< const char*, 10 > _stack;
|
DynArray< const char*, 10 > _stack;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user