1 /*
2    Gordon's Text-Utilities Library
3    Copyright (C) 2009-2013 Assaf Gordon (assafgordon@gmail.com)
4 
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU Affero General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Affero General Public License for more details.
14 
15    You should have received a copy of the GNU Affero General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>
17 */
18 #include <istream>
19 #include <sstream>
20 
21 #include "text_line_reader.h"
22 
23 using namespace std;
24 
25 
TextLineReader(istream & _input_stream)26 TextLineReader::TextLineReader(istream& _input_stream) :
27 	input_stream(_input_stream), current_line_number(0), unget_line_active(false)
28 {
29 }
30 
next_line()31 bool TextLineReader::next_line()
32 {
33 	if (unget_line_active) {
34 		unget_line_active = false;
35 	} else {
36 		current_line_number++;
37 		getline(input_stream, current_line_string ) ;
38 	}
39 
40 	current_line_stream.str( current_line_string ) ;
41 	current_line_stream.seekg(0, ios_base::beg );
42 	current_line_stream.clear();
43 
44 	if (input_stream.eof())
45 		return false;
46 
47         // Fix based on the only code change since 0.7
48 	return input_stream.good() ;
49 }
50 
51