modifier.hpp 3.6 KB

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