Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Added dll-interface declarations to support using DLLs built via VS20…
Browse files Browse the repository at this point in the history
…0X. Linking projects need to define TICPP_DLL to use the DLL.
  • Loading branch information
mjanisz@gmail.com committed Oct 18, 2012
1 parent 761c895 commit e81f4b5
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 50 deletions.
2 changes: 1 addition & 1 deletion build_instructions.txt
Expand Up @@ -22,7 +22,7 @@ Introduction:
Build Steps:
1) Download Premake from http://premake.sf.net/download
2) Checkout the source for TinyXML++ using Subversion.
- svn checkout http://ticpp.googlecode.com/svn/trunk/ ticpp
- svn checkout https://ticpp.googlecode.com/svn/trunk/ ticpp
3) Place the Premake executable in the root directory of TiCPP or somewhere in your
path.
4) To create the needed build files navigate to the TinyXML++ directory (ticpp)
Expand Down
2 changes: 2 additions & 0 deletions changes.txt
Expand Up @@ -267,3 +267,5 @@ Changes in version 2.1.5
Comments should not, in fact, parse entities. Fixed the code path and added tests.
- We were not catching all the returns from ftell. Thanks to Bernard for catching that.

2.5.4
- Added dll-interface declarations to support using DLLs built via VS200X.
44 changes: 26 additions & 18 deletions ticpp.h
Expand Up @@ -38,13 +38,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@todo add TYPECOUNT support. See ticpp::NodeFactory.
@todo Add a quick reference
*/

/*
* THIS FILE WAS ALTERED BY Matt Janisz, 12. October 2012.
*
* - added ticppapi.h include and TICPP_API dll-interface to support building DLL using VS200X
*/

#ifndef TIXML_USE_TICPP
#define TIXML_USE_TICPP
#endif

#ifndef TICPP_INCLUDED
#define TICPP_INCLUDED

