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

MM finjulhich at gmail.com
Thu May 29 09:49:11 EDT 2014


On 29 May 2014 14:40, Boris Kolpackov <boris at codesynthesis.com> wrote:

> Hi,
>
> MM <finjulhich at gmail.com> writes:
>
> > Ok, but can I have a virtual member integer that stands for auto
> generated
> > id? If not, I'll just add a integer (std::uintx_t) as a member of that
> > struct, and use that as the auto id.
>
> ODB-supported auto-id can only be a single data member of an integer
> type. It cannot be a member of a struct. It can be a virtual data
> member:
>
> #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?
I restate everything here from start, for my own understanding.
I have a struct 'object'. I will have instances of object. These instances
I want to store them as rows in some table in sqlite. The auto id is the
unique identifier of each different persistence instance of 'object'



> > also, in the virt member pragma
> >
> > #pragma db member(foo) virtual(std::string) get(*this.foo_) set(set_foo)
> >
> > My foo_ is actually public.
> >
> > Can the setter be declared in the non intrusive header for the pragmas,
> as
> > a non member function?
>
> Yes, but then you will need to spell out the call expression explicitly:
>
> class object
> {
>   #pragma db member(foo) virtual(std::string) set(set_foo (this, (?)))
> };
>
> void set_foo (object& o, const std::string foo)
> {
>   ...
> }
>
> For more detail see the describtion of the accessor and modifier
> expressions in the ODB manual (Section 14.4.5, "get/set/access").
>
> Boris
>
Ok great, this is exactly what I was looking for.

Thanks again,


More information about the odb-users mailing list