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)
6
// See http://www.boost.org/libs/test for the library home page.
10
// Version : $Revision: 57992 $
12
// Description : defines parser - public interface for CLA parsing and accessing
13
// ***************************************************************************
15
#ifndef BOOST_RT_CLA_PARSER_HPP_062604GER
16
#define BOOST_RT_CLA_PARSER_HPP_062604GER
18
// Boost.Runtime.Parameter
19
#include <boost/test/utils/runtime/config.hpp>
20
#include <boost/test/utils/runtime/fwd.hpp>
21
#include <boost/test/utils/runtime/argument.hpp>
23
#include <boost/test/utils/runtime/cla/fwd.hpp>
24
#include <boost/test/utils/runtime/cla/modifier.hpp>
25
#include <boost/test/utils/runtime/cla/argv_traverser.hpp>
28
#include <boost/optional.hpp>
35
namespace BOOST_RT_PARAM_NAMESPACE {
39
// ************************************************************************** //
40
// ************** runtime::cla::parser ************** //
41
// ************************************************************************** //
43
namespace cla_detail {
45
template<typename Modifier>
46
class global_mod_parser {
48
global_mod_parser( parser& p, Modifier const& m )
53
template<typename Param>
54
global_mod_parser const&
55
operator<<( shared_ptr<Param> param ) const
57
param->accept_modifier( m_modifiers );
67
Modifier const& m_modifiers;
72
// ************************************************************************** //
73
// ************** runtime::cla::parser ************** //
74
// ************************************************************************** //
78
typedef std::list<parameter_ptr>::const_iterator param_iterator;
81
explicit parser( cstring program_name = cstring() );
83
// parameter list construction interface
84
parser& operator<<( parameter_ptr param );
86
// parser and global parameters modifiers
87
template<typename Modifier>
88
cla_detail::global_mod_parser<Modifier>
89
operator-( Modifier const& m )
91
nfp::optionally_assign( m_traverser.p_separator.value, m, input_separator );
92
nfp::optionally_assign( m_traverser.p_ignore_mismatch.value, m, ignore_mismatch_m );
94
return cla_detail::global_mod_parser<Modifier>( *this, m );
97
// input processing method
98
void parse( int& argc, char_type** argv );
101
param_iterator first_param() const;
102
param_iterator last_param() const;
105
const_argument_ptr operator[]( cstring string_id ) const;
106
cstring get( cstring string_id ) const;
109
T const& get( cstring string_id ) const
111
return arg_value<T>( valid_argument( string_id ) );
115
void get( cstring string_id, boost::optional<T>& res ) const
117
const_argument_ptr actual_arg = (*this)[string_id];
120
res = arg_value<T>( *actual_arg );
126
void usage( out_stream& ostr );
127
void help( out_stream& ostr );
130
argument const& valid_argument( cstring string_id ) const;
133
argv_traverser m_traverser;
134
std::list<parameter_ptr> m_parameters;
135
dstring m_program_name;
138
//____________________________________________________________________________//
142
} // namespace BOOST_RT_PARAM_NAMESPACE
146
#ifndef BOOST_RT_PARAM_OFFLINE
148
# define BOOST_RT_PARAM_INLINE inline
149
# include <boost/test/utils/runtime/cla/parser.ipp>
153
#endif // BOOST_RT_CLA_PARSER_HPP_062604GER