extend line parser to retrieve file position
authorMichael Andres <ma@suse.de>
Fri, 20 Apr 2007 14:41:35 +0000 (14:41 +0000)
committerMichael Andres <ma@suse.de>
Fri, 20 Apr 2007 14:41:35 +0000 (14:41 +0000)
zypp/base/IOStream.cc
zypp/base/IOStream.h

index 7d3b50f..0bb5b77 100644 (file)
@@ -55,6 +55,7 @@ namespace zypp
     //
     EachLine::EachLine( std::istream & str_r, unsigned lineNo_r )
       : _str( str_r )
+      , _lineStart( -1 )
       , _lineNo( lineNo_r )
       , _valid( true )
     {
@@ -79,13 +80,14 @@ namespace zypp
        return(_valid = false);
       }
 
+      _lineStart = _str.tellg();
       _line = iostr::getline( _str );
+      ++_lineNo;
       if ( _str.fail() || _str.bad() )
       {
        _line.clear();
        return(_valid = false);
       }
-      ++_lineNo;
       return(_valid = true);
     }
 
index fc43c28..c1ad08b 100644 (file)
@@ -76,6 +76,9 @@ namespace zypp
        unsigned lineNo() const
        { return _lineNo; }
 
+       std::streamoff lineStart() const
+       { return _lineStart; };
+
        /** Set current line number. */
        void setLineNo( unsigned lineNo_r )
        { _lineNo = lineNo_r; }
@@ -102,9 +105,10 @@ namespace zypp
 
       private:
        std::istream & _str;
-       std::string _line;
-       unsigned _lineNo;
-       bool _valid;
+       std::string    _line;
+       std::streamoff _lineStart;
+       unsigned       _lineNo;
+       bool           _valid;
     };
     ///////////////////////////////////////////////////////////////////