DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Saving STL Maps to file as Binary(Possible?) (http://www.daniweb.com/forums/thread201372.html)

codedhands Jul 2nd, 2009 11:00 pm
Saving STL Maps to file as Binary(Possible?)
 
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?

MosaicFuneral Jul 3rd, 2009 12:33 am
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.

siddhant3s Jul 3rd, 2009 12:51 am
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.


All times are GMT -4. The time now is 5:13 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC