Moving odd pragmas outside the class header

Is there a way to move odb (C ++ orm like framework) pragmas outside the class header? For example, I define the basic_object (abstract) class with only id:

class basic_object  {
   int _id;
public:
    int get_id() const;
    void set_id(int _id);
};

And then create pragmas for this class in another file

#pragma db object(basic_object) abstract
#pragma db member(basic_object::_id) get(get_id) set(set_id) id auto
+4
source share
1 answer

Yes you can, he called pragmas.

In another file you need to write

#pragma db object(basic_object)
#pragma db member(basic_object::_id) id

Then you must tell the odb compiler where to look. You can do this by adding

#ifdef ODB_COMPILER
#include "other_file.hxx"
#endif

to the source file OR using

- odb-epilogue '#include "other_file.hxx"'

as an odb compiler option.


basic_object, : _id .

odb :

private:
friend class odb::access; 
0

Source: https://habr.com/ru/post/1616135/


All Articles