In an attempt to make compilation easier, XMLReader now has an ifdef ladder

which pulls in the headers for the various parsers if the appropriate macros are
defined - USE_EXPAT, USE_XERCES, USE_LIBXML2, USE_MSXML.

You can define any or all of them, or none should you so wish.

It also sets SAX::XMLReader as a default class - ie if you define one of the above macros,
SAX::XMLReader<stringT> will become a synonym for SAX::expat_wrapper<stringT> or whatever.
This commit is contained in:
jez_higgins 2002-07-12 22:10:52 +00:00
parent b884a0ee3d
commit fd5c310e0b
2 changed files with 70 additions and 10 deletions

View file

@ -64,7 +64,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "..\\" /I "\work\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "..\\" /I "\work\include" /I "\work\lib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "USE_EXPAT" /YX /FD /GZ /c
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
@ -254,6 +254,15 @@ SOURCE=.\ext\Locator2.h
# Begin Source File
SOURCE=.\wrappers\saxexpat.cpp
!IF "$(CFG)" == "SAXlib - Win32 Release"
!ELSEIF "$(CFG)" == "SAXlib - Win32 Debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
@ -262,6 +271,16 @@ SOURCE=.\wrappers\saxexpat.h
# Begin Source File
SOURCE=.\wrappers\saxlibxml2.cpp
!IF "$(CFG)" == "SAXlib - Win32 Release"
!ELSEIF "$(CFG)" == "SAXlib - Win32 Debug"
# PROP Exclude_From_Build 1
# SUBTRACT CPP /WX
!ENDIF
# End Source File
# Begin Source File
@ -292,5 +311,9 @@ SOURCE=.\filter\Writer.h
SOURCE=.\parsers\saxgarden.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\saxlib.cpp
# End Source File
# End Target
# End Project

View file

@ -403,16 +403,53 @@ public:
} // setProperty
}; // class basic_XMLReader
/**
* {@link basic_XMLReader basic_XMLReader} instantiated for chars
*/
typedef basic_XMLReader<std::string> XMLReader;
/**
* {@link basic_XMLReader basic_XMLReader} instantiated for wchar_t
*/
typedef basic_XMLReader<std::wstring> wXMLReader;
}; // namespace SAX
// ifdef ladder to set up the default parser
#ifdef USE_LIBXML2
#pragma message("Including libxml2")
#include <SAX/wrappers/saxlibxml2.h>
#undef DEF_SAX_P
#define DEF_SAX_P libxml2_wrapper
#endif
#ifdef USE_MSXML
#pragma message("Including MSXML")
#include <SAX/wrappers/saxmsxml2.h>
#undef DEF_SAX_P
#define DEF_SAX_P msxml2_wrapper
#endif
#ifdef USE_XERCES
#pragma message("Including Xerces")
#include <SAX/wrappers/saxxerces.h>
#undef DEF_SAX_P
#define DEF_SAX_P xerces_wrapper
#endif
#ifdef USE_GARDEN
#pragma message("Including Garden")
#include <SAX/parsers/saxgarden.h>
#undef DEF_SAX_P
#define DEF_SAX_P Garden
#endif
#ifdef USE_EXPAT
#pragma message("Including Expat")
#include <SAX/wrappers/saxexpat.h>
#undef DEF_SAX_P
#define DEF_SAX_P expat_wrapper
#endif
#ifndef NO_DEFAULT_PARSER
#ifdef DEF_SAX_P
namespace SAX
{
template<class string_type>
class XMLReader : public DEF_SAX_P<string_type> { };
} // namespace SAX
#else
#error No default parser defined.
#endif
#endif
#undef DEF_P
#endif
// end of file