[odb-users] Persisting class for which part of the code is generated at compile time.

Teererai Marange selection989 at gmail.com
Mon Jul 6 05:46:17 EDT 2015


I have a project that consists of the following files:

Node.h
Node.cpp
resultSet.h
resultSet.cpp
bfs.h
bfs.cpp
8puzzle.c

The goal of this project is to run breadth first search and the persist the
results to a database. To do this, I have created made the objects
described by resultSet.h and Node.h persistant. Worth noting is the fact
that some of the objects that describe a Node are generated and stored in
8puzzle.c at runtime. For this reason, in order to make resultSet
persistant I used:

 odb -d mysql  --generate-query --generate-schema --std c++11 resultSet.h
-x -include -x 8puzzle.c

and

 odb -d mysql  --generate-query --generate-schema --std c++11 Node.h -x
-include -x 8puzzle.c

I then tried to compile Node-odb.cxx using:

g++ -c Node-odb.cxx -include 8puzzle.c

and the following error was returned:

Node-odb.cxx: In static member function ‘static bool
odb::access::object_traits_impl<Node,
(odb::database_id)0u>::init(odb::access::object_traits_impl<Node,
(odb::database_id)0u>::image_type&, const object_type&,
odb::mysql::statement_kind)’:
Node-odb.cxx:233:10: error: no matching function for call to
‘odb::mysql::value_traits<state_t,
(odb::mysql::database_type_id)16u>::set_image(odb::details::buffer&,
std::size_t&, bool&, const state_t&)’
         v);
          ^
Node-odb.cxx:233:10: note: candidate is:
In file included from /usr/local/include/odb/mysql/query.hxx:20:0,
                 from Node-odb.hxx:86,
                 from Node-odb.cxx:7:
/usr/local/include/odb/mysql/traits.hxx:323:7: note: static void
odb::mysql::default_value_traits<T, <anonymous>
>::set_image(odb::mysql::default_value_traits<T, <anonymous>
>::image_type&, bool&, T) [with T = state_t; odb::mysql::database_type_id
ID = (odb::mysql::database_type_id)16u; odb::mysql::default_value_traits<T,
<anonymous> >::image_type = odb::details::basic_buffer<char>]
       set_image (image_type& i, bool& is_null, T v)
       ^
/usr/local/include/odb/mysql/traits.hxx:323:7: note:   candidate expects 3
arguments, 4 provided
Node-odb.cxx: In static member function ‘static void
odb::access::object_traits_impl<Node,
(odb::database_id)0u>::init(odb::access::object_traits<Node>::object_type&,
const odb::access::object_traits_impl<Node,
(odb::database_id)0u>::image_type&, odb::database*)’:
Node-odb.cxx:330:26: error: no matching function for call to
‘odb::mysql::value_traits<state_t,
(odb::mysql::database_type_id)16u>::set_value(state_t&, const buffer&,
const long unsigned int&, const my_bool&)’
         i.base_state_null);
                          ^
Node-odb.cxx:330:26: note: candidate is:
In file included from /usr/local/include/odb/mysql/query.hxx:20:0,
                 from Node-odb.hxx:86,
                 from Node-odb.cxx:7:
/usr/local/include/odb/mysql/traits.hxx:314:7: note: static void
odb::mysql::default_value_traits<T, <anonymous> >::set_value(T&, const
image_type&, bool) [with T = state_t; odb::mysql::database_type_id ID =
(odb::mysql::database_type_id)16u; odb::mysql::default_value_traits<T,
<anonymous> >::image_type = odb::details::basic_buffer<char>]
       set_value (T& v, const image_type& i, bool is_null)
       ^
/usr/local/include/odb/mysql/traits.hxx:314:7: note:   candidate expects 3
arguments, 4 provided
/usr/local/include/odb/mysql/traits.hxx: In instantiation of ‘static void
odb::mysql::default_value_traits<T, <anonymous>
>::set_image(odb::mysql::default_value_traits<T, <anonymous>
>::image_type&, bool&, T) [with T = state_t; odb::mysql::database_type_id
ID = (odb::mysql::database_type_id)16u; odb::mysql::default_value_traits<T,
<anonymous> >::image_type = odb::details::basic_buffer<char>]’:
Node-odb.cxx:229:31:   required from here
/usr/local/include/odb/mysql/traits.hxx:326:11: error: no matching function
for call to ‘odb::details::basic_buffer<char>::basic_buffer(state_t&)’
         i = image_type (v);
           ^
/usr/local/include/odb/mysql/traits.hxx:326:11: note: candidates are:
In file included from Node-odb.hxx:80:0,
                 from Node-odb.cxx:7:
/usr/local/include/odb/details/buffer.hxx:52:7: note:
odb::details::basic_buffer<T>::basic_buffer(std::size_t) [with T = char;
std::size_t = long unsigned int]
       basic_buffer (std::size_t capacity = 256)
       ^
/usr/local/include/odb/details/buffer.hxx:52:7: note:   no known conversion
for argument 1 from ‘state_t’ to ‘std::size_t {aka long unsigned int}’
/usr/local/include/odb/details/buffer.hxx:49:11: note:
odb::details::basic_buffer<char>::basic_buffer(const
odb::details::basic_buffer<char>&)
     class basic_buffer: public basic_buffer_base
           ^
/usr/local/include/odb/details/buffer.hxx:49:11: note:   no known
conversion for argument 1 from ‘state_t’ to ‘const
odb::details::basic_buffer<char>&’
In file included from /usr/local/include/odb/mysql/query.hxx:20:0,
                 from Node-odb.hxx:86,
                 from Node-odb.cxx:7:
/usr/local/include/odb/mysql/traits.hxx: In instantiation of ‘static void
odb::mysql::default_value_traits<T, <anonymous> >::set_value(T&, const
image_type&, bool) [with T = state_t; odb::mysql::database_type_id ID =
(odb::mysql::database_type_id)16u; odb::mysql::default_value_traits<T,
<anonymous> >::image_type = odb::details::basic_buffer<char>]’:
Node-odb.cxx:326:31:   required from here
/usr/local/include/odb/mysql/traits.hxx:317:13: error: no matching function
for call to ‘state_t::state_t(const image_type&)’
           v = T (i);
             ^
/usr/local/include/odb/mysql/traits.hxx:317:13: note: candidates are:
In file included from <command-line>:0:0:
./8puzzle.c:35:3: note: state_t::state_t()
 } state_t;
   ^
./8puzzle.c:35:3: note:   candidate expects 0 arguments, 1 provided
./8puzzle.c:35:3: note: state_t::state_t(const state_t&)
./8puzzle.c:35:3: note:   no known conversion for argument 1 from ‘const
image_type {aka const odb::details::basic_buffer<char>}’ to ‘const state_t&’

baring in mind that the code describing state_t is located in 8puzzle.c is
there anyway around this and what exactly is the problem?


Regards,

Teererai Marange
Ph: 021521987


More information about the odb-users mailing list