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

MM finjulhich at gmail.com
Thu May 29 10:45:10 EDT 2014


yes adding a private member std::uint32_t to my object will work.
I'll specify the pragma outside of the class definition though

#pragma db member(object::my_id_) id auto

do i still need get/set ?



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

> 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