// (C) Copyright Gennadiy Rozental 2005-2008. // Use, modification, and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/test for the library home page. // // File : $RCSfile$ // // Version : $Revision: 49312 $ // // Description : flexible configuration file iterator definition // *************************************************************************** #ifndef BOOST_RT_FILE_CONFIG_FILE_ITERATOR_HPP_062604GER #define BOOST_RT_FILE_CONFIG_FILE_ITERATOR_HPP_062604GER // Boost.Runtime.Parameter #include #include // Boost.Test #include #include #include // Boost #include namespace boost { namespace BOOST_RT_PARAM_NAMESPACE { namespace file { // Public typedef typedef std::pair location; // ************************************************************************** // // ************** modifiers ************** // // ************************************************************************** // namespace cfg_detail { struct path_separators_t; struct line_delimeter_t; struct sl_comment_delimeter_t; struct command_delimeter_t; struct line_beak_t; struct macro_ref_begin_t; struct macro_ref_end_t; struct include_kw_t; struct define_kw_t; struct undef_kw_t; struct ifdef_kw_t; struct ifndef_kw_t; struct else_kw_t; struct endif_kw_t; struct buffer_size_t; struct trim_leading_spaces_t; struct trim_trailing_spaces_t; struct skip_empty_lines_t; struct detect_missing_macro_t; } // namespace cfg_detail namespace { nfp::typed_keyword path_separators; nfp::typed_keyword line_delimeter; nfp::typed_keyword single_line_comment_delimeter; nfp::typed_keyword command_delimeter; nfp::typed_keyword line_beak; nfp::typed_keyword macro_ref_begin; nfp::typed_keyword macro_ref_end; nfp::typed_keyword include_kw; nfp::typed_keyword define_kw; nfp::typed_keyword undef_kw; nfp::typed_keyword ifdef_kw; nfp::typed_keyword ifndef_kw; nfp::typed_keyword else_kw; nfp::typed_keyword endif_kw; nfp::typed_keyword buffer_size; nfp::typed_keyword trim_leading_spaces; nfp::typed_keyword trim_trailing_spaces; nfp::typed_keyword skip_empty_lines; nfp::typed_keyword detect_missing_macro; } // local namespace // ************************************************************************** // // ************** runtime::file::config_file_iterator ************** // // ************************************************************************** // class config_file_iterator : public unit_test::input_iterator_facade { typedef unit_test::input_iterator_facade base; public: // Public typedefs typedef unit_test::callback1 command_handler; // Constructors config_file_iterator() {} explicit config_file_iterator( cstring file_name ) { construct(); load( file_name ); } template config_file_iterator( cstring file_name, Modifiers const& m ) { construct(); m.apply_to( *this ); load( file_name ); } config_file_iterator( config_file_iterator const& rhs ) : base( rhs ) , m_pimpl( rhs.m_pimpl ) { rhs.m_valid = false; } void operator=( config_file_iterator const& rhs ) { if( this == &rhs ) return; (base&)(*this) = rhs; m_pimpl = rhs.m_pimpl; rhs.m_valid = false; } // Assignment // Access methods location const& curr_location(); void register_command_handler( cstring command_kw, command_handler const& ); // Parameters setters void set_parameter( rtti::id_t, cstring ); void set_parameter( rtti::id_t, bool ); void set_parameter( rtti::id_t, char_type ); void set_parameter( rtti::id_t, std::size_t ); private: friend class unit_test::input_iterator_core_access; void construct(); void load( cstring file_name ); // increment implementation bool get(); // Data members struct Impl; shared_ptr m_pimpl; }; } // namespace file } // namespace BOOST_RT_PARAM_NAMESPACE } // namespace boost #endif // BOOST_RT_FILE_CONFIG_FILE_ITERATOR_HPP_062604GER