[odb-users] odb compiler

Boris Kolpackov boris at codesynthesis.com
Wed Jan 26 11:07:41 EST 2011


Hi Eugene,

In the future please keep your replies CC'ed to the odb-users mailing
list as discussed in the posting guidelines:

http://www.codesynthesis.com/support/posting-guidelines.xhtml

Eugene N <neverov.biks.07.1 at gmail.com> writes:

> Thank you very much for your quick responce. What i basically ment was this
> - i have a lot of extrenal dependancies in my application (libraries), and i
> wasnt sure how would odb compiler react on them (if i try to compile my
> application with it).
> 
> I missed the description of odb on your website at first, so i thought it
> would try to link my application. But as it produces c++ code, my first
> question had no sence really, forgive my ignorance.

No problem. I am glad it is clearer now.


> My second question was this: i have a class (lets call it "A") with 4
> members ( sort of POD class), those members are vectors of sort (contiguous
> in memory, just like stl vectors, elements are bytes). I need to store a few
> thousands of "A" objects, i really need only three operations - find, add,
> and get.
> 
> So, i would like to know, would i have to modify only my "A" classes, in
> order to persist them with ODB, or would i have to modify those internal
> vector classes (which are from external library)?

No, you shouldn't need to modify the vector classes from the external
library. The way to handle this depends on how you want to store these
vectors in the database. Seeing that their elements are bytes, then
one possible representation would be to store them as BLOBs. For this,
you will need to provide specializations of the value_traits template
which perform the conversion between these vectors and the database
type. This should be fairly simple and the 'mapping' example in the
odb-examples package shows how to do this. Also see Section 9.2.1,
"type" in the ODB manual.

The other possible way to handle these vectors would be to store them
as containers so that each member of a vector type is mapped to a
table and each element in a container is stored in a separate row.
Container support was added in the just-released ODB 1.1.0. Otherwise,
this also should be fairly easy to implement, as discussed in Section
5.4, "Using Custom Containers" in the ODB manual.

Boris



More information about the odb-users mailing list