By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,458 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,458 IT Pros & Developers. It's quick & easy.

Saving and restoring streampos's

P: n/a
Hello,

I need to process very large files which are made of blocks of data. To
speed up the reading of a specific block, I let my program note down the
streampos of each block's beginning in a file, which seems to work.

For reading the stream positions back, I use the following code:

while(!indexfile.eof()) {
int position;
indexfile >position;
//.. save position into a vector ..
}

which does not work because the numerical streampositions exceed the size of
an int.

while(!indexfile.eof()) {
streampos position;
indexfile >position;
//.. save position into a vector ..
}

does not work either and gives me an error message
"error: ambiguous overload for operator>in
((XYZFile*)this)->XYZFile::indexfile >position"

(XYZFile is the name of the class).

It also gives me a long list of possible candidates, but I do not know how
to specify which it should use, let alone decide which one I should use.
Any help or suggestions are greatly appreciated,
regards, Wolfgang
Apr 25 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Apr 25, 4:44 pm, Wolfgang Thomsen <wha...@arcor.dewrote:
I need to process very large files which are made of blocks of data. To
speed up the reading of a specific block, I let my program note down the
streampos of each block's beginning in a file, which seems to work.
For reading the stream positions back, I use the following code:
while(!indexfile.eof()) {
Which is surely wrong. istream::eof() is only significant after
a read has failed.
int position;
indexfile >position;
//.. save position into a vector ..
}
which does not work because the numerical streampositions exceed the sizeof
an int.
So use a larger type:-). (In practice, of course, streampos
should be a class type, and likely isn't representable in any
integral type.)
while(!indexfile.eof()) {
streampos position;
indexfile >position;
//.. save position into a vector ..
}
does not work either and gives me an error message
"error: ambiguous overload for operator>in
((XYZFile*)this)->XYZFile::indexfile >position"
(XYZFile is the name of the class).
It also gives me a long list of possible candidates, but I do not know how
to specify which it should use, let alone decide which one I should use.
There isn't one that would work. That's why it's ambiguous: all
are equally bad.
Any help or suggestions are greatly appreciated,
There's no real solution within the standard here. I'd use the
system API (Posix, Windows or whatever), with [io]stringstream
for parsing and formatting.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Apr 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.