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/global_typedef.hpp>
  20. #include <boost/test/detail/suppress_warnings.hpp>
  21. // New CLA API available only for some C++11 compilers
  22. #if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) \
  23. && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) \
  24. && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) \
  25. && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
  26. #define BOOST_TEST_CLA_NEW_API
  27. #endif
  28. namespace boost {
  29. namespace runtime {
  30. // ************************************************************************** //
  31. // ************** environment variable modifiers ************** //
  32. // ************************************************************************** //
  33. namespace {
  34. #ifdef BOOST_TEST_CLA_NEW_API
  35. auto const& description = unit_test::static_constant<nfp::typed_keyword<cstring,struct description_t>>::value;
  36. auto const& help = unit_test::static_constant<nfp::typed_keyword<cstring,struct help_t>>::value;
  37. auto const& env_var = unit_test::static_constant<nfp::typed_keyword<cstring,struct env_var_t>>::value;
  38. auto const& end_of_params = unit_test::static_constant<nfp::typed_keyword<cstring,struct end_of_params_t>>::value;
  39. auto const& negation_prefix = unit_test::static_constant<nfp::typed_keyword<cstring,struct neg_prefix_t>>::value;
  40. auto const& value_hint = unit_test::static_constant<nfp::typed_keyword<cstring,struct value_hint_t>>::value;
  41. auto const& optional_value = unit_test::static_constant<nfp::keyword<struct optional_value_t>>::value;
  42. auto const& default_value = unit_test::static_constant<nfp::keyword<struct default_value_t>>::value;
  43. auto const& callback = unit_test::static_constant<nfp::keyword<struct callback_t>>::value;
  44. template<typename EnumType>
  45. using enum_values = unit_test::static_constant<
  46. nfp::typed_keyword<std::initializer_list<std::pair<const cstring,EnumType>>, struct enum_values_t>
  47. >;
  48. #else
  49. nfp::typed_keyword<cstring,struct description_t> description;
  50. nfp::typed_keyword<cstring,struct help_t> help;
  51. nfp::typed_keyword<cstring,struct env_var_t> env_var;
  52. nfp::typed_keyword<cstring,struct end_of_params_t> end_of_params;
  53. nfp::typed_keyword<cstring,struct neg_prefix_t> negation_prefix;
  54. nfp::typed_keyword<cstring,struct value_hint_t> value_hint;
  55. nfp::keyword<struct optional_value_t> optional_value;
  56. nfp::keyword<struct default_value_t> default_value;
  57. nfp::keyword<struct callback_t> callback;
  58. template<typename EnumType>
  59. struct enum_values_list {
  60. typedef std::pair<cstring,EnumType> ElemT;
  61. typedef std::vector<ElemT> ValuesT;
  62. enum_values_list const&
  63. operator()( cstring k, EnumType v ) const
  64. {
  65. const_cast<enum_values_list*>(this)->m_values.push_back( ElemT( k, v ) );
  66. return *this;
  67. }
  68. operator ValuesT const&() const { return m_values; }
  69. private:
  70. ValuesT m_values;
  71. };
  72. template<typename EnumType>
  73. struct enum_values : unit_test::static_constant<
  74. nfp::typed_keyword<enum_values_list<EnumType>, struct enum_values_t> >
  75. {
  76. };
  77. #endif
  78. } // local namespace
  79. } // namespace runtime
  80. } // namespace boost
  81. #include <boost/test/detail/enable_warnings.hpp>
  82. #endif // BOOST_TEST_UTILS_RUNTIME_MODIFIER_HPP