Hi everyone,

Based on many users' request, I've looked into the work of implementing C++
namespace to Xerces-C++.

I've reviewed the design in ICU, and also read suggestions from some old
threads (e.g. http://marc.theaimsgroup.com/?t=98019090000001&r=1&w=2, and
http://marc.theaimsgroup.com/?t=97119438300003&r=1&w=2), here is what I am
proposing:

1. Define the following macro in XercesDefs.hpp:

// -------------------------------------------------------------------------
--
// Define namespace symbols if the compiler supports it.
// -------------------------------------------------------------------------
--
#if defined(XERCES_HAS_CPP_NAMESPACE)
    #define XERCES_CPP_NAMESPACE_BEGIN    namespace XERCES_CPP_NAMESPACE {
    #define XERCES_CPP_NAMESPACE_END    }
    #define XERCES_CPP_NAMESPACE_USE    using namespace
XERCES_CPP_NAMESPACE;
    #define XERCES_CPP_NAMESPACE_QUALIFIER    XERCES_CPP_NAMESPACE::

    namespace XERCES_CPP_NAMESPACE { }
    namespace xercesc = XERCES_CPP_NAMESPACE;
    XERCES_CPP_NAMESPACE_USE
#else
    #define XERCES_CPP_NAMESPACE_BEGIN
    #define XERCES_CPP_NAMESPACE_END
    #define XERCES_CPP_NAMESPACE_USE
    #define XERCES_CPP_NAMESPACE_QUALIFIER
#endif

2. The XERCES_HAS_CPP_NAMESPACE is defined in each Compiler Definition file,
e.g. xercesc/util/Compilers/GCCDefs.hpp

// -------------------------------------------------------------------------
--
// Indicate that we support C++ namespace
// Do not define it if the compile cannot handle C++ namespace
// -------------------------------------------------------------------------
--
//  #define XERCES_HAS_CPP_NAMESPACE

3.  And XERCES_CPP_NAMESPACE is defined in XercesVersion.hpp
    #define XERCES_PRODUCT    xercesc
    #define XERCES_CPP_NAMESPACE
INVK_CAT3_RAW_NUMERIC_SEP_UNDERSCORE(XERCES_PRODUCT,XERCES_VERSION_MAJOR,XER
CES_VERSION_MINOR)

where the INVK_CAT3... is an intermediate macro which will eventually create
the namespace name "xercesc_2_1"

4. Then in each Xerces-C++ file (both .hpp and .cpp), add
    #define XERCES_CPP_NAMESPACE_BEGIN
at the beginning and
     #define XERCES_CPP_NAMESPACE_END
at the end



Note:
1.  "using namespace xercesc_2_1;" is coded in XercesDefs.hpp if
XERCES_HAS_CPP_NAMESPACE is defined.  So users are not required to modify
their application to pick up this support, unless they use forward
declaration which then need to be properly scoped.
2.  The version number is included in the namespace name.   This is to allow
co-existence of different Xerces-C++ releases on the same system.   Such
idea is borrowed from ICU which seems working well.
3.  And the distributed binary packages will then be built with C++
Namespace, wherever applicable


Any comment?

Thanks!

Tinny


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to