diff options
| author | Mistivia <i@mistivia.com> | 2025-01-16 15:43:04 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-01-16 15:53:58 +0800 |
| commit | 8689a7c78c50676ea739f52fbcee9f091709f5c0 (patch) | |
| tree | bbb72c68e5e1753f751133941a402caa43e29a16 /lib/mstch/test/data/partial_view.hpp | |
| parent | 00afb767ae37488d99f78363d031b898b1932354 (diff) | |
add mstch
Diffstat (limited to 'lib/mstch/test/data/partial_view.hpp')
| -rw-r--r-- | lib/mstch/test/data/partial_view.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/mstch/test/data/partial_view.hpp b/lib/mstch/test/data/partial_view.hpp new file mode 100644 index 0000000..5c2c3eb --- /dev/null +++ b/lib/mstch/test/data/partial_view.hpp @@ -0,0 +1,42 @@ +class partial_view: public mstch::object { +private: + int m_value; + +public: + partial_view(): m_value(10000) { + register_methods(this, std::map<std::string,mstch::node(partial_view::*)()>{ + {"greeting", &partial_view::greeting}, + {"farewell", &partial_view::farewell}, + {"name", &partial_view::name}, + {"value", &partial_view::value}, + {"taxed_value", &partial_view::taxed_value}, + {"in_ca", &partial_view::in_ca} + }); + } + + mstch::node greeting() { + return std::string{"Welcome"}; + } + + mstch::node farewell() { + return std::string{"Fair enough, right?"}; + } + + mstch::node name() { + return std::string{"Chris"}; + } + + mstch::node value() { + return m_value; + } + + mstch::node taxed_value() { + return m_value - (m_value * 0.4); + } + + mstch::node in_ca() { + return true; + } +}; + +const auto partial_view_data = std::make_shared<partial_view>();
\ No newline at end of file |
