[odb-users] Error when trying to use odb compiler on custom class

Boris Kolpackov boris at codesynthesis.com
Tue May 14 20:27:02 EDT 2013


Hi Rafal,

Rafal Grasman <rjg1094 at gmail.com> writes:
 
> // bans.
> // v<t<reason,how_long,by_who,when>>
> typedef std::vector<std::tuple<std::string,unsigned long
> long,std::string,unsigned long long>> bans_type;

The vector element is a composite (multi-column) value type. You
need to declare such a type with the db value pragma so that the
ODB compiler can generate the database support code for it.

ODB allows you to "create" a composite value type out of a class
template instantiations (e.g., std::tuple). Here is an example:

typedef std::tuple<std::string, 
                   unsigned long long,
                   std::string,
                   unsigned long long> ban_type;

#pragma db value(ban_type)

#pragma db object
class object
{
  ...

  typedef std::vector<ban_type> bans_type;
  bans_type bans;
};

Boris




More information about the odb-users mailing list