title: Checking total lines read by QTextStream without using a dedicated counter
body: <p>I'm currently working on code for parsing a file with an unknown number of lines. The format is roughly like this:</p>
  
  <pre><code>ShapeId: 1
  ShapeType: Line
  ShapeDimensions: 20, 90, 100, 20
  PenColor: blue
  PenWidth: 2
  PenStyle: DashDotLine
  PenCapStyle: FlatCap
  PenJoinStyle: MiterJoin
  
  // and so on and so forth; formats vary slightly depending on the entry
  </code></pre>
  
  <p>Being a text file, obviously we'll want to check for errors. Currently, I am doing this by throwing an exceptions with (fairly) informative messages.</p>
  
  <p>However, my exception messages cannot be too specific, because many of my functions which help parse the file are too generic to have specific messages. Given the sheer diversity of the lines, it's impractical to have custom-written messages for each kind of line.</p>
  
  <p>As I mentioned in the title, I am using <a href="http://doc.qt.io/qt-5/qtextstream.html" rel="nofollow noreferrer">QTextStream</a>. I am using <a href="http://doc.qt.io/qt-5/qtextstream.html#readLine" rel="nofollow noreferrer">readLine</a> to read the each line, and then doing stuff with that line. I am also using <a href="http://doc.qt.io/qt-5/qtextstream.html#skipWhiteSpace" rel="nofollow noreferrer">skipWhiteSpace</a> to skip the gaps between the blocks of data.</p>
  
  <p>I was hoping <a href="http://doc.qt.io/qt-5/qtextstream.html" rel="nofollow noreferrer">QTextStream</a> would come with this functionality, but it doesn't. The closest thing I could find is <a href="http://doc.qt.io/qt-5/qtextstream.html#pos" rel="nofollow noreferrer">pos</a>. This is better than nothing, but it's not nearly as useful as a line number.</p>
  
  <p>I could add an integer counter to count up as I step through each line. However, this is impractical in the context of my program, where I have many helper functions that will read lines. Also, <a href="http://doc.qt.io/qt-5/qtextstream.html#skipWhiteSpace" rel="nofollow noreferrer">skipWhiteSpace</a> can skip multiple lines, so I couldn't use this if I were manually counting.</p>
  
  <p>Unfortunately, I haven't been able to find a good solution. The closest would be something like <a href="https://stackoverflow.com/questions/10589098/qt-how-to-count-number-of-line-in-txt-file">this</a>, but that's assuming we're already stepping through the file, one line at a time, within a simple loop. Again, that's too impractical in this situation.</p>
  
  <p>So...I guess my question is: is there an elegant way of checking the line number which a QTextStream is pointing to without relying on any previous code? Am I missing something obvious?</p>
  
  <p>(I would rather avoid using on libraries other than Qt and the basic C++ libraries for this.)</p>