[odb-users] value classes in views

Quentin Deldycke quentindeldycke at gmail.com
Fri Sep 19 05:24:34 EDT 2014


Hi Boris,
Ok, I started to modify a bit my work, but there is some things i don't
understand or do correctly:

My situation is as followed:

#pragma db value
class A
{
//some int / string and stuff...
}

#pragma db object
class B
{
 //some int / string and stuff...
}

#pragma db object
class C
{
  A   classA;
  shared_ptr<B>  classB;
}

I want to build a view, equivalent to object C (i displayed only usefull
data)

My view is built like this:

#pragma db view object(C) object(B = classB: A::classB)
class view_C
{
 A classA;
 B classB;
}

But i have a compilation error as followed:
error: unable to map C++ type '::B' used in data member 'classB' to a MySQL
database type
info: use '#pragma db type' to specify the database type

--
Deldycke Quentin


On 19 September 2014 09:22, Boris Kolpackov <boris at codesynthesis.com> wrote:

> Hi Quentin,
>
> Quentin Deldycke <quentindeldycke at gmail.com> writes:
>
> > I need to create views using sub-objects. For instance, like this:
> >
> > // a value object
> > class B
> > {
> >    std::string test;
> >    std::string test2;
> > }
> >
> > // My view
> > class A
> > {
> >   B  object1;
> >   B  object2;
> > }
>
> If B is a composite value type and is also used in the object on which
> A is based, then this works out of the box. See Section 10.6, "Other
> View Features and Limitations" for an example.
>
> If some of the above doesn't hold, then it is still possible but will
> require a bit more effort. See Section 14.4.13, "virtual" for a Swiss
> army knife of packing/unpacking data members.
>
> Boris
>


More information about the odb-users mailing list