Provide finer control over indentation inside the XMLPrinter. You'll have to subclass it to override its standard behaviour by overwriting CompactMode().
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12cac92..67716fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,8 +10,8 @@
################################
# set lib version here
-set(GENERIC_LIB_VERSION "1.0.14")
-set(GENERIC_LIB_SOVERSION "1")
+set(GENERIC_LIB_VERSION "1.1.0")
+set(GENERIC_LIB_SOVERSION "1")
################################
diff --git a/dox b/dox
index 10878f4..bfd90aa 100755
--- a/dox
+++ b/dox
@@ -32,7 +32,7 @@
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 1.0.14
+PROJECT_NUMBER = 1.1.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
diff --git a/setversion.py b/setversion.py
index a72ee03..b8c4472 100755
--- a/setversion.py
+++ b/setversion.py
@@ -33,8 +33,8 @@
minor = input( "Minor: " )
build = input( "Build: " )
-print "Setting dox,tinyxml2.h"
-print "Version: " + `major` + "." + `minor` + "." + `build`
+print ("Setting dox,tinyxml2.h")
+print ("Version: " + major + "." + minor + "." + build)
#### Write the tinyxml.h ####
@@ -45,16 +45,16 @@
matchBuild = "static const int TIXML2_PATCH_VERSION"
if line[0:len(matchMajor)] == matchMajor:
- print "1)tinyxml2.h Major found"
- return matchMajor + " = " + `major` + ";\n"
+ print( "1)tinyxml2.h Major found" )
+ return matchMajor + " = " + major + ";\n"
elif line[0:len(matchMinor)] == matchMinor:
- print "2)tinyxml2.h Minor found"
- return matchMinor + " = " + `minor` + ";\n"
+ print( "2)tinyxml2.h Minor found" )
+ return matchMinor + " = " + minor + ";\n"
elif line[0:len(matchBuild)] == matchBuild:
- print "3)tinyxml2.h Build found"
- return matchBuild + " = " + `build` + ";\n"
+ print( "3)tinyxml2.h Build found" )
+ return matchBuild + " = " + build + ";\n"
else:
return line;
@@ -69,8 +69,8 @@
match = "PROJECT_NUMBER"
if line[0:len( match )] == match:
- print "dox project found"
- return "PROJECT_NUMBER = " + `major` + "." + `minor` + "." + `build` + "\n"
+ print( "dox project found" )
+ return "PROJECT_NUMBER = " + major + "." + minor + "." + build + "\n"
else:
return line;
@@ -85,8 +85,8 @@
matchVersion = "set(GENERIC_LIB_VERSION"
if line[0:len(matchVersion)] == matchVersion:
- print "1)tinyxml2.h Major found"
- return matchVersion + " \"" + `major` + "." + `minor` + "." + `build` + "\")" + "\n"
+ print( "1)tinyxml2.h Major found" )
+ return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"
else:
return line;
@@ -98,8 +98,8 @@
matchSoversion = "set(GENERIC_LIB_SOVERSION"
if line[0:len(matchSoversion)] == matchSoversion:
- print "1)tinyxml2.h Major found"
- return matchSoversion + " \"" + `major` + "\")" + "\n"
+ print( "1)tinyxml2.h Major found" )
+ return matchSoversion + " \"" + major + "\")" + "\n"
else:
return line;
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index beaeeb8..2ecb50a 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -446,7 +446,6 @@
return false;
}
-
bool XMLUtil::ToUnsigned( const char* str, unsigned *value )
{
if ( TIXML_SSCANF( str, "%u", value ) == 1 ) {
@@ -581,8 +580,7 @@
_parent( 0 ),
_firstChild( 0 ), _lastChild( 0 ),
_prev( 0 ), _next( 0 ),
- _memPool( 0 ),
- _forceCompactMode( false )
+ _memPool( 0 )
{
}
@@ -1305,7 +1303,7 @@
}
-void XMLElement::SetText( double v )
+void XMLElement::SetText( double v )
{
char buf[BUF_SIZE];
XMLUtil::ToStr( v, buf, BUF_SIZE );
@@ -1313,42 +1311,6 @@
}
-void XMLElement::SetBoolFirstChild( bool inBool )
-{
- XMLElement * theBoolElem = FirstChild() ? FirstChild()->ToElement() : NULL;
- if( theBoolElem
- && (strcmp(theBoolElem->Value(),"true") == 0 || strcmp(theBoolElem->Value(),"false") == 0) ) {
- theBoolElem->SetValue( inBool ? "true" : "false" );
- }
- else if( !FirstChild() ) {
- theBoolElem = GetDocument()->NewElement( inBool ? "true" : "false" );
- InsertFirstChild( theBoolElem );
- }
-}
-
-
-XMLError XMLElement::QueryBoolFirstChild( bool *outBool )
-{
- if ( FirstChild() )
- {
- if ( FirstChild()->ToElement() )
- {
- bool isTrue = strcmp( FirstChild()->Value(), "true" ) == 0;
- bool isFalse = strcmp( FirstChild()->Value(), "false" ) == 0;
- if( !isTrue && !isFalse )
- return XML_CAN_NOT_CONVERT_TEXT;
-
- *outBool = isTrue;
- return XML_SUCCESS;
- }
- else
- return XML_NO_ELEMENT_NODE;
- }
- else
- return XML_NO_ELEMENT_NODE;
-}
-
-
XMLError XMLElement::QueryIntText( int* ival ) const
{
if ( FirstChild() && FirstChild()->ToText() ) {
@@ -1796,12 +1758,7 @@
const char* start = p;
Clear();
- if ( len == 0 ) {
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
- return _errorID;
- }
-
- if ( !p || !*p ) {
+ if ( len == 0 || !p || !*p ) {
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
return _errorID;
}
diff --git a/tinyxml2.h b/tinyxml2.h
index a584010..605a1ca 100755
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -116,9 +116,15 @@
#define TIXML_SSCANF sscanf
#endif
+/* Versioning, past 1.0.14:
+
+ A backwards-incompatible change or API change bumps the major version.
+ An API addition or a backwards-compatible change, bumps the minor version.
+ Simple bug fixes bump the build number.
+*/
static const int TIXML2_MAJOR_VERSION = 1;
-static const int TIXML2_MINOR_VERSION = 0;
-static const int TIXML2_PATCH_VERSION = 14;
+static const int TIXML2_MINOR_VERSION = 1;
+static const int TIXML2_PATCH_VERSION = 0;
namespace tinyxml2
{
@@ -821,7 +827,7 @@
// internal
virtual char* ParseDeep( char*, StrPair* );
-
+
protected:
XMLNode( XMLDocument* );
virtual ~XMLNode();
@@ -837,8 +843,6 @@
XMLNode* _prev;
XMLNode* _next;
-
- bool _forceCompactMode;
private:
MemPool* _memPool;
@@ -1016,8 +1020,7 @@
XML_ERROR_PARSING,
XML_CAN_NOT_CONVERT_TEXT,
- XML_NO_TEXT_NODE,
- XML_NO_ELEMENT_NODE
+ XML_NO_TEXT_NODE
};
@@ -1417,52 +1420,7 @@
void SetText( double value );
/// Convenience method for setting text inside and element. See SetText() for important limitations.
void SetText( float value );
-
- /// Convenience for QueryIntText when you don't care if the text won't convert.
- int IntText()
- {
- int i = 0;
- QueryIntText( &i );
- return i;
- }
- /// Convenience for QueryUnsignedText when you don't care if the text won't convert.
- unsigned UnsignedText()
- {
- unsigned i = 0;
- QueryUnsignedText( &i );
- return i;
- }
-
- /// Convenience for QueryDoubleText when you don't care if the text won't convert.
- double DoubleText()
- {
- double i = 0;
- QueryDoubleText( &i );
- return i;
- }
-
- /// Convenience for QueryFloatText when you don't care if the text won't convert.
- float FloatText()
- {
- float i = 0;
- QueryFloatText( &i );
- return i;
- }
-
- /// Adds a sub-element equivalent to the given boolean.
- void SetBoolFirstChild( bool inBool );
-
- /// Looks for a <true /> or <false /> as the first child and returns the corresponding bool.
- bool BoolFirstChild()
- {
- bool b = false;
- QueryBoolFirstChild(&b);
- return b;
- }
-
- XMLError QueryBoolFirstChild( bool *outBool );
-
/**
Convenience method to query the value of a child text node. This is probably best
shown by example. Given you have a document is this form:
@@ -1511,7 +1469,7 @@
char* ParseDeep( char* p, StrPair* endTag );
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
virtual bool ShallowEqual( const XMLNode* compare ) const;
-
+
private:
XMLElement( XMLDocument* doc );
virtual ~XMLElement();
@@ -2078,21 +2036,25 @@
protected:
virtual bool CompactMode( const XMLElement& elem ) { return _compactMode; };
- void SealElement();
+ /** Prints out the space before an element. You may override to change
+ the space and tabs used. A PrintSpace() override should call Print().
+ */
+ virtual void PrintSpace( int depth );
+ void Print( const char* format, ... );
+
+ void SealElement();
bool _elementJustOpened;
DynArray< const char*, 10 > _stack;
private:
- void PrintSpace( int depth );
void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
- void Print( const char* format, ... );
bool _firstElement;
FILE* _fp;
int _depth;
int _textDepth;
bool _processEntities;
- bool _compactMode;
+ bool _compactMode;
enum {
ENTITY_RANGE = 64,
diff --git a/xmltest.cpp b/xmltest.cpp
index 7c24090..6fdc162 100644
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -1012,47 +1012,6 @@
ele->DeleteAttribute( "attrib3" );
XMLTest( "Attribute order (empty)", false, ele->FirstAttribute() ? true : false );
}
-
- {
- XMLDocument doc0;
- XMLElement* root = doc0.NewElement("root");
- doc0.InsertEndChild(root);
- XMLElement* text = doc0.NewElement("text");
- text->SetForceCompactMode(true);
- root->InsertEndChild(text);
- XMLText* befText = doc0.NewText("Before ");
- text->InsertEndChild(befText);
- XMLElement* tag = doc0.NewElement("tag");
- text->InsertEndChild(tag);
- XMLText* tagText = doc0.NewText("Tag");
- tag->InsertEndChild(tagText);
- tag = doc0.NewElement("tagtwo");
- tag->SetAttribute("two", "2");
- text->InsertEndChild(tag);
- tagText = doc0.NewText("TagTwo");
- tag->InsertEndChild(tagText);
- XMLText* aftText = doc0.NewText(" After");
- text->InsertEndChild(aftText);
-
- XMLPrinter printer;
- doc0.Print( &printer );
- XMLTest( "Selective text wrapping", "<root>\n <text>Before <tag>Tag</tag><tagtwo two=\"2\">TagTwo</tagtwo> After</text>\n</root>\n", printer.CStr() );
- }
-
- {
- XMLDocument doc0;
- XMLElement* root = doc0.NewElement("root");
- doc0.InsertEndChild(root);
- XMLElement* cool = doc0.NewElement("cool");
- cool->SetForceCompactMode(true);
- root->InsertEndChild(cool);
- XMLElement* tag = doc0.NewElement("true");
- cool->InsertEndChild(tag);
-
- XMLPrinter printer;
- doc0.Print( &printer );
- XMLTest( "Selective text around single tag", "<root>\n <cool><true/></cool>\n</root>\n", printer.CStr() );
- }
{
// Make sure an attribute with a space in it succeeds.