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: 54633 $
12
// Description : implements model of named parameter
13
// ***************************************************************************
15
#ifndef BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER
16
#define BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER
18
// Boost.Runtime.Parameter
19
#include <boost/test/utils/runtime/config.hpp>
21
#include <boost/test/utils/runtime/cla/named_parameter.hpp>
22
#include <boost/test/utils/runtime/cla/char_parameter.hpp>
25
#include <boost/test/utils/algorithm.hpp>
29
namespace BOOST_RT_PARAM_NAMESPACE {
33
// ************************************************************************** //
34
// ************** string_name_policy ************** //
35
// ************************************************************************** //
38
string_name_policy::string_name_policy()
39
: basic_naming_policy( rtti::type_id<string_name_policy>() )
40
, m_guess_name( false )
42
assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 );
45
//____________________________________________________________________________//
47
BOOST_RT_PARAM_INLINE bool
48
string_name_policy::responds_to( cstring name ) const
50
std::pair<cstring::iterator,dstring::const_iterator> mm_pos;
52
mm_pos = unit_test::mismatch( name.begin(), name.end(), p_name->begin(), p_name->end() );
54
return mm_pos.first == name.end() && (m_guess_name || (mm_pos.second == p_name->end()) );
57
//____________________________________________________________________________//
60
# pragma warning(push)
61
# pragma warning(disable:4244)
64
BOOST_RT_PARAM_INLINE bool
65
string_name_policy::conflict_with( identification_policy const& id ) const
67
if( id.p_type_id == p_type_id ) {
68
string_name_policy const& snp = static_cast<string_name_policy const&>( id );
70
if( p_name->empty() || snp.p_name->empty() )
73
if( p_prefix != snp.p_prefix )
76
std::pair<dstring::const_iterator,dstring::const_iterator> mm_pos =
77
unit_test::mismatch( p_name->begin(), p_name->end(), snp.p_name->begin(), snp.p_name->end() );
79
return mm_pos.first != p_name->begin() && // there is common substring
80
((m_guess_name && (mm_pos.second == snp.p_name->end()) ) || // that match other guy and I am guessing
81
(snp.m_guess_name && (mm_pos.first == p_name->end()) )); // or me and the other guy is
84
if( id.p_type_id == rtti::type_id<char_name_policy>() ) {
85
char_name_policy const& cnp = static_cast<char_name_policy const&>( id );
87
return m_guess_name &&
88
(p_prefix == cnp.p_prefix) &&
89
unit_test::first_char( cstring( p_name ) ) == unit_test::first_char( cstring( cnp.p_name ) );
99
//____________________________________________________________________________//
101
BOOST_RT_PARAM_INLINE bool
102
string_name_policy::match_name( argv_traverser& tr ) const
105
return basic_naming_policy::match_name( tr );
107
cstring in = tr.input();
109
std::pair<cstring::iterator,dstring::const_iterator> mm_pos;
111
mm_pos = unit_test::mismatch( in.begin(), in.end(), p_name->begin(), p_name->end() );
113
if( mm_pos.first == in.begin() )
116
tr.trim( mm_pos.first - in.begin() );
121
//____________________________________________________________________________//
125
} // namespace BOOST_RT_PARAM_NAMESPACE
129
#endif // BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER