[odb-users] no modifiers found

Boris Kolpackov boris at codesynthesis.com
Tue Jun 3 08:27:49 EDT 2014


MM <finjulhich at gmail.com> writes:

> However, modifiers are indeed not found in that type definition. The doc
> lists only some accessors. The type doesn't have a def ctor, provides a
> user ctor and a copy ctor, but no assignment operator, nor setter for
> begin/end.

Lack of modifiers is a bit of challenge but you could use constructor
and assignment to work around that:

#pragma db member(boost::posix_time::time_period::begin) \
           virtual(boost::posix_time::ptime) \
           get (begin ()) \
           set (this = boost::posix_time::time_period ((?), this.end ()))

#pragma db member(boost::posix_time::time_period::end) \
           virtual(boost::posix_time::ptime) \
           get (end ()) \
           set (this = boost::posix_time::time_period (this.begin (), (?)))

The trick here is not to violate some type constraints that would
cause the constructor to throw or not to store the data we want it
to store. If that causes problems, then one can assume that simple
value data members are initialized in the order of declaration (we
don't specify this anywhere but I don't see a reason why this will
ever not hold).


More information about the odb-users mailing list