File: partial_whitespace.hpp

package info (click to toggle)
mstch 1.0.2-4
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 940 kB
  • sloc: cpp: 1,429; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 985 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class partial_whitespace: public mstch::object {
private:
  int m_value;
public:
  partial_whitespace(): m_value(10000) {
    register_methods(this, std::map<std::string,mstch::node(partial_whitespace::*)()>{
      {"greeting", &partial_whitespace::greeting},
      {"farewell", &partial_whitespace::farewell},
      {"name", &partial_whitespace::name},
      {"value", &partial_whitespace::value},
      {"taxed_value", &partial_whitespace::taxed_value},
      {"in_ca", &partial_whitespace::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 static_cast<int>(m_value - (m_value * 0.4));
  }

  mstch::node in_ca() {
    return true;
  }
};

const auto partial_whitespace_data = std::make_shared<partial_whitespace>();