#include "ticppapi.h"
#include "tinyxml.h"
#include <sstream>
#include <vector>
Expand All @@ -67,7 +75,7 @@ namespace ticpp
/**
This is a ticpp exception class
*/
class Exception : public std::exception
class TICPP_API Exception : public std::exception
{
public:
/**
Expand Down Expand Up @@ -97,16 +105,16 @@ namespace ticpp
}

// Forward Declarations for Visitor, and others.
class Document;
class Element;
class Declaration;
class StylesheetReference;
class Text;
class Comment;
class Attribute;
class TICPP_API Document;
class TICPP_API Element;
class TICPP_API Declaration;
class TICPP_API StylesheetReference;
class TICPP_API Text;
class TICPP_API Comment;
class TICPP_API Attribute;

/** Wrapper around TiXmlVisitor */
class Visitor : public TiXmlVisitor
class TICPP_API Visitor : public TiXmlVisitor
{
public:
// Overload the TiXmlVisitor functions, wrap objects, call ticpp::Visitor functions
Expand Down Expand Up @@ -149,7 +157,7 @@ namespace ticpp
};

/** Wrapper around TiXmlBase */
class Base
class TICPP_API Base
{
public:

Expand Down Expand Up @@ -300,7 +308,7 @@ namespace ticpp
/**
Wrapper around TiXmlAttribute
*/
class Attribute : public Base
class TICPP_API Attribute : public Base
{
private:
TiXmlAttribute* m_tiXmlPointer;
Expand Down Expand Up @@ -467,7 +475,7 @@ namespace ticpp
/**
Wrapper around TiXmlNode
*/
class Node : public Base
class TICPP_API Node : public Base
{
public:

Expand Down Expand Up @@ -1319,7 +1327,7 @@ namespace ticpp
};

/** Wrapper around TiXmlComment */
class Comment : public NodeImp< TiXmlComment >
class TICPP_API Comment : public NodeImp< TiXmlComment >
{
public:

Expand All @@ -1340,7 +1348,7 @@ namespace ticpp
};

/** Wrapper around TiXmlText */
class Text : public NodeImp< TiXmlText >
class TICPP_API Text : public NodeImp< TiXmlText >
{
public:

Expand Down Expand Up @@ -1379,7 +1387,7 @@ namespace ticpp
};

/** Wrapper around TiXmlDocument */
class Document : public NodeImp< TiXmlDocument >
class TICPP_API Document : public NodeImp< TiXmlDocument >
{
public:
/**
Expand Down Expand Up @@ -1458,7 +1466,7 @@ namespace ticpp
};

/** Wrapper around TiXmlElement */
class Element : public NodeImp< TiXmlElement >
class TICPP_API Element : public NodeImp< TiXmlElement >
{
public:
/**
Expand Down Expand Up @@ -1837,7 +1845,7 @@ namespace ticpp
};

/** Wrapper around TiXmlDeclaration */
class Declaration : public NodeImp< TiXmlDeclaration >
class TICPP_API Declaration : public NodeImp< TiXmlDeclaration >
{
public:
/**
Expand Down Expand Up @@ -1872,7 +1880,7 @@ namespace ticpp
};

/** Wrapper around TiXmlStylesheetReference */
class StylesheetReference : public NodeImp< TiXmlStylesheetReference >
class TICPP_API StylesheetReference : public NodeImp< TiXmlStylesheetReference >
{
public:
/**
Expand Down
3 changes: 3 additions & 0 deletions ticpp.lua
Expand Up @@ -116,3 +116,6 @@ else
table.insert( package.buildoptions, "-fPIC" )
end

if ( package.kind == "dll" ) then
table.insert( package.defines, "BUILD_TICPP_DLL" )
end
3 changes: 3 additions & 0 deletions ticpp4.lua
Expand Up @@ -66,6 +66,9 @@ project "TiCPP"
--
if _OPTIONS["ticpp-shared"] then
kind "SharedLib"

-- Define BUILD_TICPP_DLL to provide dll-interface declarations.
defines { "BUILD_TICPP_DLL" }
else
kind "StaticLib"
if not ticpp.GetCustomValue( "targetdir" ) then
Expand Down
55 changes: 55 additions & 0 deletions ticppapi.h
@@ -0,0 +1,55 @@
/*
Copyright (c) 2012 Matt Janisz
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef TICPP_API_INCLUDED
#define TICPP_API_INCLUDED

#undef TICPP_API

#if defined(_WIN32) | defined(WIN32) | defined(WINDOWS) | defined(_WINDOWS)
//windows dll defines
#include <windows.h>

// define BUILD_TICPP_DLL when building TiCPP dll.
#ifdef BUILD_TICPP_DLL
#define TICPP_API __declspec(dllexport)
#endif

// define TICPP_DLL when linking TiCPP dll.
#ifdef TICPP_DLL
#define TICPP_API __declspec(dllimport)
#endif

// Disable dll-interface warning
#ifdef TICPP_API
#pragma warning( push )
#pragma warning( disable : 4251 ) // X needs to have dll-interface to be used by clients of class Y
#pragma warning( disable : 4275 ) // X is derived from class Y but only X is exported
#endif

#endif

#ifndef TICPP_API
//linux or windows-static library defines
#define TICPP_API
#endif

#endif // TICPP_API_INCLUDED
15 changes: 11 additions & 4 deletions ticpprc.h
Expand Up @@ -20,26 +20,33 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* THIS FILE WAS ALTERED BY Matt Janisz, 12. October 2012.
*
* - added ticppapi.h include and TICPP_API dll-interface to support building DLL using VS200X
*/

#ifdef TIXML_USE_TICPP

#ifndef TICPPRC_INCLUDED
#define TICPPRC_INCLUDED

#include "ticppapi.h"
#include <vector>

// Forward declare ticpp::Node, so it can be made a friend of TiCppRC
namespace ticpp
{
class Base;
class TICPP_API Base;
}

// Forward declare TiCppRCImp so TiCppRC can hold a pointer to it
class TiCppRCImp;
class TICPP_API TiCppRCImp;

/**
Base class for reference counting functionality
*/
class TiCppRC
class TICPP_API TiCppRC
{
// Allow ticpp::Node to directly modify reference count
friend class ticpp::Base;
Expand Down Expand Up @@ -71,7 +78,7 @@ class TiCppRC
void DeleteSpawnedWrappers();
};

class TiCppRCImp
class TICPP_API TiCppRCImp
{
private:

Expand Down
11 changes: 9 additions & 2 deletions tinystr.h
Expand Up @@ -34,11 +34,18 @@ distribution.
* - added swap(), clear(), size(), capacity(), operator+().
*/

/*
* THIS FILE WAS ALTERED BY Matt Janisz, 12. October 2012.
*
* - added ticppapi.h include and TICPP_API dll-interface to support building DLL using VS200X
*/

#ifndef TIXML_USE_STL

#ifndef TIXML_STRING_INCLUDED
#define TIXML_STRING_INCLUDED

#include "ticppapi.h"
#include <assert.h>
#include <string.h>

Expand All @@ -64,7 +71,7 @@ distribution.
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
a string and there's no more room, we allocate a buffer twice as big as we need.
*/
class TiXmlString
class TICPP_API TiXmlString
{
public :
// The size type used
Expand Down Expand Up @@ -295,7 +302,7 @@ TiXmlString operator + (const char* a, const TiXmlString & b);
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
Only the operators that we need for TinyXML have been developped.
*/
class TiXmlOutStream : public TiXmlString
class TICPP_API TiXmlOutStream : public TiXmlString
{
public :

Expand Down

0 comments on commit e81f4b5

Please sign in to comment.