Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++/sqlite wrapper for dead-easy class serialization?

I am looking for an OO sqlite C++ wrapper which allows quasi-transparent serialization and de-serialization of classes.

The work-flow I have in mind is as follow:

  1. define a class record with the data members
  2. Supply this class to the wrapper which creates a suitable table

Simple serialization and de-serialization via << and >> for the entire class.

Is this realistic or do I necessarily have to write the operators myself? Ideally I would like to not worry about how the data gets into the database and how it is stored... Ease of use is my main concern rather than flexibility or performance.

I am looking for something along the lines of the GAE datastore python interface.

Many thanks, Arik

like image 210
ARF Avatar asked Feb 26 '11 00:02

ARF


2 Answers

There no easy C++ ORM (Object relational Mapping) tools. The two libraries I know of that ease the process are :

  • SOCI
  • Debea

SOCI is simpler and is boost-like in philosophy, while debea is more ORM oriented.

By the way, if SQLite / SQL / requests are not mandatory, you can use Boost serialization framework.

Just my two cents

EDIT:

Well, given the nearly inexistent C++ reflection possibilities, my humble opinion is that the only way to do what you want to do is to use a code generator. Given that there was no decent, easy to use C++ parser/lexer/..., I know of none widespread tool doing that.

Someone I know had the same problem for some years. He has finally found a solution : He tells me that clang is now usable (it compiles boost), and that he uses it to generate serialization code based upon markers in the code (he tells me that there is support for marker in TR1, but I'm no expert). That is valuable feedback, and my own tries in this field make me agree about the solution.

like image 91
neuro Avatar answered Nov 15 '22 21:11

neuro


Quince is a library that does almost exactly what the questioner asks for. See quince-lib.com.

(Full disclosure: I wrote it.)

like image 23
slyqualin Avatar answered Nov 15 '22 19:11

slyqualin