[odb-users] raw pointer to application's global array

Boris Kolpackov boris at codesynthesis.com
Thu May 29 10:06:36 EDT 2014


Hi,

MM <finjulhich at gmail.com> writes:

> > #pragma db member(my_id) virtual(unsigned long) id
> >
> I am very confused. In this pragma, there is nothing that links the my_id
> to the C++ class/struct ('object') the instances of which will be persisted
> and use this auto generated id?

Yes, I should have added ellipsis at the end of this pragma to
highlight that it is incomplete (and I forgot auto):

#pragma db member(my_id) virtual(unsigned long) id auto ...

What you still need to specify is the get/set expressions that
interface with the underlying storage. Here is an example:

class object
{
  #pragma db transient
  unsigned long my_id_;

  #pragma db member(my_id) virtual(unsigned long) id auto get(my_id_) set(my_id_)
};

Of course, this specific example does not make much sense since
you can achieve the same result by simply making my_id_ the id
member directly, without any virtual data members:

class object
{
  #pragma db id auto
  unsigned long my_id_;
};

Perhaps that's what you are looking for?

Boris



More information about the odb-users mailing list