named_parameter.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // (C) Copyright Gennadiy Rozental 2005-2008.
  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: 49312 $
  10. //
  11. // Description : defines model of named parameter
  12. // ***************************************************************************
  13. #ifndef BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER
  14. #define BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER
  15. // Boost.Runtime.Parameter
  16. #include <boost/test/utils/runtime/config.hpp>
  17. #include <boost/test/utils/runtime/cla/basic_parameter.hpp>
  18. #include <boost/test/utils/runtime/cla/id_policy.hpp>
  19. namespace boost {
  20. namespace BOOST_RT_PARAM_NAMESPACE {
  21. namespace cla {
  22. // ************************************************************************** //
  23. // ************** string_name_policy ************** //
  24. // ************************************************************************** //
  25. class string_name_policy : public basic_naming_policy {
  26. public:
  27. // Constructor
  28. string_name_policy();
  29. BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~string_name_policy() {}
  30. // policy interface
  31. virtual bool responds_to( cstring name ) const;
  32. virtual bool conflict_with( identification_policy const& ) const;
  33. // Accept modifier
  34. template<typename Modifier>
  35. void accept_modifier( Modifier const& m )
  36. {
  37. basic_naming_policy::accept_modifier( m );
  38. if( m.has( guess_name_m ) )
  39. m_guess_name = true;
  40. }
  41. private:
  42. // Naming policy interface
  43. virtual bool match_name( argv_traverser& tr ) const;
  44. // Data members
  45. bool m_guess_name;
  46. };
  47. // ************************************************************************** //
  48. // ************** runtime::cla::named_parameter ************** //
  49. // ************************************************************************** //
  50. template<typename T>
  51. class named_parameter_t : public basic_parameter<T,string_name_policy> {
  52. typedef basic_parameter<T,string_name_policy> base;
  53. public:
  54. // Constructors
  55. explicit named_parameter_t( cstring name ) : base( name ) {}
  56. };
  57. //____________________________________________________________________________//
  58. BOOST_RT_CLA_NAMED_PARAM_GENERATORS( named_parameter )
  59. //____________________________________________________________________________//
  60. } // namespace cla
  61. } // namespace BOOST_RT_PARAM_NAMESPACE
  62. } // namespace boost
  63. #ifndef BOOST_RT_PARAM_OFFLINE
  64. # define BOOST_RT_PARAM_INLINE inline
  65. # include <boost/test/utils/runtime/cla/named_parameter.ipp>
  66. #endif
  67. #endif // BOOST_RT_CLA_NAMED_PARAMETER_HPP_062604GER