Created
July 17, 2013 07:44
-
-
Save betatim/6018538 to your computer and use it in GitHub Desktop.
On my mac it compiles with:
$ g++ -g serial.cpp -o serial -lboost_serialization-mt
running it create dead_pixels.archive
$ ./serial somewhere I have the magic line to add to the requirements file to get it to link to boost_serialisation ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
#include <map> | |
#include <boost/archive/binary_oarchive.hpp> | |
#include <boost/archive/binary_iarchive.hpp> | |
#include <boost/serialization/map.hpp> | |
int main() { | |
std::ofstream ofs("dead_pixels.archive", std::ios::binary); | |
// channel ID as key, value tells us for how | |
// many more cycles the pixel is dead | |
std::map<int, int> dead_pixels; | |
dead_pixels[123456] = 12; | |
dead_pixels[123457] = 2; | |
// save data to archive | |
{ | |
boost::archive::binary_oarchive oa(ofs); | |
oa << dead_pixels; | |
} | |
// ... some time later | |
std::map<int,int> restored_dead_pixels; | |
{ | |
std::ifstream ifs("dead_pixels.archive", std::ios::binary); | |
boost::archive::binary_iarchive ia(ifs); | |
ia >> restored_dead_pixels; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment