473,378 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Writing an STL map to disk.

Hey there :)

I was once told that the STL classes had member functions to write their
data to disk and to restore that data. Searching google (and why are there
no "stl" or "map" manpages?), it seems like someone was pulling my leg,
because I really can't find anything about it.

So, was I misinformed? Or perhaps this person was talking about some other
classes you could use to do such a thing?

TIA,
Daniel :)
--
Why do cats jump out of windows? Because there's love out there!
Jul 23 '05 #1
6 5609
DanielEKFA wrote:
I was once told that the STL classes had member functions to write their
data to disk and to restore that data. Searching google (and why are there
no "stl" or "map" manpages?), it seems like someone was pulling my leg,
because I really can't find anything about it.


Prepare yourself for a shock, but not everything has a manpage. My Panasonic
TV doesn't, for example.

These hits look promising:

http://www.google.com/search?q=seria...%3Aboost%2Eorg

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #2
DanielEKFA wrote:
I was once told that the STL classes had member functions to write their data to disk and to restore that data.


No, you probably mean RogueWave classes.
But you can write a for-loop with fwrite() for serialization and a
for-loop with fread() for deserialization. :-)

::A::

Jul 23 '05 #3
Phlip wrote:
DanielEKFA wrote:
I was once told that the STL classes had member functions to write their
data to disk and to restore that data. Searching google (and why are
there no "stl" or "map" manpages?), it seems like someone was pulling my
leg, because I really can't find anything about it.
Prepare yourself for a shock, but not everything has a manpage. My
Panasonic TV doesn't, for example.


....yet ;)
These hits look promising:

http://www.google.com/search?q=seria...%3Aboost%2Eorg


Didn't know the term serialization (other than in a scheduling context),
will have a look, thanks :)

--
Why do cats jump out of windows? Because there's love out there!
Jul 23 '05 #4
Abecedarian wrote:

No, you probably mean RogueWave classes.
Could be, not sure... Checking it out.
But you can write a for-loop with fwrite() for serialization and a
for-loop with fread() for deserialization. :-)

This serialization term in this context is new to me... Is this like
balancing a binary tree by writing it in pre-order to a file and then
restore it be reading back the data from the file?
::A::


Cheers,
Daniel :)

--
Why do cats jump out of windows? Because there's love out there!
Jul 23 '05 #5
DanielEKFA wrote:
But you can write a for-loop with fwrite() for serialization and a
for-loop with fread() for deserialization. :-)
This serialization term in this context is new to me...
"Serialize" is the generic term for turning structured data into a
restructured stream.

Then, the first big question is whether the stream should use text or binary
encoding. Prefer text until you find a hard reason to use binary.

So serializing to XML is safer and more humane than writing raw data with
fwrite(). That will narrow your options to read the file.

Next, your data needs structure. Text formats like XML provide that with ><
marks, linefeeds, etc. Binary formats often encode the length of each field
before the field.

One impressive binary format out there is simply a GZip of an XML file. The
only requirement was small file size, and if both your GZip and XML
libraries can stream, then you can read efficiently.
Is this like
balancing a binary tree by writing it in pre-order to a file and then
restore it be reading back the data from the file?


Like. But that changed the raw structure on the way. (And to balance, you
should either use a std::map with the balancing act built-in, or you should
write the tree straight into another tree, or you can skip the problem and
not prematurely optimize.)

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #6
DanielEKFA wrote:
Abecedarian wrote:
But you can write a for-loop with fwrite() for serialization and a
for-loop with fread() for deserialization. :-)


This serialization term in this context is new to me... Is this like
balancing a binary tree by writing it in pre-order to a file and then
restore it be reading back the data from the file?


std::map has iterators. You can just write in 'key=value' style
(similar to Windows INI files) to the file.

::A::

Jul 23 '05 #7

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

Similar topics

48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
8
by: Lu | last post by:
Hi there, I got a program to write data to a randomly accessed file (the program moves file pointer to a certain position of the file according the current "keyword" and then writes data). It...
5
by: Ben Jeurissen | last post by:
Hello, I have to deal with the following issue in C++: Two threads are started from the main thread, both capturing images from a different firewire camera. Both threads take shots of 460800...
3
by: ishekar | last post by:
Hi, I have an application where i want to write data to a file, the data is being sent from an external source. I know the total size of the data and then i retrieve the data in small segments...
2
by: Jeevan | last post by:
Hi, I have an array of data (which I am getting from a socket connection). I am working on a program which acts on this data but the program is written to work on data from a file (not from an...
16
by: Ali | last post by:
Hi I want to write (or read) to a stream, but the data is not byte array I converted the data to byte array manually, but it is very slow, (becuse the data is very large) Is another way for this...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
12
by: romayankin | last post by:
I plan to write site on a few language. For this reason I'm trying to find the most convenient way to output strings depending on their unique ID. As far as I plan to have pretty much strings...
16
by: Claudio Grondi | last post by:
I have a 250 Gbyte file (occupies the whole hard drive space) and want to change only eight bytes in this file at a given offset of appr. 200 Gbyte (all other data in that file should remain...
10
by: eastcoastguyz | last post by:
(I've not done C prorgamming in such a long time, I have forgotten how to do this.) I'm writing a program, where it fopens a file with "a+", and I want to be able to continue writing to this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.