473,806 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving and restoring streampos's

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(!indexfil e.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(!indexfil e.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::index file >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
1 2381
On Apr 25, 4:44 pm, Wolfgang Thomsen <wha...@arcor.d ewrote:
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(!indexfil e.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(!indexfil e.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::index file >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 objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Apr 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5460
by: Jacob H | last post by:
Hello list... I'm developing an adventure game in Python (which of course is lots of fun). One of the features is the ability to save games and restore the saves later. I'm using the pickle module to implement this. Capturing current program state and neatly replacing it later is proving to be trickier than I first imagined, so I'm here to ask for a little direction from wiser minds than mine! When my program initializes, each game...
5
7259
by: Michael Albanese | last post by:
Can you save objects a (custom class) to Viewstate and then get them on a later page?? I have a custom class for an ASP.Net application that I would like to make available across several web pages. For example: page1.aspx accepts a users's name, age and gender, instantiated the new class and redirects to page2.aspx
1
1280
by: usl2222 | last post by:
Hi, I'm building this web application using asp.net and c# as code behind. Currently I save all my session data in session variables. One of the things that this application must do, is to invoke another instance of the same application, with different parameters, of course. Then the second invokation can potentially couse a third invokation, etc.
3
4578
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and set textboxes, radio buttons, etc - that viewstate is fine. Then I have a linkbutton that does a Server.Transfer over to Page2.aspx. When I Server.Transfer back to Page1.aspx, the viewstate info is lost. I ran across another example of this last...
1
1636
by: Tom | last post by:
I have a large application; lots of forms, multiple dynamic DLLs, etc. I also have, in the appliation, a general 'Preferences' class object (which is in itself a separate DLL, and I just include a reference to it so I can instantiate it at the beginning) which stores all my user preferences. I serialize the data to and from an XML file, thereby saving and restoring the user preferences with ease. I also have a Preferences form that the user...
2
3978
by: Al-Burak | last post by:
I have a program that retrieves the cursor position at the point where the data began to be stored, this value is assigned to a 'std::streampos' data type called 'pos'. Later on in the program, 'pos' is put in another file, but as an 'int' data type, as suggested by the documentation. Having said that, here is my question: If the value of 'pos' exceeds INT_MAX, I will lose the ability to store that data in an integral value; run time error...
1
2687
by: Al-Burak | last post by:
After storing the cursor possition in a file, I try to read it back, std::ofstream >> std::streampos, but this statement gives me an error syaing: file.cpp: In member function `virtual jme::MyClass& jme::MyClass::operator>>(std::streampos&)': file.cpp:1051: error: ambiguous overload for 'operator>>' in '(((jme::Stream*)this) + (*(int*)(((jme::MyClass*)this)->jme::MyClass::_vptr$MyClass + -0x000000010)))->jme::Stream::f >> data'
0
1060
by: timnels | last post by:
I have a strongly-typed DataTable I need to save as XML and later reload it. I thought that all I had to do was: menuDataTable.WriteXml(filename,XmlWriteMode.WriteSchema); And from another application do: menuDataTable.ReadXml(filename);
1
8224
by: Jacek Dziedzic | last post by:
Hello! This is my first time dealing with Very Large Files. I have vector of strings representing numbers and I need to extract bytes in binary mode from a Large File that correspond to ranges specified by the strings. For example for an input of "0", "100", "500", "700" I need to create three files, the first would contain
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.