Saving STL Maps to file as Binary(Possible?)

Reply

Join Date: Dec 2008
Posts: 30
Reputation: codedhands is an unknown quantity at this point 
Solved Threads: 0
codedhands codedhands is offline Offline
Light Poster

Saving STL Maps to file as Binary(Possible?)

 
0
  #1
Jul 2nd, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 923
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is online now Online
Posting Shark

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

 
0
  #2
Jul 3rd, 2009
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.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 791
Reputation: siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of 
Solved Threads: 134
siddhant3s's Avatar
siddhant3s siddhant3s is offline Offline
Master Poster

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

 
0
  #3
Jul 3rd, 2009
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.
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC