Added demo program.
This commit is contained in:
35
examples/demo.cpp
Normal file
35
examples/demo.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user