Extended demo program.

This commit is contained in:
Jens Luedicke
2011-01-23 00:05:10 +01:00
parent e25af5ff2a
commit ff6c75b10c

View File

@@ -2,19 +2,46 @@
#include <iostream> #include <iostream>
enum Value {
One = 1,
Two,
Three
};
namespace string2type {
template <>
Value convert<Value>(const std::string &value) {
std::cout << "special convert function... " << std::endl;
if (value == "One") {
return One;
} else if (value == "Two") {
return Two;
} else if (value == "Three") {
return Three;
}
}
}
struct foo : attributes { struct foo : attributes {
foo() { foo() {
REGISTER_ATTRIBUTE(int, x); REGISTER_ATTRIBUTE(int, x);
REGISTER_ATTRIBUTE(Value, y);
} }
int x; int x;
Value y;
}; };
int main(int argc, char *argv) { int main(int argc, char *argv) {
foo f; foo f;
f.set_attribute("x", "42"); f.set_attribute("x", "42");
f.set_attribute("y", "One");
std::cout << f.x << std::endl; std::cout << f.x << std::endl;
std::cout << f.y << std::endl;
return 0; return 0;
} }