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: dual_name_parameter.ipp,v $
|
---|
9 | //
|
---|
10 | // Version : $Revision: 1.1 $
|
---|
11 | //
|
---|
12 | // Description : implements model of generic parameter with dual naming
|
---|
13 | // ***************************************************************************
|
---|
14 |
|
---|
15 | #ifndef BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER
|
---|
16 | #define BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER
|
---|
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/dual_name_parameter.hpp>
|
---|
23 |
|
---|
24 | namespace boost {
|
---|
25 |
|
---|
26 | namespace BOOST_RT_PARAM_NAMESPACE {
|
---|
27 |
|
---|
28 | namespace cla {
|
---|
29 |
|
---|
30 | // ************************************************************************** //
|
---|
31 | // ************** dual_name_policy ************** //
|
---|
32 | // ************************************************************************** //
|
---|
33 |
|
---|
34 | BOOST_RT_PARAM_INLINE
|
---|
35 | dual_name_policy::dual_name_policy()
|
---|
36 | {
|
---|
37 | m_primary.accept_modifier( prefix = BOOST_RT_PARAM_CSTRING_LITERAL( "--" ) );
|
---|
38 | m_secondary.accept_modifier( prefix = BOOST_RT_PARAM_CSTRING_LITERAL( "-" ) );
|
---|
39 | }
|
---|
40 |
|
---|
41 | //____________________________________________________________________________//
|
---|
42 |
|
---|
43 | namespace {
|
---|
44 |
|
---|
45 | template<typename K>
|
---|
46 | inline void
|
---|
47 | split( string_name_policy& snp, char_name_policy& cnp, cstring src, K const& k )
|
---|
48 | {
|
---|
49 | cstring::iterator sep = std::find( src.begin(), src.end(), BOOST_RT_PARAM_LITERAL( '|' ) );
|
---|
50 |
|
---|
51 | if( sep != src.begin() )
|
---|
52 | snp.accept_modifier( k = cstring( src.begin(), sep ) );
|
---|
53 |
|
---|
54 | if( sep != src.end() )
|
---|
55 | cnp.accept_modifier( k = cstring( sep+1, src.end() ) );
|
---|
56 | }
|
---|
57 |
|
---|
58 | } // local namespace
|
---|
59 |
|
---|
60 | BOOST_RT_PARAM_INLINE void
|
---|
61 | dual_name_policy::set_prefix( cstring src )
|
---|
62 | {
|
---|
63 | split( m_primary, m_secondary, src, prefix );
|
---|
64 | }
|
---|
65 |
|
---|
66 | //____________________________________________________________________________//
|
---|
67 |
|
---|
68 | BOOST_RT_PARAM_INLINE void
|
---|
69 | dual_name_policy::set_name( cstring src )
|
---|
70 | {
|
---|
71 | split( m_primary, m_secondary, src, name );
|
---|
72 | }
|
---|
73 |
|
---|
74 | //____________________________________________________________________________//
|
---|
75 |
|
---|
76 | BOOST_RT_PARAM_INLINE void
|
---|
77 | dual_name_policy::set_separator( cstring src )
|
---|
78 | {
|
---|
79 | split( m_primary, m_secondary, src, separator );
|
---|
80 | }
|
---|
81 |
|
---|
82 | //____________________________________________________________________________//
|
---|
83 |
|
---|
84 | } // namespace cla
|
---|
85 |
|
---|
86 | } // namespace BOOST_RT_PARAM_NAMESPACE
|
---|
87 |
|
---|
88 | } // namespace boost
|
---|
89 |
|
---|
90 | // ************************************************************************** //
|
---|
91 | // Revision History:
|
---|
92 | //
|
---|
93 | // $Log: dual_name_parameter.ipp,v $
|
---|
94 | // Revision 1.1 2005/04/12 06:42:43 rogeeff
|
---|
95 | // Runtime.Param library initial commit
|
---|
96 | //
|
---|
97 | // ************************************************************************** //
|
---|
98 |
|
---|
99 | #endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER
|
---|