diff --git a/dox b/dox index 3bcbb76..8e4d547 100755 --- a/dox +++ b/dox @@ -32,7 +32,7 @@ PROJECT_NAME = "TinyXML-2" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.0.0 +PROJECT_NUMBER = 1.0.1 # 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/tinyxml2.cpp b/tinyxml2.cpp index 67bf205..297c966 100644 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1351,7 +1351,7 @@ XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) { XMLDeclaration* dec = new (commentPool.Alloc()) XMLDeclaration( this ); dec->memPool = &commentPool; - dec->SetValue( str ); + dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); return dec; } diff --git a/tinyxml2.h b/tinyxml2.h index e68d1d5..0cd4d58 100644 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -85,7 +85,7 @@ distribution. static const int TIXML2_MAJOR_VERSION = 1; static const int TIXML2_MINOR_VERSION = 0; -static const int TIXML2_PATCH_VERSION = 0; +static const int TIXML2_PATCH_VERSION = 1; namespace tinyxml2 { @@ -1038,6 +1038,9 @@ public: Returns true if this document has a leading Byte Order Mark of UTF8. */ bool HasBOM() const { return writeBOM; } + /** Sets whether to write the BOM when writing the file. + */ + void SetBOM( bool useBOM ) { writeBOM = useBOM; } /** Return the root element of DOM. Equivalent to FirstChildElement(). To get the first node, use FirstChild(). @@ -1084,8 +1087,14 @@ public: Create a new Declaration associated with this Document. The memory for the object is managed by the Document. + + If the 'text' param is null, the standard + declaration is used.: + @verbatim + + @endverbatim */ - XMLDeclaration* NewDeclaration( const char* text ); + XMLDeclaration* NewDeclaration( const char* text=0 ); /** Create a new Unknown associated with this Document. The memory for the object diff --git a/xmltest.cpp b/xmltest.cpp index a88d1bc..a87b75e 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -813,6 +813,18 @@ int main( int /*argc*/, const char ** /*argv*/ ) ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement(); XMLTest( "Handle, dne, const", false, ele != 0 ); } + { + // Default Declaration & BOM + XMLDocument doc; + doc.InsertEndChild( doc.NewDeclaration() ); + doc.SetBOM( true ); + + XMLPrinter printer; + doc.Print( &printer ); + + static const char* result = "\xef\xbb\xbf"; + XMLTest( "BOM and default declaration", printer.CStr(), result, false ); + } // ----------- Performance tracking --------------