source: NonGTP/Boost/boost/test/utils/runtime/cla/char_parameter.hpp @ 857

Revision 857, 3.5 KB checked in by igarcia, 18 years ago (diff)
Line 
1//  (C) Copyright Gennadiy Rozental 2005.
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
6//  See http://www.boost.org/libs/test for the library home page.
7//
8//  File        : $RCSfile: char_parameter.hpp,v $
9//
10//  Version     : $Revision: 1.1 $
11//
12//  Description : defines model of parameter with single char name
13// ***************************************************************************
14
15#ifndef BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
16#define BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
17
18// Boost.Runtime.Parameter
19#include <boost/test/utils/runtime/config.hpp>
20#include <boost/test/utils/runtime/validation.hpp>
21
22#include <boost/test/utils/runtime/cla/basic_parameter.hpp>
23#include <boost/test/utils/runtime/cla/id_policy.hpp>
24
25namespace boost {
26
27namespace BOOST_RT_PARAM_NAMESPACE {
28
29namespace cla {
30
31// ************************************************************************** //
32// **************               char_name_policy               ************** //
33// ************************************************************************** //
34
35class char_name_policy : public basic_naming_policy {
36public:
37    // Constructor
38    char_name_policy();
39    BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~char_name_policy() {}
40
41    // policy interface
42    virtual bool    conflict_with( identification_policy const& ) const;
43
44    // Accept modifier
45    template<typename Modifier>
46    void            accept_modifier( Modifier const& m )
47    {
48        basic_naming_policy::accept_modifier( m );
49
50        BOOST_RT_PARAM_VALIDATE_LOGIC( m_name.size() <= 1, "Invalid parameter name "  << m_name );
51    }
52};
53
54// ************************************************************************** //
55// **************          runtime::cla::char_parameter        ************** //
56// ************************************************************************** //
57
58template<typename T>
59class char_parameter_t : public basic_parameter<T,char_name_policy> {
60    typedef basic_parameter<T,char_name_policy> base;
61public:
62    // Constructors
63    explicit    char_parameter_t( char_type name ) : base( cstring( &name, 1 ) ) {}
64};
65
66//____________________________________________________________________________//
67
68template<typename T>
69inline shared_ptr<char_parameter_t<T> >
70char_parameter( char_type name )
71{
72    return shared_ptr<char_parameter_t<T> >( new char_parameter_t<T>( name ) );
73}
74
75//____________________________________________________________________________//
76
77inline shared_ptr<char_parameter_t<cstring> >
78char_parameter( char_type name )
79{
80    return shared_ptr<char_parameter_t<cstring> >( new char_parameter_t<cstring>( name ) );
81}
82
83//____________________________________________________________________________//
84
85} // namespace cla
86
87} // namespace BOOST_RT_PARAM_NAMESPACE
88
89} // namespace boost
90
91#ifndef BOOST_RT_PARAM_OFFLINE
92
93#  define BOOST_RT_PARAM_INLINE inline
94#  include <boost/test/utils/runtime/cla/char_parameter.ipp>
95
96#endif
97
98// ************************************************************************** //
99//   Revision History:
100//
101//   $Log: char_parameter.hpp,v $
102//   Revision 1.1  2005/04/12 06:42:43  rogeeff
103//   Runtime.Param library initial commit
104//
105// ************************************************************************** //
106
107#endif // BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
Note: See TracBrowser for help on using the repository browser.