template<class O, class T, class ...Op> internal::column_t<O, T, Op...> make_column(const std::string &name, T O::*m, Op ...constraints); template<class O, class T, class ...Op> internal::column_t<O, T, Op...> make_column(const std::string &name, void (O::*setter)(T), const T& (O::*getter)() const, Op ...constraints); template<class O, class T, class ...Op> internal::column_t<O, T, Op...> make_column(const std::string &name, const T& (O::*getter)() const, void (O::*setter)(T), Op ...constraints);
Creates column objects used as make_table function argument. There are two ways to make a column: with member pointer and with member function pointer. First overload is used to create a column with member pointer. The second and the third are used to create a column with setter and getter member function pointers. First way is used to map public members, second - to map private and protected members with public setters and getters.
(1) name
Column name from database.
(2) m
Member pointer mapped to this column. Example: &User::id
.
(3) options
Extra options used to specify column more precisely. For example: primary_key, autoincrement and default_value.
(4) setter
Setter function pointer. Must return void, have only one argument of type T
and be non-const.
(5) getter
Getter function pointer. Must return const T&
, have 0 arguments and be const.
column_t<O, T, Op...>
instance.
struct Employee { int id; std::string name; int age; std::shared_ptr<std::string> address; // optional std::shared_ptr<double> salary; // optional }; using namespace sqlite_orm; auto storage = make_storage("make_storage_example.sqlite", make_table("COMPANY", make_column("ID", &Employee::id, primary_key()), make_column("NAME", &Employee::name), make_column("AGE", &Employee::age), make_column("ADDRESS", &Employee::address), make_column("SALARY", &Employee::salary)));
For mapping private/protected members please check out the example
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4