CppUnit project page FAQ CppUnit home page

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Portability.h

Go to the documentation of this file.
00001 #ifndef CPPUNIT_PORTABILITY_H
00002 #define CPPUNIT_PORTABILITY_H
00003 
00004 /* include platform specific config */
00005 #if defined(__BORLANDC__)
00006 #    include <cppunit/config/config-bcb5.h>
00007 #elif defined (_MSC_VER)
00008 #    include <cppunit/config/config-msvc6.h>
00009 #else
00010 #    include <cppunit/config-auto.h>
00011 #endif
00012 
00013 // Version number of package
00014 #ifndef CPPUNIT_VERSION 
00015 #define CPPUNIT_VERSION  "1.9.10" 
00016 #endif
00017  
00018 #include <cppunit/config/CppUnitApi.h>    // define CPPUNIT_API & CPPUNIT_NEED_DLL_DECL
00019 #include <cppunit/config/SelectDllLoader.h>
00020 
00021 
00022 /* Options that the library user may switch on or off.
00023  * If the user has not done so, we chose default values.
00024  */
00025 
00026 
00027 /* Define to 1 if you wish to have the old-style macros
00028    assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
00029 #if !defined(CPPUNIT_ENABLE_NAKED_ASSERT)
00030 # define CPPUNIT_ENABLE_NAKED_ASSERT          0
00031 #endif
00032 
00033 /* Define to 1 if you wish to have the old-style CU_TEST family
00034    of macros. */
00035 #if !defined(CPPUNIT_ENABLE_CU_TEST_MACROS)
00036 # define CPPUNIT_ENABLE_CU_TEST_MACROS        0
00037 #endif
00038 
00039 /* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.) 
00040    I don't think there is any C preprocess that does NOT support this! */
00041 #if !defined(CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION)
00042 # define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION   1
00043 #endif
00044 
00045 /* Assumes that STL and CppUnit are in global space if the compiler does not
00046    support namespace. */
00047 #if !defined(CPPUNIT_HAVE_NAMESPACES)
00048 # if !defined(CPPUNIT_NO_NAMESPACE)
00049 #  define CPPUNIT_NO_NAMESPACE 1
00050 # endif // !defined(CPPUNIT_NO_NAMESPACE)
00051 # if !defined(CPPUNIT_NO_STD_NAMESPACE)
00052 #  define CPPUNIT_NO_STD_NAMESPACE 1
00053 # endif // !defined(CPPUNIT_NO_STD_NAMESPACE)
00054 #endif // !defined(CPPUNIT_HAVE_NAMESPACES)
00055 
00056 /* Define CPPUNIT_STD_NEED_ALLOCATOR to 1 if you need to specify
00057  * the allocator you used when instantiating STL container. Typically
00058  * used for compilers that do not support template default parameter.
00059  * CPPUNIT_STD_ALLOCATOR will be used as the allocator. Default is
00060  * std::allocator. On some compilers, you may need to change this to
00061  * std::allocator<T>.
00062  */
00063 #if CPPUNIT_STD_NEED_ALLOCATOR
00064 # if !defined(CPPUNIT_STD_ALLOCATOR)
00065 #  define CPPUNIT_STD_ALLOCATOR std::allocator
00066 # endif // !defined(CPPUNIT_STD_ALLOCATOR)
00067 #endif // defined(CPPUNIT_STD_NEED_ALLOCATOR)
00068 
00069 
00070 // Compiler error location format for CompilerOutputter
00071 // If not define, assumes that it's gcc
00072 // See class CompilerOutputter for format.
00073 #if !defined(CPPUNIT_COMPILER_LOCATION_FORMAT)
00074 # define CPPUNIT_COMPILER_LOCATION_FORMAT "%f:%l:"
00075 #endif
00076 
00077 // If CPPUNIT_HAVE_CPP_CAST is defined, then c++ style cast will be used,
00078 // otherwise, C style cast are used.
00079 #if defined( CPPUNIT_HAVE_CPP_CAST )
00080 # define CPPUNIT_CONST_CAST( TargetType, pointer ) \
00081     const_cast<TargetType>( pointer )
00082 
00083 # define CPPUNIT_STATIC_CAST( TargetType, pointer ) \
00084     static_cast<TargetType>( pointer )
00085 #else // defined( CPPUNIT_HAVE_CPP_CAST )
00086 # define CPPUNIT_CONST_CAST( TargetType, pointer ) \
00087     ((TargetType)( pointer ))
00088 # define CPPUNIT_STATIC_CAST( TargetType, pointer ) \
00089     ((TargetType)( pointer ))
00090 #endif // defined( CPPUNIT_HAVE_CPP_CAST )
00091 
00092 // If CPPUNIT_NO_STD_NAMESPACE is defined then STL are in the global space.
00093 // => Define macro 'std' to nothing
00094 #if defined(CPPUNIT_NO_STD_NAMESPACE)
00095 # undef std
00096 # define std
00097 #endif  // defined(CPPUNIT_NO_STD_NAMESPACE)
00098 
00099 // If CPPUNIT_NO_NAMESPACE is defined, then put CppUnit classes in the
00100 // global namespace: the compiler does not support namespace.
00101 #if defined(CPPUNIT_NO_NAMESPACE)
00102 # define CPPUNIT_NS_BEGIN
00103 # define CPPUNIT_NS_END
00104 # define CPPUNIT_NS
00105 #else   // defined(CPPUNIT_NO_NAMESPACE)
00106 # define CPPUNIT_NS_BEGIN namespace CppUnit {
00107 # define CPPUNIT_NS_END }
00108 # define CPPUNIT_NS CppUnit
00109 #endif  // defined(CPPUNIT_NO_NAMESPACE)
00110 
00121 #define CPPUNIT_STRINGIZE( symbol ) _CPPUNIT_DO_STRINGIZE( symbol )
00122 
00124 #define _CPPUNIT_DO_STRINGIZE( symbol ) #symbol
00125 
00144 #define CPPUNIT_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN( symbol1, symbol2 )
00145 
00147 #define _CPPUNIT_DO_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN2( symbol1, symbol2 )
00148 
00150 #define _CPPUNIT_DO_JOIN2( symbol1, symbol2 ) symbol1##symbol2
00151 
00156 #define CPPUNIT_MAKE_UNIQUE_NAME( prefix ) CPPUNIT_JOIN( prefix, __LINE__ )
00157 
00160 #if !defined(CPPUNIT_WRAP_COLUMN)
00161 # define CPPUNIT_WRAP_COLUMN 79
00162 #endif
00163 
00164 
00165 /* perform portability hacks */
00166 
00167 
00168 /* Define CPPUNIT_SSTREAM as a stream with a "std::string str()"
00169  * method.
00170  */
00171 #if CPPUNIT_HAVE_SSTREAM
00172 # include <sstream>
00173     CPPUNIT_NS_BEGIN
00174 
00175     typedef std::ostringstream OStringStream;
00176 
00177     CPPUNIT_NS_END
00178 #elif CPPUNIT_HAVE_CLASS_STRSTREAM
00179 # include <string>
00180 # if CPPUNIT_HAVE_STRSTREAM
00181 #   include <strstream>
00182 # else // CPPUNIT_HAVE_STRSTREAM
00183 #  include <strstream.h>
00184 # endif // CPPUNIT_HAVE_CLASS_STRSTREAM
00185 
00186     CPPUNIT_NS_BEGIN
00187 
00188       class OStringStream : public std::ostrstream 
00189       {
00190       public:
00191           std::string str()
00192           {
00193 //            (*this) << '\0';
00194 //            std::string msg(std::ostrstream::str());
00195 //            std::ostrstream::freeze(false);
00196 //            return msg;
00197 // Alternative implementation that don't rely on freeze which is not
00198 // available on some platforms:
00199             return std::string( std::ostrstream::str(), pcount() );
00200           }
00201       };
00202 
00203     CPPUNIT_NS_END
00204 #else // CPPUNIT_HAVE_CLASS_STRSTREAM
00205 #   error Cannot define CppUnit::OStringStream.
00206 #endif // CPPUNIT_HAVE_SSTREAM
00207 
00208 
00209 #endif // CPPUNIT_PORTABILITY_H

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers