1 | // (C) Copyright Gennadiy Rozental 2004-2005.
|
---|
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)
|
---|
5 |
|
---|
6 | // See http://www.boost.org/libs/test for the library home page.
|
---|
7 | //
|
---|
8 | // File : $RCSfile: ifstream_line_iterator.hpp,v $
|
---|
9 | //
|
---|
10 | // Version : $Revision: 1.7 $
|
---|
11 | //
|
---|
12 | // Description :
|
---|
13 | // ***************************************************************************
|
---|
14 |
|
---|
15 | #ifndef BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
|
---|
16 | #define BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
|
---|
17 |
|
---|
18 | // Boost
|
---|
19 | #include <boost/test/utils/iterator/istream_line_iterator.hpp>
|
---|
20 |
|
---|
21 | // STL
|
---|
22 | #include <fstream>
|
---|
23 |
|
---|
24 | #include <boost/test/detail/suppress_warnings.hpp>
|
---|
25 |
|
---|
26 | //____________________________________________________________________________//
|
---|
27 |
|
---|
28 | namespace boost {
|
---|
29 |
|
---|
30 | namespace unit_test {
|
---|
31 |
|
---|
32 | namespace ut_detail {
|
---|
33 |
|
---|
34 | // ************************************************************************** //
|
---|
35 | // ************** ifstream_holder ************** //
|
---|
36 | // ************************************************************************** //
|
---|
37 |
|
---|
38 | template<typename CharT>
|
---|
39 | class ifstream_holder {
|
---|
40 | public:
|
---|
41 | // Constructor
|
---|
42 | explicit ifstream_holder( basic_cstring<CharT const> file_name )
|
---|
43 | {
|
---|
44 | if( file_name.is_empty() )
|
---|
45 | return;
|
---|
46 |
|
---|
47 | m_stream.open( file_name.begin(), std::ios::in );
|
---|
48 | }
|
---|
49 |
|
---|
50 | bool is_valid()
|
---|
51 | {
|
---|
52 | return m_stream.is_open();
|
---|
53 | }
|
---|
54 |
|
---|
55 | protected:
|
---|
56 | #ifdef BOOST_CLASSIC_IOSTREAMS
|
---|
57 | typedef std::ifstream stream_t;
|
---|
58 | #else
|
---|
59 | typedef std::basic_ifstream<CharT,std::char_traits<CharT> > stream_t;
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | // Data members
|
---|
63 | stream_t m_stream;
|
---|
64 | };
|
---|
65 |
|
---|
66 | } // namespace ut_detail
|
---|
67 |
|
---|
68 | // ************************************************************************** //
|
---|
69 | // ************** basic_ifstream_line_iterator ************** //
|
---|
70 | // ************************************************************************** //
|
---|
71 |
|
---|
72 | #ifdef BOOST_MSVC
|
---|
73 | # pragma warning(push)
|
---|
74 | # pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | template<typename CharT>
|
---|
78 | class basic_ifstream_line_iterator : ut_detail::ifstream_holder<CharT>, public basic_istream_line_iterator<CharT>
|
---|
79 | {
|
---|
80 | public:
|
---|
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 ) {}
|
---|
83 |
|
---|
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 ) {}
|
---|
86 | };
|
---|
87 |
|
---|
88 | #ifdef BOOST_MSVC
|
---|
89 | # pragma warning(default: 4355)
|
---|
90 | #endif
|
---|
91 |
|
---|
92 | typedef basic_ifstream_line_iterator<char> ifstream_line_iterator;
|
---|
93 | typedef basic_ifstream_line_iterator<wchar_t> wifstream_line_iterator;
|
---|
94 |
|
---|
95 | } // namespace unit_test
|
---|
96 |
|
---|
97 | } // namespace boost
|
---|
98 |
|
---|
99 | //____________________________________________________________________________//
|
---|
100 |
|
---|
101 | #include <boost/test/detail/enable_warnings.hpp>
|
---|
102 |
|
---|
103 | // ***************************************************************************
|
---|
104 | // Revision History :
|
---|
105 | //
|
---|
106 | // $Log: ifstream_line_iterator.hpp,v $
|
---|
107 | // Revision 1.7 2005/06/11 07:21:23 rogeeff
|
---|
108 | // reverse prev fix
|
---|
109 | //
|
---|
110 | // Revision 1.6 2005/06/07 05:08:03 rogeeff
|
---|
111 | // gcc fix
|
---|
112 | //
|
---|
113 | // Revision 1.5 2005/02/20 08:27:09 rogeeff
|
---|
114 | // This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
|
---|
115 | //
|
---|
116 | // Revision 1.4 2005/02/01 06:40:08 rogeeff
|
---|
117 | // copyright update
|
---|
118 | // old log entries removed
|
---|
119 | // minor stilistic changes
|
---|
120 | // depricated tools removed
|
---|
121 | //
|
---|
122 | // Revision 1.3 2005/01/30 01:44:14 rogeeff
|
---|
123 | // warnings suppressed
|
---|
124 | //
|
---|
125 | // Revision 1.2 2005/01/22 19:22:13 rogeeff
|
---|
126 | // implementation moved into headers section to eliminate dependency of included/minimal component on src directory
|
---|
127 | //
|
---|
128 | // Revision 1.1 2005/01/22 18:21:40 rogeeff
|
---|
129 | // moved sharable staff into utils
|
---|
130 | //
|
---|
131 | // ***************************************************************************
|
---|
132 |
|
---|
133 | #endif // BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
|
---|
134 |
|
---|