blob: f5f8f1718d6944c5ad0c4529561df165364da1a6 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (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 Thompson3d613fd2013-10-15 15:39:04 -070015#ifndef NDNBOOST_RT_CONFIG_HPP_062604GER
16#define NDNBOOST_RT_CONFIG_HPP_062604GER
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070017
18// Boost
19#include <ndnboost/config.hpp>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070020#ifdef NDNBOOST_MSVC
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070021# 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 Thompson3d613fd2013-10-15 15:39:04 -070039#ifndef NDNBOOST_RT_PARAM_CUSTOM_STRING
40# ifndef NDNBOOST_RT_PARAM_WIDE_STRING
41# define NDNBOOST_RT_PARAM_NAMESPACE runtime
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070042# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070043# define NDNBOOST_RT_PARAM_NAMESPACE wide_runtime
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070044# endif
45#endif
46
47#ifdef __SUNPRO_CC
48extern int putenv(char*);
49#endif
50
51namespace ndnboost {
52
Jeff Thompson3d613fd2013-10-15 15:39:04 -070053namespace NDNBOOST_RT_PARAM_NAMESPACE {
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070054
Jeff Thompson3d613fd2013-10-15 15:39:04 -070055#ifndef NDNBOOST_RT_PARAM_CUSTOM_STRING
56# ifndef NDNBOOST_RT_PARAM_WIDE_STRING
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070057
58typedef char char_type;
59typedef std::string dstring;
60typedef unit_test::const_string cstring;
61typedef unit_test::literal_string literal_cstring;
62typedef wrap_stringstream format_stream;
63
Jeff Thompson3d613fd2013-10-15 15:39:04 -070064#ifdef NDNBOOST_CLASSIC_IOSTREAMS
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070065typedef std::ostream out_stream;
66#else
67typedef std::basic_ostream<char_type> out_stream;
68#endif
69
Jeff Thompson3d613fd2013-10-15 15:39:04 -070070#ifdef NDNBOOST_MSVC
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070071#pragma warning(push)
72#pragma warning(disable:4996) // putenv
73#endif
74
75#ifndef UNDER_CE
76#if defined(__COMO__) && 0
77inline void
78putenv_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
85inline void
86putenv_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 Thompson3d613fd2013-10-15 15:39:04 -0700100#ifdef NDNBOOST_MSVC
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700101#pragma warning(pop)
102#endif
103
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700104#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 Thompsonef2d5a42013-08-22 19:09:24 -0700109
110//____________________________________________________________________________//
111
112# else
113
114typedef wchar_t char_type;
115typedef std::basic_string<char_type> dstring;
116typedef unit_test::basic_cstring<wchar_t const> cstring;
117typedef const unit_test::basic_cstring<wchar_t const> literal_cstring;
118typedef wrap_wstringstream format_stream;
119typedef std::wostream out_stream;
120
121#ifndef UNDER_CE
122inline void
123putenv_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 Thompson3d613fd2013-10-15 15:39:04 -0700136#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 Thompsonef2d5a42013-08-22 19:09:24 -0700140
141# endif
142#endif
143
144#ifdef __GNUC__
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700145#define NDNBOOST_RT_PARAM_UNNEEDED_VIRTUAL virtual
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700146#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700147#define NDNBOOST_RT_PARAM_UNNEEDED_VIRTUAL
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700148#endif
149
150//____________________________________________________________________________//
151
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700152} // namespace NDNBOOST_RT_PARAM_NAMESPACE
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700153
154} // namespace ndnboost
155
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700156#endif // NDNBOOST_RT_CONFIG_HPP_062604GER