xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dick.Brid...@tais.com
Subject Re: Proposal Review: Using C++ Namespace
Date Sat, 02 Nov 2002 00:18:57 GMT

Rather than using an entire namespace in a common header, it might be
useful to do something like:

#if defined(XERCES_HAS_CPP_NAMESPACE) && !defined(XERCES_USE_NAMESPACES)
      #undef XERCES_HAS_CPP_NAMESPACE
#endif

That way the onus is on those of us that want to take advantage of
namespaces to define
XERCES_USE_NAMESPACES.



                                                                                         
                                            
                      "Tinny Ng"                                                         
                                            
                      <tng-xml@ca.ibm.         To:      <xerces-c-dev@xml.apache.org>
                                                
                      com>                     cc:                                    
                                               
                                               Subject: Proposal Review: Using C++ Namespace
                                         
                      11/01/2002 03:57                                                   
                                            
                      PM                                                                 
                                            
                      Please respond                                                     
                                            
                      to xerces-c-dev                                                    
                                            
                                                                                         
                                            
                                                                                         
                                            




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: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org






---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Mime
View raw message