Question

I have code which will read an entire file into a buffer. For my purposes, I can guarantee that such a file is not over, say, 10MB in size... small enough that we need never concern ourselves with thrashing or real performance issues with doing a full-file read.

Further, I am currently extracting a line at a time using an isstrstream on the resulting whole-file-buffer. This works beautifully, and allows me to consume the underlying string data a line at a time.

However, I now need to see if I can save the current isstrstream position, and "jump there" later... i.e. copy an isstrsteam and generally treat it as a value object. Is this allowed / guaranteed to be a reasonable use of isstrstreams?

If it matters, I'm using VS2010.

Also, how would you look up the answers to something like this (other than stackoverflow)? Doing some google searches tells me lots of random points of data about individual methods of isstrsteam and leads to a wide variety of information about related classes - base classes or siblings or subclasses. But answering the above question is far less clear (to me).

Était-ce utile?

La solution

One can use members istream<>::tellg() and istream<>::seekg() to save/restore a stream position, similar to fgetpos and fsetpos.

istrstream supports these methods, as does istringstream.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top