blob: 8fcb04f0b34a310ab83049b7045ce820fe9c1aaf [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (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: 49312 $
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 <ndnboost/test/utils/runtime/config.hpp>
20#include <ndnboost/test/utils/runtime/validation.hpp>
21
22#include <ndnboost/test/utils/runtime/cla/dual_name_parameter.hpp>
23
24namespace ndnboost {
25
26namespace BOOST_RT_PARAM_NAMESPACE {
27
28namespace cla {
29
30// ************************************************************************** //
31// ************** dual_name_policy ************** //
32// ************************************************************************** //
33
34BOOST_RT_PARAM_INLINE
35dual_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
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_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
60BOOST_RT_PARAM_INLINE void
61dual_name_policy::set_prefix( cstring src )
62{
63 split( m_primary, m_secondary, src, prefix );
64}
65
66//____________________________________________________________________________//
67
68BOOST_RT_PARAM_INLINE void
69dual_name_policy::set_name( cstring src )
70{
71 split( m_primary, m_secondary, src, name );
72}
73
74//____________________________________________________________________________//
75
76BOOST_RT_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_RT_PARAM_NAMESPACE
87
88} // namespace ndnboost
89
90#endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_IPP_062904GER