943,529 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1290
  • C++ RSS
Jul 2nd, 2009
0

Saving STL Maps to file as Binary(Possible?)

Expand Post »
Hi,Am writing an application which requires storing data to a map and saving it to a file.How do i save a STL map to a file and retrieve it without the application crashing?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
codedhands is offline Offline
30 posts
since Dec 2008
Jul 3rd, 2009
0

Re: Saving STL Maps to file as Binary(Possible?)

I assume you know how to do basic file i/o?
http://www.cplusplus.com/reference/iostream/ofstream/
http://www.cplusplus.com/reference/iostream/ifstream/

Write/read how many objects you have, then loop through and load/store those objects.
Reputation Points: 888
Solved Threads: 114
Nearly a Posting Virtuoso
MosaicFuneral is offline Offline
1,270 posts
since Nov 2008
Jul 3rd, 2009
0

Re: Saving STL Maps to file as Binary(Possible?)

Tell me how much time did you spent on a search engine to find your answer.
In technical terms, 'saving' is known as serialization[1]
There are plenty of libraries out there to serialize STL containers. You are fortunate enough that Boost's Serialization Library is there on your demand.
Another library is provided on CodeProject

But I would suggest you to use this tool and find the best library for you, yourself.

[1] serialization is actually the process of converting an object into a sequence of bits so that it can be persisted on a storage medium (such as a file, or a memory buffer) or transmitted across a network connection link.
Reputation Points: 1486
Solved Threads: 140
Practically a Posting Shark
siddhant3s is offline Offline
816 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help Would Be Appreciated
Next Thread in C++ Forum Timeline: Intro and question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC