Result columns of a described type: the common description of objects ( anch::Mapping<T> , anch-utils) registered to read result rows.
More...
#include <rows.hpp>
Classes | |
| struct | Field |
| Field which can be written. More... | |
Public Member Functions | |
| const Field * | find (std::string_view column) const noexcept |
| const std::vector< Field > & | fields () const noexcept |
| template<typename P, typename... C> | |
| RowMapper< T > & | registerField (const std::string &name, P T::*member, C &&...) |
| template<typename P, typename... C> | |
| RowMapper< T > & | registerField (const std::string &, std::function< P(const T &)>, C &&...) |
| template<typename P, typename... C> | |
| RowMapper< T > & | registerField (const std::string &name, std::function< void(T &, const P &)> setter, C &&...) |
| template<typename P, typename... C> | |
| RowMapper< T > & | registerField (const std::string &name, std::function< P(const T &)>, std::function< void(T &, const P &)> setter, C &&...) |
Static Public Member Functions | |
| static const RowMapper< T > & | instance () |
Result columns of a described type: the common description of objects ( anch::Mapping<T> , anch-utils) registered to read result rows.
Each field which can be written (member or setter) is filled with the column of the same name (ASCII case is ignored: PostgreSQL gives unquoted names in lowercase) ; fields which are only read (getter) are ignored. Fields values have to be Readable : a field of another type (nested object, collection, ...) is refused at compile time. Constraints are not checked (validate objects with anch::val::validate ).
| T | the described type |
|
noexcept |
Fields getter
|
noexcept |
Find field of a column: field of the same name, or of the same name ignoring ASCII case
| column | the column name |
nullptr when T has no such field (or when it is only read)
|
static |
Mapper of T (built once)
| RowMapper< T > & anch::sql::RowMapper< T >::registerField | ( | const std::string & | , |
| std::function< P(const T &)> | , | ||
| C && | ... ) |
Register field by getter: ignored (the field can not be written)
| P | the field type |
| C | the constraints types |
this | RowMapper< T > & anch::sql::RowMapper< T >::registerField | ( | const std::string & | name, |
| P T::* | member, | ||
| C && | ... ) |
Register field by member
| P | the field type |
| C | the constraints types |
| name | the field name |
| member | the member |
this | RowMapper< T > & anch::sql::RowMapper< T >::registerField | ( | const std::string & | name, |
| std::function< P(const T &)> | , | ||
| std::function< void(T &, const P &)> | setter, | ||
| C && | ... ) |
Register field by getter and setter (the setter writes the value)
| P | the field type |
| C | the constraints types |
| name | the field name |
| setter | the setter |
this | RowMapper< T > & anch::sql::RowMapper< T >::registerField | ( | const std::string & | name, |
| std::function< void(T &, const P &)> | setter, | ||
| C && | ... ) |
Register field by setter
| P | the field type |
| C | the constraints types |
| name | the field name |
| setter | the setter |
this