From a326214482d66fa7147be6298cb0219347c96d4b Mon Sep 17 00:00:00 2001 From: Jens Luedicke Date: Sat, 22 Jan 2011 01:43:53 +0100 Subject: [PATCH] Added convenience macro. --- examples/demo.cpp | 2 +- settable.hpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/demo.cpp b/examples/demo.cpp index f16c80b..4999d39 100644 --- a/examples/demo.cpp +++ b/examples/demo.cpp @@ -15,7 +15,7 @@ int convert(const std::string &value) { struct foo : settable::settable { foo() { - register_setter("x", &x); + REGISTER_MEMBER(int, x); } int x; diff --git a/settable.hpp b/settable.hpp index d668135..3a9f975 100644 --- a/settable.hpp +++ b/settable.hpp @@ -52,6 +52,9 @@ public: void *ptr; }; +#define REGISTER_MEMBER(Type, Attribute) \ + this->register_setter(#Attribute, &Attribute); + class settable { public: void set_attribute(const std::string &attr, const std::string &value) {