[odb-users] containers of containers

Andrew Cunningham odb at a-cunningham.com
Thu Aug 18 13:50:34 EDT 2016


>
> You can actually map std::array<float, 3> as a composite value type and it
> can be used "as if" it was a container. For example:
>
>
>
> #include <array>
>
> #include <vector>
>
>
>
> using float3 = std::array<float, 3>;
>
>
>
> #pragma db value(float3) transient
>
> #pragma db member(float3::e1) virtual(float) get(this[0]) set(this[0])
> #pragma db member(float3::e2) virtual(float) get(this[1]) set(this[1])
> #pragma db member(float3::e3) virtual(float) get(this[2]) set(this[2])
>
>
>
> #pragma db object
>
> struct object
>
> {
>
>   #pragma db id
>
>   int id;
>
>
>
>   std::vector<float3> vf3;
>
> };
>
>
>
> Note how with this approach you can easily customize column name/type, use
> members in queries, etc.
>

OK, i see how that can work... I think....could get painful for larger
array sizes.


More information about the odb-users mailing list