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: istream_line_iterator.hpp,v $
|
---|
9 | //
|
---|
10 | // Version : $Revision: 1.4 $
|
---|
11 | //
|
---|
12 | // Description :
|
---|
13 | // ***************************************************************************
|
---|
14 |
|
---|
15 | #ifndef BOOST_ISTREAM_LINE_ITERATOR_HPP_071894GER
|
---|
16 | #define BOOST_ISTREAM_LINE_ITERATOR_HPP_071894GER
|
---|
17 |
|
---|
18 | // Boost
|
---|
19 | #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
---|
20 | #include <boost/test/utils/iterator/input_iterator_facade.hpp>
|
---|
21 |
|
---|
22 | // STL
|
---|
23 | #include <iosfwd>
|
---|
24 |
|
---|
25 | #include <boost/test/detail/suppress_warnings.hpp>
|
---|
26 |
|
---|
27 | //____________________________________________________________________________//
|
---|
28 |
|
---|
29 | namespace boost {
|
---|
30 |
|
---|
31 | namespace unit_test {
|
---|
32 |
|
---|
33 | // ************************************************************************** //
|
---|
34 | // ************** basic_istream_line_iterator ************** //
|
---|
35 | // ************************************************************************** //
|
---|
36 |
|
---|
37 | //!! Should we support policy based delimitation
|
---|
38 |
|
---|
39 | template<typename CharT>
|
---|
40 | class basic_istream_line_iterator
|
---|
41 | : public input_iterator_facade<basic_istream_line_iterator<CharT>,
|
---|
42 | std::basic_string<CharT>,
|
---|
43 | basic_cstring<CharT const> > {
|
---|
44 | typedef input_iterator_facade<basic_istream_line_iterator<CharT>,
|
---|
45 | std::basic_string<CharT>,
|
---|
46 | basic_cstring<CharT const> > base;
|
---|
47 | #ifdef BOOST_CLASSIC_IOSTREAMS
|
---|
48 | typedef std::istream istream_type;
|
---|
49 | #else
|
---|
50 | typedef std::basic_istream<CharT> istream_type;
|
---|
51 | #endif
|
---|
52 | public:
|
---|
53 | // Constructors
|
---|
54 | basic_istream_line_iterator() {}
|
---|
55 | basic_istream_line_iterator( istream_type& input, CharT delimeter )
|
---|
56 | : m_input_stream( &input ), m_delimeter( delimeter )
|
---|
57 | {
|
---|
58 | this->init();
|
---|
59 | }
|
---|
60 | explicit basic_istream_line_iterator( istream_type& input )
|
---|
61 | : m_input_stream( &input )
|
---|
62 | #if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
---|
63 | , m_delimeter( '\n' )
|
---|
64 | #else
|
---|
65 | , m_delimeter( input.widen( '\n' ) )
|
---|
66 | #endif
|
---|
67 | {
|
---|
68 | this->init();
|
---|
69 | }
|
---|
70 |
|
---|
71 | private:
|
---|
72 | friend class input_iterator_core_access;
|
---|
73 |
|
---|
74 | // increment implementation
|
---|
75 | bool get()
|
---|
76 | {
|
---|
77 | return std::getline( *m_input_stream, this->m_value, m_delimeter );
|
---|
78 | }
|
---|
79 |
|
---|
80 | // Data members
|
---|
81 | istream_type* m_input_stream;
|
---|
82 | CharT m_delimeter;
|
---|
83 | };
|
---|
84 |
|
---|
85 | typedef basic_istream_line_iterator<char> istream_line_iterator;
|
---|
86 | typedef basic_istream_line_iterator<wchar_t> wistream_line_iterator;
|
---|
87 |
|
---|
88 | } // namespace unit_test
|
---|
89 |
|
---|
90 | } // namespace boost
|
---|
91 |
|
---|
92 | //____________________________________________________________________________//
|
---|
93 |
|
---|
94 | #include <boost/test/detail/enable_warnings.hpp>
|
---|
95 |
|
---|
96 | // ***************************************************************************
|
---|
97 | // Revision History :
|
---|
98 | //
|
---|
99 | // $Log: istream_line_iterator.hpp,v $
|
---|
100 | // Revision 1.4 2005/02/20 08:27:09 rogeeff
|
---|
101 | // This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
|
---|
102 | //
|
---|
103 | // Revision 1.3 2005/02/01 06:40:08 rogeeff
|
---|
104 | // copyright update
|
---|
105 | // old log entries removed
|
---|
106 | // minor stilistic changes
|
---|
107 | // depricated tools removed
|
---|
108 | //
|
---|
109 | // Revision 1.2 2005/01/22 19:22:14 rogeeff
|
---|
110 | // implementation moved into headers section to eliminate dependency of included/minimal component on src directory
|
---|
111 | //
|
---|
112 | // Revision 1.1 2005/01/22 18:21:40 rogeeff
|
---|
113 | // moved sharable staff into utils
|
---|
114 | //
|
---|
115 | // ***************************************************************************
|
---|
116 |
|
---|
117 | #endif // BOOST_ISTREAM_LINE_ITERATOR_HPP_071894GER
|
---|
118 |
|
---|