[odb-users] Unknown action or bug in odb compiler
Александр Матушкин
sysmaker at compot.ru
Sun Dec 20 05:27:15 EST 2015
Hello.
Found problem with compiler ODB.
Enviroment:
OS: Raspian.
GCC G++ 4.9.2.
Present file(smarthome_types.h) with descriptions database object classes.
(Generated by thrift compiler).
No edit manually. Make be regenerate.
All needed classes are present in separated namespace: smarthouse.
Create new header file odb-thrift.hxx.
For "non-intrusive conversion" create this text:
#ifndef ODB_THRIFT_HXX_
#define ODB_THRIFT_HXX_
#include "smarthome_types.h"
namespace smarthouse {
#pragma db object(Node)
#pragma db member(Node::id) id
}
#endif
In <smarthome_types.h> present class Node. In class Node present filed id as
'int';
Compile this flie odb:
odb -d mysql --generate-query --generate-schema odb-thrift.hpp
Success. No error. Present new files:
odb-thrift-odb.cxx, odb-thrift-odb.hxx, odb-thrift-odb.ixx, odb-thrift.sql
But odb-thrift.sql is empty:
/* This file was generated by ODB, object-relational mapping (ORM)
* compiler for C++.
*/
In odb-thrift-odb.hxx:
// This file was generated by ODB, object-relational mapping (ORM)
// compiler for C++.
//
#ifndef ODB_THRIFT_ODB_HXX
#define ODB_THRIFT_ODB_HXX
#include <odb/version.hxx>
#if (ODB_VERSION != 20400UL)
#error ODB runtime version mismatch
#endif
#include <odb/pre.hxx>
#include "odb-thrift.hpp"
#include "smarthome_types-odb.hxx"
#include <memory>
#include <cstddef>
#include <odb/core.hxx>
#include <odb/traits.hxx>
#include <odb/callback.hxx>
#include <odb/wrapper-traits.hxx>
#include <odb/pointer-traits.hxx>
#include <odb/container-traits.hxx>
#include <odb/no-op-cache-traits.hxx>
#include <odb/result.hxx>
#include <odb/details/unused.hxx>
#include <odb/details/shared-ptr.hxx>
namespace odb
{
}
#include <odb/details/buffer.hxx>
#include <odb/mysql/version.hxx>
#include <odb/mysql/forward.hxx>
#include <odb/mysql/binding.hxx>
#include <odb/mysql/mysql-types.hxx>
#include <odb/mysql/query.hxx>
namespace odb
{
}
#include "odb-thrift-odb.ixx"
#include <odb/post.hxx>
#endif // ODB_THRIFT_ODB_HXX
In .cxx file present the same.
Empty namespace odb.
If manually insert into smarthome_types.h after class Node definition but
into namespace smarthouse this lines:
#pragma db object(Node)
#pragma db member(Node::id) id
Odb generate valid classes, headers and sql files.Not emty.
Attempt modify odb-thrift.hxx to next form:
#ifndef OBD_THRIFT_HXX_
#define OBD_THRIFT_HXX_
#include "smarthome_types.h"
#pragma db namespace(smarthouse) object(Node)
#pragma db namespace(smarthouse) member(Node::id) id
#endif /* OBD_THRIFT_HXX_ */
Odb produce next error:
odb-thrift.hpp:13:34: error: name 'smarthouse' in db pragma object does not
refer to a class
odb-thrift.hpp:14:34: error: unknown db pragma member.
Attempt write odb-thrift.hxx to next form:
#ifndef OBD_THRIFT_HXX_
#define OBD_THRIFT_HXX_
#include "smarthome_types.h"
#pragma db object(smarthouse::Node)
#pragma db member(smarthouse::Node::id) id
#endif /* OBD_THRIFT_HXX_ */
Success. No error. But present empty files.
In what my error? How to receive result without changing the file
smarthome_types.h?
Thanks in advance.
Alexandr.
More information about the odb-users
mailing list