implemented specialization of data types via type traits and handling of embedded non-trivial types
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#ifndef QUERY_COORDINATE_HPP
|
||||
#define QUERY_COORDINATE_HPP
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
|
||||
namespace matador::test {
|
||||
struct coordinate
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace matador::utils::access {
|
||||
|
||||
template<class Operator>
|
||||
void attribute(Operator &op, const char *id, test::coordinate &value, const field_attributes &attr = null_attributes) {
|
||||
attribute(op, (std::string(id) + "_x").c_str(), value.x, attr);
|
||||
attribute(op, (std::string(id) + "_y").c_str(), value.y, attr);
|
||||
attribute(op, (std::string(id) + "_z").c_str(), value.z, attr);
|
||||
}
|
||||
|
||||
}
|
||||
#endif //QUERY_COORDINATE_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef QUERY_LOCATION_HPP
|
||||
#define QUERY_LOCATION_HPP
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
|
||||
#include "coordinate.hpp"
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
enum class Color : uint8_t {
|
||||
Green, Red, Blue, Yellow, Black, White, Brown
|
||||
};
|
||||
|
||||
struct location
|
||||
{
|
||||
unsigned long id;
|
||||
std::string name;
|
||||
coordinate coord;
|
||||
Color color;
|
||||
|
||||
template < class Operator >
|
||||
void process(Operator &op)
|
||||
{
|
||||
namespace field = matador::utils::access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "name", name, 255);
|
||||
field::attribute(op, "coordinate", coord);
|
||||
field::attribute(op, "color", color);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //QUERY_LOCATION_HPP
|
||||
Reference in New Issue
Block a user