File: simple.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 (32 lines) | stat: -rw-r--r-- 614 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
class simple: public mstch::object {
private:
  int m_value;
public:
  simple():
    m_value(10000)
  {
    register_methods(this, std::map<std::string,mstch::node(simple::*)()>{
      {"name", &simple::name},
      {"value", &simple::value},
      {"taxed_value", &simple::taxed_value},
      {"in_ca", &simple::in_ca}});
  }
  
  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 simple_data = std::make_shared<simple>();