From 9a975b7bdbfa085098de5a0a4004874e93d4b098 Mon Sep 17 00:00:00 2001 From: Vasily Biryukov Date: Sat, 11 May 2013 21:41:42 +0600 Subject: [PATCH 01/10] Small fixes in documentation --- readme.md | 6 +++--- tinyxml2.h | 54 +++++++++++++++++++++++++++--------------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/readme.md b/readme.md index 007e79e..51d23e4 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ TinyXML-2 ========= -TinyXML is a simple, small, efficient, C++ XML parser that can be +TinyXML-2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs. The master is hosted on github: @@ -15,7 +15,7 @@ Examples are in the "related pages" tab of the HTML docs. What it does. ------------- -In brief, TinyXML parses an XML document, and builds from that a +In brief, TinyXML-2 parses an XML document, and builds from that a Document Object Model (DOM) that can be read, modified, and saved. XML stands for "eXtensible Markup Language." It is a general purpose @@ -197,7 +197,7 @@ Or the XMLPrinter class: Printing to memory is supported by the XMLPrinter. XMLPrinter printer; - doc->Print( &printer ); + doc.Print( &printer ); // printer.CStr() has a const char* to the XML #### Print without an XMLDocument diff --git a/tinyxml2.h b/tinyxml2.h index 9c7e6e9..2c11d13 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -402,7 +402,7 @@ private: All flavors of Visit methods have a default implementation that returns 'true' (continue visiting). You need to only override methods that are interesting to you. - Generally Accept() is called on the TiXmlDocument, although all nodes support visiting. + Generally Accept() is called on the XMLDocument, although all nodes support visiting. You should never change the document from a callback. @@ -759,12 +759,12 @@ public: */ virtual bool ShallowEqual( const XMLNode* compare ) const = 0; - /** Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the + /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the XML tree will be conditionally visited and the host will be called back - via the TiXmlVisitor interface. + via the XMLVisitor interface. - This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML is unchanged by using this + This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this interface versus any other.) The interface has been based on ideas from: @@ -776,7 +776,7 @@ public: An example of using Accept(): @verbatim - TiXmlPrinter printer; + XMLPrinter printer; tinyxmlDoc.Accept( &printer ); const char* xmlcstr = printer.CStr(); @endverbatim @@ -818,7 +818,7 @@ private: A text node can have 2 ways to output the next. "normal" output and CDATA. It will default to the mode it was parsed from the XML file and you generally want to leave it alone, but you can change the output mode with - SetCDATA() and query it with CDATA(). + SetCData() and query it with CData(). */ class XMLText : public XMLNode { @@ -891,7 +891,7 @@ private: @endverbatim - TinyXML2 will happily read or write files without a declaration, + TinyXML-2 will happily read or write files without a declaration, however. The text of the declaration isn't interpreted. It is parsed @@ -922,12 +922,12 @@ protected: }; -/** Any tag that tinyXml doesn't recognize is saved as an +/** Any tag that TinyXML-2 doesn't recognize is saved as an unknown. It is a tag of text, but should not be modified. It will be written back to the XML, unchanged, when the file is saved. - DTD tags get thrown into TiXmlUnknowns. + DTD tags get thrown into XMLUnknowns. */ class XMLUnknown : public XMLNode { @@ -1005,52 +1005,52 @@ public: return _next; } - /** IntAttribute interprets the attribute as an integer, and returns the value. + /** IntValue interprets the attribute as an integer, and returns the value. If the value isn't an integer, 0 will be returned. There is no error checking; - use QueryIntAttribute() if you need error checking. + use QueryIntValue() if you need error checking. */ int IntValue() const { int i=0; QueryIntValue( &i ); return i; } - /// Query as an unsigned integer. See IntAttribute() + /// Query as an unsigned integer. See IntValue() unsigned UnsignedValue() const { unsigned i=0; QueryUnsignedValue( &i ); return i; } - /// Query as a boolean. See IntAttribute() + /// Query as a boolean. See IntValue() bool BoolValue() const { bool b=false; QueryBoolValue( &b ); return b; } - /// Query as a double. See IntAttribute() + /// Query as a double. See IntValue() double DoubleValue() const { double d=0; QueryDoubleValue( &d ); return d; } - /// Query as a float. See IntAttribute() + /// Query as a float. See IntValue() float FloatValue() const { float f=0; QueryFloatValue( &f ); return f; } - /** QueryIntAttribute interprets the attribute as an integer, and returns the value + /** QueryIntValue interprets the attribute as an integer, and returns the value in the provided parameter. The function will return XML_NO_ERROR on success, and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. */ XMLError QueryIntValue( int* value ) const; - /// See QueryIntAttribute + /// See QueryIntValue XMLError QueryUnsignedValue( unsigned int* value ) const; - /// See QueryIntAttribute + /// See QueryIntValue XMLError QueryBoolValue( bool* value ) const; - /// See QueryIntAttribute + /// See QueryIntValue XMLError QueryDoubleValue( double* value ) const; - /// See QueryIntAttribute + /// See QueryIntValue XMLError QueryFloatValue( float* value ) const; /// Set the attribute to a string value. @@ -1301,10 +1301,10 @@ public: const XMLAttribute* FindAttribute( const char* name ) const; /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the TiXmlText child + and concise, GetText() is limited compared to getting the XMLText child and accessing it directly. - If the first child of 'this' is a TiXmlText, the GetText() + If the first child of 'this' is a XMLText, the GetText() returns the character string of the Text node, else null is returned. This is a convenient method for getting the text of simple contained text: @@ -1431,7 +1431,7 @@ public: You may optionally pass in the 'nBytes', which is the number of bytes which will be parsed. If not - specified, TinyXML will assume 'xml' points to a + specified, TinyXML-2 will assume 'xml' points to a null terminated string. */ XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); @@ -1507,7 +1507,7 @@ public: Or you can use a printer to print to memory: @verbatim XMLPrinter printer; - doc->Print( &printer ); + doc.Print( &printer ); // printer.CStr() has a const char* to the XML @endverbatim */ @@ -1614,7 +1614,7 @@ private: /** A XMLHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that XMLHandle is not part of the TinyXML + an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2 DOM structure. It is a separate utility class. Take an example: @@ -1829,7 +1829,7 @@ private: @verbatim XMLPrinter printer; - doc->Print( &printer ); + doc.Print( &printer ); SomeFunction( printer.CStr() ); @endverbatim From 632c57217ce896167762f2745c8dfc049eb278da Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 6 Jul 2013 11:28:16 +0200 Subject: [PATCH 02/10] Improved VS solution: Added x64 configuration, enabled optimizations --- tinyxml2/tinyxml2.sln | 8 +++- tinyxml2/tinyxml2.vcxproj | 79 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 3 deletions(-) diff --git a/tinyxml2/tinyxml2.sln b/tinyxml2/tinyxml2.sln index 24d5ce6..d4f8f8a 100755 --- a/tinyxml2/tinyxml2.sln +++ b/tinyxml2/tinyxml2.sln @@ -1,18 +1,24 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 +# Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml2", "tinyxml2.vcxproj", "{D1C528B6-AA02-4D29-9D61-DC08E317A70D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|Win32.ActiveCfg = Debug|Win32 {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|Win32.Build.0 = Debug|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|x64.ActiveCfg = Debug|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|x64.Build.0 = Debug|x64 {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|Win32.ActiveCfg = Release|Win32 {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|Win32.Build.0 = Release|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|x64.ActiveCfg = Release|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tinyxml2/tinyxml2.vcxproj b/tinyxml2/tinyxml2.vcxproj index d13b5c6..b338bd1 100755 --- a/tinyxml2/tinyxml2.vcxproj +++ b/tinyxml2/tinyxml2.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D} @@ -21,33 +29,69 @@ true Unicode + + Application + true + Unicode + Application false true Unicode + + Application + false + true + Unicode + + + + + + + true + + true + false + + false + - Level3 + Level4 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Level4 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) @@ -58,19 +102,50 @@ - Level3 + Level4 MaxSpeed true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + AnySuitable + Speed + true + true + true + false Console true true true + true + + + + + Level4 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + AnySuitable + Speed + true + true + true + false + + + Console + true + true + true + true From 1c5f99e37c0e7132fae4d167dcd7c746ad6ed36b Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 6 Jul 2013 11:28:39 +0200 Subject: [PATCH 03/10] Fixed two cppcheck messages --- tinyxml2.cpp | 4 ++-- tinyxml2.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index ad00867..6567520 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1691,7 +1691,7 @@ XMLError XMLDocument::Parse( const char* p, size_t len ) } -void XMLDocument::Print( XMLPrinter* streamer ) +void XMLDocument::Print( XMLPrinter* streamer ) const { XMLPrinter stdStreamer( stdout ); if ( !streamer ) { @@ -1839,8 +1839,8 @@ void XMLPrinter::PrintString( const char* p, bool restricted ) void XMLPrinter::PushHeader( bool writeBOM, bool writeDec ) { - static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 }; if ( writeBOM ) { + static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 }; Print( "%s", bom ); } if ( writeDec ) { diff --git a/tinyxml2.h b/tinyxml2.h index 2c11d13..07ddc2b 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -1511,7 +1511,7 @@ public: // printer.CStr() has a const char* to the XML @endverbatim */ - void Print( XMLPrinter* streamer=0 ); + void Print( XMLPrinter* streamer=0 ) const; virtual bool Accept( XMLVisitor* visitor ) const; /** From 16ed47dc14a39b505c4dc8721791086b21bca783 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 6 Jul 2013 12:02:43 +0200 Subject: [PATCH 04/10] Added support for building TinyXML as a .lib or .dll --- tinyxml2.h | 45 +++-- tinyxml2/test.vcxproj | 300 ++++++++++++++++++++++++++++ tinyxml2/test.vcxproj.filters | 6 + tinyxml2/tinyxml2.sln | 54 +++-- tinyxml2/tinyxml2.vcxproj | 318 ++++++++++++++++++++++++------ tinyxml2/tinyxml2.vcxproj.filters | 2 - 6 files changed, 639 insertions(+), 86 deletions(-) create mode 100644 tinyxml2/test.vcxproj create mode 100644 tinyxml2/test.vcxproj.filters diff --git a/tinyxml2.h b/tinyxml2.h index 07ddc2b..aa86d0d 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -58,6 +58,19 @@ distribution. #endif +#ifdef _WIN32 +# ifdef TINYXML2_EXPORT +# define TINYXML2_LIB __declspec(dllexport) +# elif defined(TINYXML2_IMPORT) +# define TINYXML2_LIB __declspec(dllimport) +# else +# define TINYXML2_LIB +# endif +#else +# define TINYXML2_LIB +#endif + + #if defined(DEBUG) # if defined(_MSC_VER) # define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak() @@ -121,7 +134,7 @@ class XMLPrinter; and entity translation if actually read. Can also store (and memory manage) a traditional char[] */ -class StrPair +class TINYXML2_LIB StrPair { public: enum { @@ -185,7 +198,7 @@ private: cause a call to new/delete */ template -class DynArray +class TINYXML2_LIB DynArray { public: DynArray< T, INIT >() { @@ -276,7 +289,7 @@ private: Parent virtual class of a pool for fast allocation and deallocation of objects. */ -class MemPool +class TINYXML2_LIB MemPool { public: MemPool() {} @@ -293,7 +306,7 @@ public: Template child class to create pools of the correct type. */ template< int SIZE > -class MemPoolT : public MemPool +class TINYXML2_LIB MemPoolT : public MemPool { public: MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} @@ -408,7 +421,7 @@ private: @sa XMLNode::Accept() */ -class XMLVisitor +class TINYXML2_LIB XMLVisitor { public: virtual ~XMLVisitor() {} @@ -554,7 +567,7 @@ public: @endverbatim */ -class XMLNode +class TINYXML2_LIB XMLNode { friend class XMLDocument; friend class XMLElement; @@ -820,7 +833,7 @@ private: you generally want to leave it alone, but you can change the output mode with SetCData() and query it with CData(). */ -class XMLText : public XMLNode +class TINYXML2_LIB XMLText : public XMLNode { friend class XMLBase; friend class XMLDocument; @@ -859,7 +872,7 @@ private: /** An XML Comment. */ -class XMLComment : public XMLNode +class TINYXML2_LIB XMLComment : public XMLNode { friend class XMLDocument; public: @@ -897,7 +910,7 @@ private: The text of the declaration isn't interpreted. It is parsed and written as a string. */ -class XMLDeclaration : public XMLNode +class TINYXML2_LIB XMLDeclaration : public XMLNode { friend class XMLDocument; public: @@ -929,7 +942,7 @@ protected: DTD tags get thrown into XMLUnknowns. */ -class XMLUnknown : public XMLNode +class TINYXML2_LIB XMLUnknown : public XMLNode { friend class XMLDocument; public: @@ -988,7 +1001,7 @@ enum XMLError { @note The attributes are not XMLNodes. You may only query the Next() attribute in a list. */ -class XMLAttribute +class TINYXML2_LIB XMLAttribute { friend class XMLElement; public: @@ -1089,7 +1102,7 @@ private: and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes. */ -class XMLElement : public XMLNode +class TINYXML2_LIB XMLElement : public XMLNode { friend class XMLBase; friend class XMLDocument; @@ -1409,7 +1422,7 @@ enum Whitespace { All Nodes are connected and allocated to a Document. If the Document is deleted, all its Nodes are also deleted. */ -class XMLDocument : public XMLNode +class TINYXML2_LIB XMLDocument : public XMLNode { friend class XMLElement; public: @@ -1667,7 +1680,7 @@ private: See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. */ -class XMLHandle +class TINYXML2_LIB XMLHandle { public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. @@ -1751,7 +1764,7 @@ private: A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the same in all regards, except for the 'const' qualifiers. See XMLHandle for API. */ -class XMLConstHandle +class TINYXML2_LIB XMLConstHandle { public: XMLConstHandle( const XMLNode* node ) { @@ -1858,7 +1871,7 @@ private: printer.CloseElement(); @endverbatim */ -class XMLPrinter : public XMLVisitor +class TINYXML2_LIB XMLPrinter : public XMLVisitor { public: /** Construct the printer. If the FILE* is specified, diff --git a/tinyxml2/test.vcxproj b/tinyxml2/test.vcxproj new file mode 100644 index 0000000..d55c24d --- /dev/null +++ b/tinyxml2/test.vcxproj @@ -0,0 +1,300 @@ + + + + + Debug-Dll + Win32 + + + Debug-Dll + x64 + + + Debug-Lib + Win32 + + + Debug-Lib + x64 + + + Release-Dll + Win32 + + + Release-Dll + x64 + + + Release-Lib + Win32 + + + Release-Lib + x64 + + + + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260} + test + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + Unicode + + + Unicode + true + + + Unicode + + + Unicode + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level4 + Disabled + + + true + + + + + Level4 + Disabled + + + true + + + + + Level4 + Disabled + TINYXML2_IMPORT;%(PreprocessorDefinitions) + + + true + Console + + + + + Level4 + Disabled + TINYXML2_IMPORT;%(PreprocessorDefinitions) + + + true + Console + + + + + Level4 + MaxSpeed + true + true + + + true + true + true + + + + + Level4 + MaxSpeed + true + true + + + true + true + true + + + + + Level4 + MaxSpeed + true + true + AnySuitable + Speed + true + true + true + TINYXML2_IMPORT;%(PreprocessorDefinitions) + + + false + true + true + Console + true + + + + + Level4 + MaxSpeed + true + true + AnySuitable + Speed + true + true + true + TINYXML2_IMPORT;%(PreprocessorDefinitions) + + + false + true + true + Console + true + + + + + Level4 + + + Console + + + + + Level4 + AnySuitable + true + Speed + true + true + true + + + false + Console + true + true + true + + + + + Level4 + + + Console + + + + + Level4 + AnySuitable + true + Speed + true + true + true + + + false + Console + true + true + true + + + + + + + + {d1c528b6-aa02-4d29-9d61-dc08e317a70d} + + + + + + \ No newline at end of file diff --git a/tinyxml2/test.vcxproj.filters b/tinyxml2/test.vcxproj.filters new file mode 100644 index 0000000..0a70dc6 --- /dev/null +++ b/tinyxml2/test.vcxproj.filters @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tinyxml2/tinyxml2.sln b/tinyxml2/tinyxml2.sln index d4f8f8a..1c0c92f 100755 --- a/tinyxml2/tinyxml2.sln +++ b/tinyxml2/tinyxml2.sln @@ -3,22 +3,52 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml2", "tinyxml2.vcxproj", "{D1C528B6-AA02-4D29-9D61-DC08E317A70D}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{E8FB2712-8666-4662-A5B8-2B5B0FB1A260}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 + Debug-Dll|Win32 = Debug-Dll|Win32 + Debug-Dll|x64 = Debug-Dll|x64 + Debug-Lib|Win32 = Debug-Lib|Win32 + Debug-Lib|x64 = Debug-Lib|x64 + Release-Dll|Win32 = Release-Dll|Win32 + Release-Dll|x64 = Release-Dll|x64 + Release-Lib|Win32 = Release-Lib|Win32 + Release-Lib|x64 = Release-Lib|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|Win32.ActiveCfg = Debug|Win32 - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|Win32.Build.0 = Debug|Win32 - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|x64.ActiveCfg = Debug|x64 - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug|x64.Build.0 = Debug|x64 - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|Win32.ActiveCfg = Release|Win32 - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|Win32.Build.0 = Release|Win32 - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|x64.ActiveCfg = Release|x64 - {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release|x64.Build.0 = Release|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Dll|Win32.ActiveCfg = Debug-Dll|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Dll|Win32.Build.0 = Debug-Dll|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Dll|x64.ActiveCfg = Debug-Dll|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Dll|x64.Build.0 = Debug-Dll|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Lib|Win32.ActiveCfg = Debug-Lib|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Lib|Win32.Build.0 = Debug-Lib|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Lib|x64.ActiveCfg = Debug-Lib|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Debug-Lib|x64.Build.0 = Debug-Lib|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Dll|Win32.ActiveCfg = Release-Dll|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Dll|Win32.Build.0 = Release-Dll|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Dll|x64.ActiveCfg = Release-Dll|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Dll|x64.Build.0 = Release-Dll|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Lib|Win32.ActiveCfg = Release-Lib|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Lib|Win32.Build.0 = Release-Lib|Win32 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Lib|x64.ActiveCfg = Release-Lib|x64 + {D1C528B6-AA02-4D29-9D61-DC08E317A70D}.Release-Lib|x64.Build.0 = Release-Lib|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Dll|Win32.ActiveCfg = Debug-Dll|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Dll|Win32.Build.0 = Debug-Dll|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Dll|x64.ActiveCfg = Debug-Dll|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Dll|x64.Build.0 = Debug-Dll|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Lib|Win32.ActiveCfg = Debug-Lib|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Lib|Win32.Build.0 = Debug-Lib|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Lib|x64.ActiveCfg = Debug-Lib|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Debug-Lib|x64.Build.0 = Debug-Lib|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Dll|Win32.ActiveCfg = Release-Dll|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Dll|Win32.Build.0 = Release-Dll|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Dll|x64.ActiveCfg = Release-Dll|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Dll|x64.Build.0 = Release-Dll|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Lib|Win32.ActiveCfg = Release-Lib|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Lib|Win32.Build.0 = Release-Lib|Win32 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Lib|x64.ActiveCfg = Release-Lib|x64 + {E8FB2712-8666-4662-A5B8-2B5B0FB1A260}.Release-Lib|x64.Build.0 = Release-Lib|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tinyxml2/tinyxml2.vcxproj b/tinyxml2/tinyxml2.vcxproj index b338bd1..bb7b999 100755 --- a/tinyxml2/tinyxml2.vcxproj +++ b/tinyxml2/tinyxml2.vcxproj @@ -1,20 +1,36 @@  - - Debug + + Debug-Dll Win32 - - Debug + + Debug-Dll x64 - - Release + + Debug-Lib Win32 - - Release + + Debug-Lib + x64 + + + Release-Dll + Win32 + + + Release-Dll + x64 + + + Release-Lib + Win32 + + + Release-Lib x64 @@ -24,57 +40,121 @@ tinyxml2 - - Application + + StaticLibrary true Unicode - - Application + + DynamicLibrary true Unicode - - Application + + StaticLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + StaticLibrary false true Unicode - - Application + + DynamicLibrary false true Unicode + + StaticLibrary + false + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + StaticLibrary + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + Unicode + + + StaticLibrary + true + Unicode + - + - + - + - + + + + + + + + + + + + + - + true - + true - + + true + + + true + + false - + false - + + false + + + false + + @@ -87,7 +167,20 @@ true - + + + + + Level4 + Disabled + WIN32;TINYXML2_EXPORT;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + NotSet + true + + + @@ -100,61 +193,174 @@ true + + + + + Level4 + Disabled + WIN32;TINYXML2_EXPORT;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + NotSet + true + + + + + Level4 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + AnySuitable + Speed + true + true + true + false + + + Console + true + true + true + true + + + + + Level4 + + + MaxSpeed + true + true + WIN32;TINYXML2_EXPORT;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + AnySuitable + Speed + true + true + true + false + + + NotSet + true + true + true + true + + + + + Level4 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + AnySuitable + Speed + true + true + true + false + + + Console + true + true + true + true + + + + + Level4 + + + MaxSpeed + true + true + WIN32;TINYXML2_EXPORT;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + AnySuitable + Speed + true + true + true + false + + + NotSet + true + true + true + true + + + + + true + + + + true + - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) AnySuitable + + + true + + Speed + + true + + true true false - - Console - true - true - true - true - + + + + true + + + true + - Level4 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) AnySuitable + + + true + + Speed + + true + + true true false - - Console - true - true - true - true - - - diff --git a/tinyxml2/tinyxml2.vcxproj.filters b/tinyxml2/tinyxml2.vcxproj.filters index 89f9d69..e19968a 100755 --- a/tinyxml2/tinyxml2.vcxproj.filters +++ b/tinyxml2/tinyxml2.vcxproj.filters @@ -2,10 +2,8 @@ - - \ No newline at end of file From 0c55c70b116ccfb381e0ce551f5b64ce1a24d461 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 6 Jul 2013 12:19:04 +0200 Subject: [PATCH 05/10] Improved output paths in VS solution --- tinyxml2/test.vcxproj | 49 ++++++++++++++++++++++++++++++++++++++- tinyxml2/tinyxml2.vcxproj | 16 +++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/tinyxml2/test.vcxproj b/tinyxml2/test.vcxproj index d55c24d..e61bb1b 100644 --- a/tinyxml2/test.vcxproj +++ b/tinyxml2/test.vcxproj @@ -125,7 +125,54 @@ - + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + + + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + + + $(SolutionDir)temp\$(Platform)-$(Configuration)\ + Level4 diff --git a/tinyxml2/tinyxml2.vcxproj b/tinyxml2/tinyxml2.vcxproj index bb7b999..7155976 100755 --- a/tinyxml2/tinyxml2.vcxproj +++ b/tinyxml2/tinyxml2.vcxproj @@ -132,27 +132,43 @@ true + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ true + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ true + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ true + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ false + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ false + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ false + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ false + $(SolutionDir)bin\$(Platform)-$(Configuration)\ + $(SolutionDir)temp\$(Platform)-$(Configuration)\ From 95060350bdbff81b5597cc5c2d0f6960242d8032 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Fri, 26 Jul 2013 10:42:44 +0200 Subject: [PATCH 06/10] Removed dllexport/import attribute from private class, disable related warning C4251 --- tinyxml2.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tinyxml2.h b/tinyxml2.h index aa86d0d..72dc801 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -57,6 +57,10 @@ distribution. # endif #endif +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4251) +#endif #ifdef _WIN32 # ifdef TINYXML2_EXPORT @@ -134,7 +138,7 @@ class XMLPrinter; and entity translation if actually read. Can also store (and memory manage) a traditional char[] */ -class TINYXML2_LIB StrPair +class StrPair { public: enum { @@ -198,7 +202,7 @@ private: cause a call to new/delete */ template -class TINYXML2_LIB DynArray +class DynArray { public: DynArray< T, INIT >() { @@ -289,7 +293,7 @@ private: Parent virtual class of a pool for fast allocation and deallocation of objects. */ -class TINYXML2_LIB MemPool +class MemPool { public: MemPool() {} @@ -306,7 +310,7 @@ public: Template child class to create pools of the correct type. */ template< int SIZE > -class TINYXML2_LIB MemPoolT : public MemPool +class MemPoolT : public MemPool { public: MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} @@ -1977,5 +1981,8 @@ private: } // tinyxml2 +#if defined(_MSC_VER) +# pragma warning(pop) +#endif #endif // TINYXML2_INCLUDED From 721b42da8e4efdb095aa39373c557ad40385d88a Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Wed, 31 Jul 2013 11:50:44 -0300 Subject: [PATCH 07/10] make the xmltest to return != 0, if one of the tests has failed. --- xmltest.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xmltest.cpp b/xmltest.cpp index abb2f1b..1df0c44 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -21,6 +21,7 @@ #endif using namespace tinyxml2; +int gTests = 0; int gPass = 0; int gFail = 0; @@ -47,6 +48,8 @@ bool XMLTest (const char* testString, const char* expected, const char* found, b } } + ++gTests; + if ( pass ) ++gPass; else @@ -68,6 +71,8 @@ template< class T > bool XMLTest( const char* testString, T expected, T found, b else printf (" %s [%d][%d]\n", testString, static_cast(expected), static_cast(found) ); + ++gTests; + if ( pass ) ++gPass; else @@ -1262,5 +1267,5 @@ int main( int argc, const char ** argv ) #endif printf ("\nPass %d, Fail %d\n", gPass, gFail); - return 0; + return (gTests - gPass); } From 032aa1b96c0a8b7bd6001e5d7eeab0bd3b863886 Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Wed, 31 Jul 2013 12:01:12 -0300 Subject: [PATCH 08/10] added test rule. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index b1a8ed7..aab6293 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ all: xmltest xmltest: xmltest.cpp tinyxml2.cpp tinyxml2.h +test: clean xmltest + ./xmltest clean: rm -f *.o xmltest From db304256bb41547c9e700f0021846613dc9ba8ab Mon Sep 17 00:00:00 2001 From: "Lee Thomason (grinliz)" Date: Wed, 31 Jul 2013 12:24:52 -0700 Subject: [PATCH 09/10] clean up the pass/fail logic, still return the same value from test if it fails --- tinyxml2.h | 1 + xmltest.cpp | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tinyxml2.h b/tinyxml2.h index 72dc801..a4aa6d3 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -14,6 +14,7 @@ not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. diff --git a/xmltest.cpp b/xmltest.cpp index 1df0c44..86b4ba2 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -21,7 +21,6 @@ #endif using namespace tinyxml2; -int gTests = 0; int gPass = 0; int gFail = 0; @@ -48,8 +47,6 @@ bool XMLTest (const char* testString, const char* expected, const char* found, b } } - ++gTests; - if ( pass ) ++gPass; else @@ -71,8 +68,6 @@ template< class T > bool XMLTest( const char* testString, T expected, T found, b else printf (" %s [%d][%d]\n", testString, static_cast(expected), static_cast(found) ); - ++gTests; - if ( pass ) ++gPass; else @@ -1267,5 +1262,6 @@ int main( int argc, const char ** argv ) #endif printf ("\nPass %d, Fail %d\n", gPass, gFail); - return (gTests - gPass); + + return gFail; } From 1bfb95488f83e22f182e097fd3c55a0904345d3f Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sun, 4 Aug 2013 13:51:17 +0200 Subject: [PATCH 10/10] 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 --- tinyxml2.cpp | 8 +++++--- tinyxml2.h | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 6567520..5611614 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1729,11 +1729,11 @@ void XMLDocument::PrintError() const } -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::PrintString( const char* p, bool restricted ) 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 @@ void XMLPrinter::OpenElement( const char* name ) if ( _textDepth < 0 && !_firstElement && !_compactMode ) { Print( "\n" ); + } + if ( !_compactMode ) { PrintSpace( _depth ); } diff --git a/tinyxml2.h b/tinyxml2.h index 72dc801..31f2ec7 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -125,11 +125,9 @@ class XMLDocument; class XMLElement; class XMLAttribute; class XMLComment; -class XMLNode; class XMLText; class XMLDeclaration; class XMLUnknown; - class XMLPrinter; /* @@ -1884,7 +1882,7 @@ public: If 'compact' is set to true, then output is created with only required whitespace and newlines. */ - XMLPrinter( FILE* file=0, bool compact = false ); + XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 ); ~XMLPrinter() {} /** If streaming, write the BOM and declaration. */