This is an automated email from the git hooks/post-receive script.

plessy pushed a commit to branch debian/unstable
in repository libgtextutils.

commit 6614b0e72507ef6d95f341cf977d8cb8c8e2ab71
Author: A. Gordon <[email protected]>
Date:   Wed Mar 25 19:56:19 2009 -0400

    Added 'unget_line' feature to TextLineReader class.
---
 src/gtextutils/text_line_reader.cpp | 10 +++++++---
 src/gtextutils/text_line_reader.h   | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/gtextutils/text_line_reader.cpp 
b/src/gtextutils/text_line_reader.cpp
index 881f54f..1db0a52 100644
--- a/src/gtextutils/text_line_reader.cpp
+++ b/src/gtextutils/text_line_reader.cpp
@@ -24,14 +24,18 @@ using namespace std;
 
 
 TextLineReader::TextLineReader(istream& _input_stream) :
-       input_stream(_input_stream), current_line_number(0)
+       input_stream(_input_stream), current_line_number(0), 
unget_line_active(false)
 {
 }
 
 bool TextLineReader::next_line() 
 {
-       current_line_number++;
-       getline(input_stream, current_line_string ) ;
+       if (unget_line_active) {
+               unget_line_active = false;
+       } else {
+               current_line_number++;
+               getline(input_stream, current_line_string ) ;
+       }
 
        current_line_stream.str( current_line_string ) ;
        current_line_stream.seekg(0, ios_base::beg );
diff --git a/src/gtextutils/text_line_reader.h 
b/src/gtextutils/text_line_reader.h
index da3ef1c..07c85d2 100644
--- a/src/gtextutils/text_line_reader.h
+++ b/src/gtextutils/text_line_reader.h
@@ -29,6 +29,7 @@ private:
        size_t current_line_number;
        std::string current_line_string ;
        std::istringstream current_line_stream ;
+       bool unget_line_active ;
 
        TextLineReader(const TextLineReader&);
        TextLineReader& operator=(const TextLineReader&);
@@ -40,8 +41,22 @@ public:
 
        bool next_line() ;
 
+       void unget_line ( const std::string& line ) 
+       { 
+               unget_line_active = true ;
+               current_line_string = line ;
+       }
+       void unget_current_line () { unget_line_active = true; } 
+
+       //explicit conversions
        const std::string& line_string() const { return current_line_string; }
        std::istringstream& line_stream() { return current_line_stream; }
+
+       //implicit conversions
+       operator const std::string& () const { return line_string() ; }
+       operator std::string() const { return line_string(); }
+       operator std::istream& () { return line_stream(); }
+
 };
 
 #endif

-- 
Alioth's /git/debian-med/git-commit-notice on 
/srv/git.debian.org/git/debian-med/libgtextutils.git

_______________________________________________
debian-med-commit mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to