Added demo program.

This commit is contained in:
Jens Luedicke
2010-09-16 00:04:02 +02:00
parent 2ca1424663
commit 6be687ae44

35
examples/demo.cpp Normal file
View File

@@ -0,0 +1,35 @@
#include "settable.hpp"
#include <iostream>
#include <boost/lexical_cast.hpp>
namespace settable {
namespace setter {
namespace string2type {
namespace helper {
template<>
int convert<int>(const std::string &value) {
return boost::lexical_cast<int>(value);
}
}
}
}
}
struct foo : settable::settable {
foo() {
register_setter<int>("x", &x);
}
int x;
};
int main(int argc, char *argv) {
foo f;
f.set_attribute("x", "42");
std::cout << f.x << std::endl;
return 0;
}