GDBM class for Boost C++ serializable objects

I havn't writtin the iterators yet, but below is a simple class wrapping a GDBM database allowing you to store Boost serializable objects in the file on disk. Usage is pretty simple:

  Gdbm st(databaseName);

  std::map<std::string, double> amap;
  amap["a"] = 10;
  amap["b"] = 12.5;
  cout << "Into file a: " << amap["a"] << endl;
  st.store("example", amap); //Serialize and store the map

  std::map<std::string, double> fromFile;
  st.load("example", fromFile); //Serialize and restore the map
  cout << "From file a: " << fromFile["a"] << endl;

The whole code is pretty basic, but I wanted to blog something again. However, the code should be an mediocre example of how you could get it to work. I don't think it is very usefull to grow the whole library any further because it is just for fun anyway, but it seems to be quite fast (GDBM is fast, that is) and I have succesfully stored more than 10 GB of data without any problems with it.

Have fun!

PS Your ccResolutions file should contain:

boost/archive/text_iarchive.hpp -lboost_serialization
boost/archive/text_oarchive.hpp -lboost_serialization
boost/serialization/map.hpp -lboost_serialization
boost/shared_ptr.hpp
gdbm.h -lgdbm
sys/stat.h

AttachmentSize
example.cc803 bytes
Gdbm.hh5.54 KB