2015-04-17 08:07:14 +08:00
|
|
|
class dot_notation_price: public mstch::object {
|
|
|
|
private:
|
2015-04-21 21:04:11 +08:00
|
|
|
int m_value;
|
|
|
|
mstch::map m_currency;
|
2015-04-17 08:07:14 +08:00
|
|
|
public:
|
|
|
|
dot_notation_price():
|
2015-04-21 21:04:11 +08:00
|
|
|
m_value{200}, m_currency{{"symbol", std::string{"$"}}, {"name", std::string{"USD"}}}
|
2015-04-17 08:07:14 +08:00
|
|
|
{
|
2015-04-21 21:04:11 +08:00
|
|
|
register_methods(this, {
|
|
|
|
{"value", &dot_notation_price::value},
|
|
|
|
{"vat", &dot_notation_price::vat},
|
|
|
|
{"currency", &dot_notation_price::currency}});
|
|
|
|
}
|
|
|
|
|
|
|
|
mstch::node value() {
|
|
|
|
return m_value;
|
2015-04-17 08:07:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
mstch::node vat() {
|
2015-04-29 16:53:01 +08:00
|
|
|
return m_value * 0.2;
|
2015-04-21 21:04:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
mstch::node currency() {
|
|
|
|
return m_currency;
|
2015-04-17 08:07:14 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto dot_notation_data = mstch::map{
|
|
|
|
{"name", std::string{"A Book"}},
|
|
|
|
{"authors", mstch::array{std::string{"John Power"}, std::string{"Jamie Walsh"}}},
|
|
|
|
{"price", std::make_shared<dot_notation_price>()},
|
|
|
|
{"availability", mstch::map{{"status", true}, {"text", std::string{"In Stock"}}}},
|
|
|
|
{"truthy", mstch::map{{"zero", 0}, {"notTrue", false}}}
|
|
|
|
};
|