~ubuntu-branches/ubuntu/wily/davix/wily

« back to all changes in this revision

Viewing changes to deps/boost_intern/boost/test/utils/runtime/cla/named_parameter.ipp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2015-07-31 13:17:55 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20150731131755-mizprbmn7ogv33te
Tags: 0.4.1-1
* Update to version 0.4.1
* Implement Multi-Arch support

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
5
 
 
6
 
//  See http://www.boost.org/libs/test for the library home page.
7
 
//
8
 
//  File        : $RCSfile$
9
 
//
10
 
//  Version     : $Revision: 54633 $
11
 
//
12
 
//  Description : implements model of named parameter
13
 
// ***************************************************************************
14
 
 
15
 
#ifndef BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER
16
 
#define BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER
17
 
 
18
 
// Boost.Runtime.Parameter
19
 
#include <boost/test/utils/runtime/config.hpp>
20
 
 
21
 
#include <boost/test/utils/runtime/cla/named_parameter.hpp>
22
 
#include <boost/test/utils/runtime/cla/char_parameter.hpp>
23
 
 
24
 
// Boost.Test
25
 
#include <boost/test/utils/algorithm.hpp>
26
 
 
27
 
namespace boost {
28
 
 
29
 
namespace BOOST_RT_PARAM_NAMESPACE {
30
 
 
31
 
namespace cla {
32
 
 
33
 
// ************************************************************************** //
34
 
// **************              string_name_policy              ************** //
35
 
// ************************************************************************** //
36
 
 
37
 
BOOST_RT_PARAM_INLINE 
38
 
string_name_policy::string_name_policy()
39
 
: basic_naming_policy( rtti::type_id<string_name_policy>() )
40
 
, m_guess_name( false )
41
 
{
42
 
    assign_op( p_prefix.value, BOOST_RT_PARAM_CSTRING_LITERAL( "-" ), 0 );
43
 
}
44
 
 
45
 
//____________________________________________________________________________//
46
 
 
47
 
BOOST_RT_PARAM_INLINE bool
48
 
string_name_policy::responds_to( cstring name ) const
49
 
{
50
 
    std::pair<cstring::iterator,dstring::const_iterator> mm_pos;
51
 
 
52
 
    mm_pos = unit_test::mismatch( name.begin(), name.end(), p_name->begin(), p_name->end() );
53
 
 
54
 
    return mm_pos.first == name.end() && (m_guess_name || (mm_pos.second == p_name->end()) );
55
 
}
56
 
 
57
 
//____________________________________________________________________________//
58
 
 
59
 
#ifdef BOOST_MSVC
60
 
#  pragma warning(push)
61
 
#  pragma warning(disable:4244)
62
 
#endif
63
 
 
64
 
BOOST_RT_PARAM_INLINE bool
65
 
string_name_policy::conflict_with( identification_policy const& id ) const
66
 
{
67
 
    if( id.p_type_id == p_type_id ) {
68
 
        string_name_policy const& snp = static_cast<string_name_policy const&>( id );
69
 
 
70
 
        if( p_name->empty() || snp.p_name->empty() )
71
 
            return false;
72
 
 
73
 
        if( p_prefix != snp.p_prefix )
74
 
            return false;
75
 
 
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() );
78
 
 
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
82
 
    }
83
 
    
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 );
86
 
 
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 ) );
90
 
    }
91
 
    
92
 
    return false;    
93
 
}
94
 
 
95
 
#ifdef BOOST_MSVC
96
 
#  pragma warning(pop)
97
 
#endif
98
 
 
99
 
//____________________________________________________________________________//
100
 
 
101
 
BOOST_RT_PARAM_INLINE bool
102
 
string_name_policy::match_name( argv_traverser& tr ) const
103
 
{
104
 
    if( !m_guess_name )
105
 
        return basic_naming_policy::match_name( tr );
106
 
 
107
 
    cstring in = tr.input();
108
 
 
109
 
    std::pair<cstring::iterator,dstring::const_iterator> mm_pos;
110
 
    
111
 
    mm_pos = unit_test::mismatch( in.begin(), in.end(), p_name->begin(), p_name->end() );
112
 
 
113
 
    if( mm_pos.first == in.begin() )
114
 
        return false;
115
 
 
116
 
    tr.trim( mm_pos.first - in.begin() );
117
 
 
118
 
    return true;
119
 
}
120
 
 
121
 
//____________________________________________________________________________//
122
 
 
123
 
} // namespace cla
124
 
 
125
 
} // namespace BOOST_RT_PARAM_NAMESPACE
126
 
 
127
 
} // namespace boost
128
 
 
129
 
#endif // BOOST_RT_CLA_NAMED_PARAMETER_IPP_062904GER