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

Rafal Grasman rjg1094 at gmail.com
Tue May 14 19:13:49 EDT 2013


Dear ODB-Users,

I have a problem when compiling my class through the ODB compiler,

The problem is that I get this error:

user.hxx:110:12: error: unable to map C++ type '::__gnu_cxx::new_allocator<
::std::tuple< ::std::basic_string< char, ::std::char_traits< char >,
::std::allocator< char > >, long long unsigned int, ::std::basic_string<
char, ::std::char_traits< char >, ::std::allocator< char > >, long long
unsigned int > >::value_type' used in data member 'bans_' to a MySQL
database type
user.hxx:110:12: info: use '#pragma db value_type' to specify the database
type

This recently happend when I tried to add my ban system, just like in the
examples (with employees emails):


// 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;

const bans_type&
bans () const
{
return bans_;
}

bans_type&
bans ()
{
return bans_;
}
private:
bans_type bans_;

This is the full header is needed:

#ifdef EXE24_EXPORTS
#pragma once
#endif

#include <string>
#include <vector>
#include <tuple>

#include <odb/core.hxx>

#define acmf(variable_name,variable_type) \
const variable_type& variable_name () const \
{ \
return variable_name ## _; \
} \
void variable_name (variable_type variable_name) \
{ \
variable_name ## _ = variable_name; \
}

#define accessor(variable_name,variable_type) \
const variable_type& variable_name () const \
{ \
return variable_name ## _; \
}

#pragma db object
class user
{
public:
user () {}
user
(
std::string nickname,
std::string password,
unsigned long long register_date,
unsigned int kills,
unsigned int deaths,
unsigned int joins,
unsigned int disconnects,
unsigned int kicks,
unsigned long long experience,
unsigned long long admin,
unsigned long long banned
):
nickname_(nickname),
password_(password),
register_date_(register_date),
kills_(kills),
deaths_(deaths),
joins_(joins),
disconnects_(disconnects),
kicks_(kicks),
experience_(experience),
admin_(admin),
banned_(banned)
{

}
// Standard accessor/modifier names. Auto-discovered by ODB.
//
acmf(nickname,std::string);
acmf(password,std::string);
acmf(register_date,unsigned long long);
acmf(kills,unsigned int);
acmf(deaths,unsigned int);
acmf(joins,unsigned int);
acmf(disconnects,unsigned int);
acmf(kicks,unsigned int);
acmf(experience,unsigned long long);
acmf(admin,unsigned long long);
acmf(banned,unsigned long long);

accessor(id,unsigned long);

 // 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;

const bans_type&
bans () const
{
return bans_;
}

bans_type&
bans ()
{
return bans_;
}
private:
friend class odb::access;

#pragma db id auto
unsigned long id_;

std::string nickname_;
std::string password_;
unsigned long long register_date_;
unsigned int kills_;
unsigned int deaths_;
unsigned int joins_;
unsigned int disconnects_;
unsigned int kicks_;
unsigned long long experience_;
unsigned long long admin_;
unsigned long long banned_;

bans_type bans_;
};


Could anyone point me out what I'm doing wrong? Thanks in advance!


More information about the odb-users mailing list