partial_whitespace.hpp 985 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. class partial_whitespace: public mstch::object {
  2. private:
  3. int m_value;
  4. public:
  5. partial_whitespace(): m_value(10000) {
  6. register_methods(this, std::map<std::string,mstch::node(partial_whitespace::*)()>{
  7. {"greeting", &partial_whitespace::greeting},
  8. {"farewell", &partial_whitespace::farewell},
  9. {"name", &partial_whitespace::name},
  10. {"value", &partial_whitespace::value},
  11. {"taxed_value", &partial_whitespace::taxed_value},
  12. {"in_ca", &partial_whitespace::in_ca}
  13. });
  14. }
  15. mstch::node greeting() {
  16. return std::string{"Welcome"};
  17. }
  18. mstch::node farewell() {
  19. return std::string{"Fair enough, right?"};
  20. }
  21. mstch::node name() {
  22. return std::string{"Chris"};
  23. }
  24. mstch::node value() {
  25. return m_value;
  26. }
  27. mstch::node taxed_value() {
  28. return static_cast<int>(m_value - (m_value * 0.4));
  29. }
  30. mstch::node in_ca() {
  31. return true;
  32. }
  33. };
  34. const auto partial_whitespace_data = std::make_shared<partial_whitespace>();