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: 49312 $
12
// Description : flexible configuration file iterator definition
13
// ***************************************************************************
15
#ifndef BOOST_RT_FILE_CONFIG_FILE_ITERATOR_HPP_062604GER
16
#define BOOST_RT_FILE_CONFIG_FILE_ITERATOR_HPP_062604GER
18
// Boost.Runtime.Parameter
19
#include <boost/test/utils/runtime/config.hpp>
21
#include <boost/test/utils/runtime/fwd.hpp>
24
#include <boost/test/utils/iterator/input_iterator_facade.hpp>
25
#include <boost/test/utils/callback.hpp>
26
#include <boost/test/utils/named_params.hpp>
29
#include <boost/shared_ptr.hpp>
33
namespace BOOST_RT_PARAM_NAMESPACE {
38
typedef std::pair<dstring,long> location;
40
// ************************************************************************** //
41
// ************** modifiers ************** //
42
// ************************************************************************** //
44
namespace cfg_detail {
45
struct path_separators_t;
46
struct line_delimeter_t;
47
struct sl_comment_delimeter_t;
48
struct command_delimeter_t;
50
struct macro_ref_begin_t;
51
struct macro_ref_end_t;
62
struct trim_leading_spaces_t;
63
struct trim_trailing_spaces_t;
64
struct skip_empty_lines_t;
65
struct detect_missing_macro_t;
66
} // namespace cfg_detail
70
nfp::typed_keyword<cstring,cfg_detail::path_separators_t> path_separators;
71
nfp::typed_keyword<char_type ,cfg_detail::line_delimeter_t> line_delimeter;
72
nfp::typed_keyword<cstring,cfg_detail::sl_comment_delimeter_t> single_line_comment_delimeter;
73
nfp::typed_keyword<cstring,cfg_detail::command_delimeter_t> command_delimeter;
74
nfp::typed_keyword<cstring,cfg_detail::line_beak_t> line_beak;
75
nfp::typed_keyword<cstring,cfg_detail::macro_ref_begin_t> macro_ref_begin;
76
nfp::typed_keyword<cstring,cfg_detail::macro_ref_end_t> macro_ref_end;
77
nfp::typed_keyword<cstring,cfg_detail::include_kw_t> include_kw;
78
nfp::typed_keyword<cstring,cfg_detail::define_kw_t> define_kw;
79
nfp::typed_keyword<cstring,cfg_detail::undef_kw_t> undef_kw;
80
nfp::typed_keyword<cstring,cfg_detail::ifdef_kw_t> ifdef_kw;
81
nfp::typed_keyword<cstring,cfg_detail::ifndef_kw_t> ifndef_kw;
82
nfp::typed_keyword<cstring,cfg_detail::else_kw_t> else_kw;
83
nfp::typed_keyword<cstring,cfg_detail::endif_kw_t> endif_kw;
85
nfp::typed_keyword<std::size_t,cfg_detail::buffer_size_t> buffer_size;
87
nfp::typed_keyword<bool,cfg_detail::trim_leading_spaces_t> trim_leading_spaces;
88
nfp::typed_keyword<bool,cfg_detail::trim_trailing_spaces_t> trim_trailing_spaces;
89
nfp::typed_keyword<bool,cfg_detail::skip_empty_lines_t> skip_empty_lines;
90
nfp::typed_keyword<bool,cfg_detail::detect_missing_macro_t> detect_missing_macro;
94
// ************************************************************************** //
95
// ************** runtime::file::config_file_iterator ************** //
96
// ************************************************************************** //
98
class config_file_iterator : public unit_test::input_iterator_facade<config_file_iterator,cstring,cstring> {
99
typedef unit_test::input_iterator_facade<config_file_iterator,cstring,cstring> base;
102
typedef unit_test::callback1<cstring> command_handler;
105
config_file_iterator() {}
106
explicit config_file_iterator( cstring file_name )
111
template<typename Modifiers>
112
config_file_iterator( cstring file_name, Modifiers const& m )
118
config_file_iterator( config_file_iterator const& rhs )
120
, m_pimpl( rhs.m_pimpl )
125
void operator=( config_file_iterator const& rhs )
130
(base&)(*this) = rhs;
131
m_pimpl = rhs.m_pimpl;
137
location const& curr_location();
138
void register_command_handler( cstring command_kw, command_handler const& );
140
// Parameters setters
141
void set_parameter( rtti::id_t, cstring );
142
void set_parameter( rtti::id_t, bool );
143
void set_parameter( rtti::id_t, char_type );
144
void set_parameter( rtti::id_t, std::size_t );
147
friend class unit_test::input_iterator_core_access;
150
void load( cstring file_name );
152
// increment implementation
157
shared_ptr<Impl> m_pimpl;
162
} // namespace BOOST_RT_PARAM_NAMESPACE
166
#endif // BOOST_RT_FILE_CONFIG_FILE_ITERATOR_HPP_062604GER