Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 1 | // (C) Copyright Gennadiy Rozental 2005-2008. |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | // http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | // See http://www.boost.org/libs/test for the library home page. |
| 7 | // |
| 8 | // File : $RCSfile$ |
| 9 | // |
| 10 | // Version : $Revision: 57992 $ |
| 11 | // |
| 12 | // Description : Runtime.Param library configuration |
| 13 | // *************************************************************************** |
| 14 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 15 | #ifndef NDNBOOST_RT_CONFIG_HPP_062604GER |
| 16 | #define NDNBOOST_RT_CONFIG_HPP_062604GER |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 17 | |
| 18 | // Boost |
| 19 | #include <ndnboost/config.hpp> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 20 | #ifdef NDNBOOST_MSVC |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 21 | # pragma warning(disable: 4511) // copy constructor could not be generated |
| 22 | # pragma warning(disable: 4512) // assignment operator could not be generated |
| 23 | # pragma warning(disable: 4181) // qualifier applied to reference type; ignored |
| 24 | # pragma warning(disable: 4675) // resolved overload was found by argument-dependent lookup |
| 25 | #endif |
| 26 | |
| 27 | // Boost.Test |
| 28 | #include <ndnboost/test/detail/config.hpp> |
| 29 | #include <ndnboost/test/utils/basic_cstring/basic_cstring.hpp> |
| 30 | #include <ndnboost/test/utils/wrap_stringstream.hpp> |
| 31 | #include <ndnboost/test/utils/basic_cstring/io.hpp> // operator<<(ndnboost::runtime::cstring) |
| 32 | |
| 33 | // STL |
| 34 | #include <string> |
| 35 | #include <cstdlib> |
| 36 | |
| 37 | //____________________________________________________________________________// |
| 38 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 39 | #ifndef NDNBOOST_RT_PARAM_CUSTOM_STRING |
| 40 | # ifndef NDNBOOST_RT_PARAM_WIDE_STRING |
| 41 | # define NDNBOOST_RT_PARAM_NAMESPACE runtime |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 42 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 43 | # define NDNBOOST_RT_PARAM_NAMESPACE wide_runtime |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 44 | # endif |
| 45 | #endif |
| 46 | |
| 47 | #ifdef __SUNPRO_CC |
| 48 | extern int putenv(char*); |
| 49 | #endif |
| 50 | |
| 51 | namespace ndnboost { |
| 52 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 53 | namespace NDNBOOST_RT_PARAM_NAMESPACE { |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 54 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 55 | #ifndef NDNBOOST_RT_PARAM_CUSTOM_STRING |
| 56 | # ifndef NDNBOOST_RT_PARAM_WIDE_STRING |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 57 | |
| 58 | typedef char char_type; |
| 59 | typedef std::string dstring; |
| 60 | typedef unit_test::const_string cstring; |
| 61 | typedef unit_test::literal_string literal_cstring; |
| 62 | typedef wrap_stringstream format_stream; |
| 63 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 64 | #ifdef NDNBOOST_CLASSIC_IOSTREAMS |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 65 | typedef std::ostream out_stream; |
| 66 | #else |
| 67 | typedef std::basic_ostream<char_type> out_stream; |
| 68 | #endif |
| 69 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 70 | #ifdef NDNBOOST_MSVC |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 71 | #pragma warning(push) |
| 72 | #pragma warning(disable:4996) // putenv |
| 73 | #endif |
| 74 | |
| 75 | #ifndef UNDER_CE |
| 76 | #if defined(__COMO__) && 0 |
| 77 | inline void |
| 78 | putenv_impl( cstring name, cstring value ) |
| 79 | { |
| 80 | using namespace std; |
| 81 | // !! this may actually fail. What should we do? |
| 82 | setenv( name.begin(), value.begin(), 1 ); |
| 83 | } |
| 84 | #else |
| 85 | inline void |
| 86 | putenv_impl( cstring name, cstring value ) |
| 87 | { |
| 88 | format_stream fs; |
| 89 | |
| 90 | fs << name << '=' << value; |
| 91 | |
| 92 | // !! this may actually fail. What should we do? |
| 93 | // const_cast is used to satisfy putenv interface |
| 94 | using namespace std; |
| 95 | putenv( const_cast<char*>( fs.str().c_str() ) ); |
| 96 | } |
| 97 | #endif |
| 98 | #endif |
| 99 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 100 | #ifdef NDNBOOST_MSVC |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 101 | #pragma warning(pop) |
| 102 | #endif |
| 103 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 104 | #define NDNBOOST_RT_PARAM_LITERAL( l ) l |
| 105 | #define NDNBOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( l, sizeof( l ) - 1 ) |
| 106 | #define NDNBOOST_RT_PARAM_GETENV getenv |
| 107 | #define NDNBOOST_RT_PARAM_PUTENV ::ndnboost::NDNBOOST_RT_PARAM_NAMESPACE::putenv_impl |
| 108 | #define NDNBOOST_RT_PARAM_EXCEPTION_INHERIT_STD |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 109 | |
| 110 | //____________________________________________________________________________// |
| 111 | |
| 112 | # else |
| 113 | |
| 114 | typedef wchar_t char_type; |
| 115 | typedef std::basic_string<char_type> dstring; |
| 116 | typedef unit_test::basic_cstring<wchar_t const> cstring; |
| 117 | typedef const unit_test::basic_cstring<wchar_t const> literal_cstring; |
| 118 | typedef wrap_wstringstream format_stream; |
| 119 | typedef std::wostream out_stream; |
| 120 | |
| 121 | #ifndef UNDER_CE |
| 122 | inline void |
| 123 | putenv_impl( cstring name, cstring value ) |
| 124 | { |
| 125 | format_stream fs; |
| 126 | |
| 127 | fs << name << '=' << value; |
| 128 | |
| 129 | // !! this may actually fail. What should we do? |
| 130 | // const_cast is used to satisfy putenv interface |
| 131 | using namespace std; |
| 132 | wputenv( const_cast<wchar_t*>( fs.str().c_str() ) ); |
| 133 | } |
| 134 | #endif |
| 135 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 136 | #define NDNBOOST_RT_PARAM_LITERAL( l ) L ## l |
| 137 | #define NDNBOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( L ## l, sizeof( L ## l )/sizeof(wchar_t) - 1 ) |
| 138 | #define NDNBOOST_RT_PARAM_GETENV wgetenv |
| 139 | #define NDNBOOST_RT_PARAM_PUTENV putenv_impl |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 140 | |
| 141 | # endif |
| 142 | #endif |
| 143 | |
| 144 | #ifdef __GNUC__ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 145 | #define NDNBOOST_RT_PARAM_UNNEEDED_VIRTUAL virtual |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 146 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 147 | #define NDNBOOST_RT_PARAM_UNNEEDED_VIRTUAL |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 148 | #endif |
| 149 | |
| 150 | //____________________________________________________________________________// |
| 151 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 152 | } // namespace NDNBOOST_RT_PARAM_NAMESPACE |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 153 | |
| 154 | } // namespace ndnboost |
| 155 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 156 | #endif // NDNBOOST_RT_CONFIG_HPP_062604GER |