From 16ed47dc14a39b505c4dc8721791086b21bca783 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 6 Jul 2013 12:02:43 +0200 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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