object support
This commit is contained in:
parent
8fbcd12284
commit
812b4bdb41
29 changed files with 142 additions and 155 deletions
25
test/data/dot_notation.hpp
Normal file
25
test/data/dot_notation.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
class dot_notation_price: public mstch::object {
|
||||
private:
|
||||
const int value;
|
||||
const mstch::map currency;
|
||||
public:
|
||||
dot_notation_price():
|
||||
value{200}, currency{{"symbol", std::string{"$"}}, {"name", std::string{"USD"}}}
|
||||
{
|
||||
register_method("value", {value});
|
||||
register_method("vat", this, &dot_notation_price::vat);
|
||||
register_method("currency", {currency});
|
||||
}
|
||||
|
||||
mstch::node vat() {
|
||||
return static_cast<int>(value * 0.2);
|
||||
}
|
||||
};
|
||||
|
||||
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}}}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue