modifier.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // Use, modification, and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at 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$
  10. //
  11. // Description : parameter modifiers
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_UTILS_RUNTIME_MODIFIER_HPP
  14. #define BOOST_TEST_UTILS_RUNTIME_MODIFIER_HPP
  15. // Boost.Test Runtime parameters
  16. #include <boost/test/utils/runtime/fwd.hpp>
  17. // Boost.Test
  18. #include <boost/test/utils/named_params.hpp>
  19. #include <boost/test/detail/suppress_warnings.hpp>
  20. // New CLA API available only for some C++11 compilers
  21. #if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) \
  22. && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) \
  23. && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) \
  24. && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
  25. #define BOOST_TEST_CLA_NEW_API
  26. #endif
  27. namespace boost {
  28. namespace runtime {
  29. // ************************************************************************** //
  30. // ************** environment variable modifiers ************** //
  31. // ************************************************************************** //
  32. namespace {
  33. #ifdef BOOST_TEST_CLA_NEW_API
  34. auto const& description = unit_test::static_constant<nfp::typed_keyword<cstring,struct description_t>>::value;
  35. auto const& help = unit_test::static_constant<nfp::typed_keyword<cstring,struct help_t>>::value;
  36. auto const& env_var = unit_test::static_constant<nfp::typed_keyword<cstring,struct env_var_t>>::value;
  37. auto const& end_of_params = unit_test::static_constant<nfp::typed_keyword<cstring,struct end_of_params_t>>::value;
  38. auto const& negation_prefix = unit_test::static_constant<nfp::typed_keyword<cstring,struct neg_prefix_t>>::value;
  39. auto const& value_hint = unit_test::static_constant<nfp::typed_keyword<cstring,struct value_hint_t>>::value;
  40. auto const& optional_value = unit_test::static_constant<nfp::keyword<struct optional_value_t>>::value;
  41. auto const& default_value = unit_test::static_constant<nfp::keyword<struct default_value_t>>::value;
  42. auto const& callback = unit_test::static_constant<nfp::keyword<struct callback_t>>::value;
  43. template<typename EnumType>
  44. using enum_values = unit_test::static_constant<
  45. nfp::typed_keyword<std::initializer_list<std::pair<const cstring,EnumType>>, struct enum_values_t>
  46. >;
  47. #else
  48. nfp::typed_keyword<cstring,struct description_t> description;
  49. nfp::typed_keyword<cstring,struct help_t> help;
  50. nfp::typed_keyword<cstring,struct env_var_t> env_var;
  51. nfp::typed_keyword<cstring,struct end_of_params_t> end_of_params;
  52. nfp::typed_keyword<cstring,struct neg_prefix_t> negation_prefix;
  53. nfp::typed_keyword<cstring,struct value_hint_t> value_hint;
  54. nfp::keyword<struct optional_value_t> optional_value;
  55. nfp::keyword<struct default_value_t> default_value;
  56. nfp::keyword<struct callback_t> callback;
  57. template<typename EnumType>
  58. struct enum_values_list {
  59. typedef std::pair<cstring,EnumType> ElemT;
  60. typedef std::vector<ElemT> ValuesT;
  61. enum_values_list const&
  62. operator()( cstring k, EnumType v ) const
  63. {
  64. const_cast<enum_values_list*>(this)->m_values.push_back( ElemT( k, v ) );
  65. return *this;
  66. }
  67. operator ValuesT const&() const { return m_values; }
  68. private:
  69. ValuesT m_values;
  70. };
  71. template<typename EnumType>
  72. struct enum_values : unit_test::static_constant<
  73. nfp::typed_keyword<enum_values_list<EnumType>, struct enum_values_t> >
  74. {
  75. };
  76. #endif
  77. } // local namespace
  78. } // namespace runtime
  79. } // namespace boost
  80. #include <boost/test/detail/enable_warnings.hpp>
  81. #endif // BOOST_TEST_UTILS_RUNTIME_MODIFIER_HPP