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 
15 #ifndef BOOST_RT_CONFIG_HPP_062604GER
16 #define BOOST_RT_CONFIG_HPP_062604GER
17 
18 // Boost
19 #include <boost/config.hpp>
20 #ifdef BOOST_MSVC
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 <boost/test/detail/config.hpp>
29 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
30 #include <boost/test/utils/wrap_stringstream.hpp>
31 #include <boost/test/utils/basic_cstring/io.hpp> // operator<<(boost::runtime::cstring)
32 
33 // STL
34 #include <string>
35 #include <cstdlib>
36 
37 //____________________________________________________________________________//
38 
39 #ifndef BOOST_RT_PARAM_CUSTOM_STRING
40 #  ifndef BOOST_RT_PARAM_WIDE_STRING
41 #    define BOOST_RT_PARAM_NAMESPACE                            runtime
42 #  else
43 #    define BOOST_RT_PARAM_NAMESPACE                            wide_runtime
44 #  endif
45 #endif
46 
47 #ifdef __SUNPRO_CC
48 extern int putenv(char*);
49 #endif
50 
51 namespace boost {
52 
53 namespace BOOST_RT_PARAM_NAMESPACE {
54 
55 #ifndef BOOST_RT_PARAM_CUSTOM_STRING
56 #  ifndef BOOST_RT_PARAM_WIDE_STRING
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 
64 #ifdef BOOST_CLASSIC_IOSTREAMS
65 typedef std::ostream                                            out_stream;
66 #else
67 typedef std::basic_ostream<char_type>                           out_stream;
68 #endif
69 
70 #ifdef BOOST_MSVC
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
putenv_impl(cstring name,cstring value)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
putenv_impl(cstring name,cstring value)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 
100 #ifdef BOOST_MSVC
101 #pragma warning(pop)
102 #endif
103 
104 #define BOOST_RT_PARAM_LITERAL( l ) l
105 #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( l, sizeof( l ) - 1 )
106 #define BOOST_RT_PARAM_GETENV getenv
107 #define BOOST_RT_PARAM_PUTENV ::boost::BOOST_RT_PARAM_NAMESPACE::putenv_impl
108 #define BOOST_RT_PARAM_EXCEPTION_INHERIT_STD
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 
136 #define BOOST_RT_PARAM_LITERAL( l ) L ## l
137 #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( L ## l, sizeof( L ## l )/sizeof(wchar_t) - 1 )
138 #define BOOST_RT_PARAM_GETENV wgetenv
139 #define BOOST_RT_PARAM_PUTENV putenv_impl
140 
141 #  endif
142 #endif
143 
144 #ifdef __GNUC__
145 #define BOOST_RT_PARAM_UNNEEDED_VIRTUAL virtual
146 #else
147 #define BOOST_RT_PARAM_UNNEEDED_VIRTUAL
148 #endif
149 
150 //____________________________________________________________________________//
151 
152 } // namespace BOOST_RT_PARAM_NAMESPACE
153 
154 } // namespace boost
155 
156 #endif // BOOST_RT_CONFIG_HPP_062604GER
157