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

Revision 857, 3.4 KB checked in by igarcia, 19 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: positional_parameter.hpp,v $
9//
10//  Version     : $Revision: 1.1 $
11//
12//  Description : positional parameter model
13// ***************************************************************************
14
15#ifndef BOOST_RT_CLA_POSITIONAL_PARAMETER_HPP_062604GER
16#define BOOST_RT_CLA_POSITIONAL_PARAMETER_HPP_062604GER
17
18// Boost.Runtime.Parameter
19#include <boost/test/utils/runtime/config.hpp>
20
21#include <boost/test/utils/runtime/cla/basic_parameter.hpp>
22
23namespace boost {
24
25namespace BOOST_RT_PARAM_NAMESPACE {
26
27namespace cla {
28
29// ************************************************************************** //
30// **************              single_name_policy              ************** //
31// ************************************************************************** //
32
33class trivial_id_policy : public identification_policy {
34public:
35    trivial_id_policy()
36    : identification_policy( rtti::type_id<trivial_id_policy>() )
37    {}
38    BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~trivial_id_policy() {}
39
40    virtual bool    responds_to( cstring name ) const                       { return m_name == name; }
41    virtual bool    conflict_with( identification_policy const& id ) const  { return false; }
42    virtual cstring id_2_report() const                                     { return m_name; }
43    virtual void    usage_info( format_stream& fs ) const
44    {
45        if( !m_name.empty() )
46            fs << BOOST_RT_PARAM_LITERAL( '<' ) << m_name << BOOST_RT_PARAM_LITERAL( '>' );
47        else
48            fs << BOOST_RT_PARAM_CSTRING_LITERAL( "<value>" );;
49    }
50
51    virtual bool    matching( parameter const& p, argv_traverser& tr, bool primary ) const
52    {
53        return primary && ( !p.has_argument() || p.p_multiplicable );
54    }
55
56    template<typename Modifier>
57    void            accept_modifier( Modifier const& m )
58    {
59        nfp::optionally_assign( m_name, m, name );
60    }
61
62private:
63    // Data members
64    dstring      m_name;
65};
66
67// ************************************************************************** //
68// **************      runtime::cla::positional_parameter      ************** //
69// ************************************************************************** //
70
71template<typename T>
72class positional_parameter_t : public basic_parameter<T,trivial_id_policy> {
73    typedef basic_parameter<T,trivial_id_policy> base;
74public:
75    // Constructors
76    explicit    positional_parameter_t( cstring name )
77    : base( name )
78    {}
79};
80
81//____________________________________________________________________________//
82
83BOOST_RT_CLA_NAMED_PARAM_GENERATORS( positional_parameter )
84
85} // namespace cla
86
87} // namespace BOOST_RT_PARAM_NAMESPACE
88
89} // namespace boost
90
91// ************************************************************************** //
92//   Revision History:
93//
94//   $Log: positional_parameter.hpp,v $
95//   Revision 1.1  2005/04/12 06:42:43  rogeeff
96//   Runtime.Param library initial commit
97//
98// ************************************************************************** //
99
100#endif // BOOST_RT_CLA_POSITIONAL_PARAMETER_HPP_062604GER
Note: See TracBrowser for help on using the repository browser.