config.hpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision: 57992 $
  10. //
  11. // Description : Runtime.Param library configuration
  12. // ***************************************************************************
  13. #ifndef BOOST_RT_CONFIG_HPP_062604GER
  14. #define BOOST_RT_CONFIG_HPP_062604GER
  15. // Boost
  16. #include <boost/config.hpp>
  17. #ifdef BOOST_MSVC
  18. # pragma warning(disable: 4511) // copy constructor could not be generated
  19. # pragma warning(disable: 4512) // assignment operator could not be generated
  20. # pragma warning(disable: 4181) // qualifier applied to reference type; ignored
  21. # pragma warning(disable: 4675) // resolved overload was found by argument-dependent lookup
  22. #endif
  23. // Boost.Test
  24. #include <boost/test/detail/config.hpp>
  25. #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
  26. #include <boost/test/utils/wrap_stringstream.hpp>
  27. #include <boost/test/utils/basic_cstring/io.hpp> // operator<<(boost::runtime::cstring)
  28. // STL
  29. #include <string>
  30. #include <cstdlib>
  31. //____________________________________________________________________________//
  32. #ifndef BOOST_RT_PARAM_CUSTOM_STRING
  33. # ifndef BOOST_RT_PARAM_WIDE_STRING
  34. # define BOOST_RT_PARAM_NAMESPACE runtime
  35. # else
  36. # define BOOST_RT_PARAM_NAMESPACE wide_runtime
  37. # endif
  38. #endif
  39. #ifdef __SUNPRO_CC
  40. extern int putenv(char*);
  41. #endif
  42. namespace boost {
  43. namespace BOOST_RT_PARAM_NAMESPACE {
  44. #ifndef BOOST_RT_PARAM_CUSTOM_STRING
  45. # ifndef BOOST_RT_PARAM_WIDE_STRING
  46. typedef char char_type;
  47. typedef std::string dstring;
  48. typedef unit_test::const_string cstring;
  49. typedef unit_test::literal_string literal_cstring;
  50. typedef wrap_stringstream format_stream;
  51. #ifdef BOOST_CLASSIC_IOSTREAMS
  52. typedef std::ostream out_stream;
  53. #else
  54. typedef std::basic_ostream<char_type> out_stream;
  55. #endif
  56. #ifdef BOOST_MSVC
  57. #pragma warning(push)
  58. #pragma warning(disable:4996) // putenv
  59. #endif
  60. #ifndef UNDER_CE
  61. #if defined(__COMO__) && 0
  62. inline void
  63. putenv_impl( cstring name, cstring value )
  64. {
  65. using namespace std;
  66. // !! this may actually fail. What should we do?
  67. setenv( name.begin(), value.begin(), 1 );
  68. }
  69. #else
  70. inline void
  71. putenv_impl( cstring name, cstring value )
  72. {
  73. format_stream fs;
  74. fs << name << '=' << value;
  75. // !! this may actually fail. What should we do?
  76. // const_cast is used to satisfy putenv interface
  77. using namespace std;
  78. putenv( const_cast<char*>( fs.str().c_str() ) );
  79. }
  80. #endif
  81. #endif
  82. #ifdef BOOST_MSVC
  83. #pragma warning(pop)
  84. #endif
  85. #define BOOST_RT_PARAM_LITERAL( l ) l
  86. #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( l, sizeof( l ) - 1 )
  87. #define BOOST_RT_PARAM_GETENV getenv
  88. #define BOOST_RT_PARAM_PUTENV ::boost::BOOST_RT_PARAM_NAMESPACE::putenv_impl
  89. #define BOOST_RT_PARAM_EXCEPTION_INHERIT_STD
  90. //____________________________________________________________________________//
  91. # else
  92. typedef wchar_t char_type;
  93. typedef std::basic_string<char_type> dstring;
  94. typedef unit_test::basic_cstring<wchar_t const> cstring;
  95. typedef const unit_test::basic_cstring<wchar_t const> literal_cstring;
  96. typedef wrap_wstringstream format_stream;
  97. typedef std::wostream out_stream;
  98. #ifndef UNDER_CE
  99. inline void
  100. putenv_impl( cstring name, cstring value )
  101. {
  102. format_stream fs;
  103. fs << name << '=' << value;
  104. // !! this may actually fail. What should we do?
  105. // const_cast is used to satisfy putenv interface
  106. using namespace std;
  107. wputenv( const_cast<wchar_t*>( fs.str().c_str() ) );
  108. }
  109. #endif
  110. #define BOOST_RT_PARAM_LITERAL( l ) L ## l
  111. #define BOOST_RT_PARAM_CSTRING_LITERAL( l ) cstring( L ## l, sizeof( L ## l )/sizeof(wchar_t) - 1 )
  112. #define BOOST_RT_PARAM_GETENV wgetenv
  113. #define BOOST_RT_PARAM_PUTENV putenv_impl
  114. # endif
  115. #endif
  116. #ifdef __GNUC__
  117. #define BOOST_RT_PARAM_UNNEEDED_VIRTUAL virtual
  118. #else
  119. #define BOOST_RT_PARAM_UNNEEDED_VIRTUAL
  120. #endif
  121. //____________________________________________________________________________//
  122. } // namespace BOOST_RT_PARAM_NAMESPACE
  123. } // namespace boost
  124. #endif // BOOST_RT_CONFIG_HPP_062604GER