Added convenience macro.
This commit is contained in:
@@ -15,7 +15,7 @@ int convert<int>(const std::string &value) {
|
|||||||
|
|
||||||
struct foo : settable::settable {
|
struct foo : settable::settable {
|
||||||
foo() {
|
foo() {
|
||||||
register_setter<int>("x", &x);
|
REGISTER_MEMBER(int, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ public:
|
|||||||
void *ptr;
|
void *ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define REGISTER_MEMBER(Type, Attribute) \
|
||||||
|
this->register_setter<Type>(#Attribute, &Attribute);
|
||||||
|
|
||||||
class settable {
|
class settable {
|
||||||
public:
|
public:
|
||||||
void set_attribute(const std::string &attr, const std::string &value) {
|
void set_attribute(const std::string &attr, const std::string &value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user