1//  (C) Copyright Gennadiy Rozental 2005-2014.
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$
11//
12//  Description : implements model of generic parameter with dual naming
13// ***************************************************************************
14
15#ifndef BOOST_TEST_UTILS_RUNTIME_CLA_DUAL_NAME_PARAMETER_IPP
16#define BOOST_TEST_UTILS_RUNTIME_CLA_DUAL_NAME_PARAMETER_IPP
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
24namespace boost {
25
26namespace BOOST_TEST_UTILS_RUNTIME_PARAM_NAMESPACE {
27
28namespace cla {
29
30// ************************************************************************** //
31// **************               dual_name_policy               ************** //
32// ************************************************************************** //
33
34BOOST_TEST_UTILS_RUNTIME_PARAM_INLINE
35dual_name_policy::dual_name_policy()
36{
37    m_primary.accept_modifier( prefix = BOOST_TEST_UTILS_RUNTIME_PARAM_CSTRING_LITERAL( "--" ) );
38    m_secondary.accept_modifier( prefix = BOOST_TEST_UTILS_RUNTIME_PARAM_CSTRING_LITERAL( "-" ) );
39}
40
41//____________________________________________________________________________//
42
43namespace {
44
45template<typename K>
46inline void
47split( 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_TEST_UTILS_RUNTIME_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
60BOOST_TEST_UTILS_RUNTIME_PARAM_INLINE void
61dual_name_policy::set_prefix( cstring src )
62{
63    split( m_primary, m_secondary, src, prefix );
64}
65
66//____________________________________________________________________________//
67
68BOOST_TEST_UTILS_RUNTIME_PARAM_INLINE void
69dual_name_policy::set_name( cstring src )
70{
71    split( m_primary, m_secondary, src, name );
72}
73
74//____________________________________________________________________________//
75
76BOOST_TEST_UTILS_RUNTIME_PARAM_INLINE void
77dual_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_TEST_UTILS_RUNTIME_PARAM_NAMESPACE
87
88} // namespace boost
89
90#endif // BOOST_TEST_UTILS_RUNTIME_CLA_DUAL_NAME_PARAMETER_IPP
91