1 // (C) Copyright Gennadiy Rozental 2004-2008.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // See http://www.boost.org/libs/test for the library home page.
10 // Version : $Revision$
13 // ***************************************************************************
15 #ifndef BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
16 #define BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
19 #include <boost/test/utils/iterator/istream_line_iterator.hpp>
24 #include <boost/test/detail/suppress_warnings.hpp>
26 //____________________________________________________________________________//
34 // ************************************************************************** //
35 // ************** ifstream_holder ************** //
36 // ************************************************************************** //
38 template<typename CharT>
39 class ifstream_holder {
42 explicit ifstream_holder( basic_cstring<CharT const> file_name )
44 if( file_name.is_empty() )
47 m_stream.open( file_name.begin(), std::ios::in );
52 return m_stream.is_open();
56 #ifdef BOOST_CLASSIC_IOSTREAMS
57 typedef std::ifstream stream_t;
59 typedef std::basic_ifstream<CharT,std::char_traits<CharT> > stream_t;
66 } // namespace ut_detail
68 // ************************************************************************** //
69 // ************** basic_ifstream_line_iterator ************** //
70 // ************************************************************************** //
73 # pragma warning(push)
74 # pragma warning(disable: 4355) // 'this' : used in base member initializer list
77 template<typename CharT>
78 class basic_ifstream_line_iterator : ut_detail::ifstream_holder<CharT>, public basic_istream_line_iterator<CharT>
81 basic_ifstream_line_iterator( basic_cstring<CharT const> file_name, CharT delimeter )
82 : ut_detail::ifstream_holder<CharT>( file_name ), basic_istream_line_iterator<CharT>( this->m_stream, delimeter ) {}
84 explicit basic_ifstream_line_iterator( basic_cstring<CharT const> file_name = basic_cstring<CharT const>() )
85 : ut_detail::ifstream_holder<CharT>( file_name ), basic_istream_line_iterator<CharT>( this->m_stream ) {}
89 # pragma warning(default: 4355)
92 typedef basic_ifstream_line_iterator<char> ifstream_line_iterator;
93 typedef basic_ifstream_line_iterator<wchar_t> wifstream_line_iterator;
95 } // namespace unit_test
99 //____________________________________________________________________________//
101 #include <boost/test/detail/enable_warnings.hpp>
103 #endif // BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER