File: specs_lambdas.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-- 1,424 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
std::map<std::string,mstch::node> specs_lambdas {
    {"Interpolation", mstch::lambda{[](const std::string&) -> mstch::node {
      return std::string{"world"};
    }}},
    {"Interpolation - Expansion", mstch::lambda{[](const std::string&) -> mstch::node {
      return std::string{"{{planet}}"};
    }}},
    {"Interpolation - Alternate Delimiters", mstch::lambda{[](const std::string&) -> mstch::node {
      return std::string{"|planet| => {{planet}}"};
    }}},
    {"Interpolation - Multiple Calls", mstch::lambda{[](const std::string&) -> mstch::node {
      static int calls = 0; return ++calls;
    }}},
    {"Escaping", mstch::lambda{[](const std::string&) -> mstch::node {
      return std::string{">"};
    }}},
    {"Section", mstch::lambda{[](const std::string& txt) -> mstch::node {
      return std::string{(txt == "{{x}}") ? "yes" : "no"};
    }}},
    {"Section - Expansion", mstch::lambda{[](const std::string& txt) -> mstch::node {
      return txt + std::string{"{{planet}}"} + txt;
    }}},
    {"Section - Alternate Delimiters", mstch::lambda{[](const std::string& txt) -> mstch::node {
      return txt + std::string{"{{planet}} => |planet|"} + txt;
    }}},
    {"Section - Multiple Calls", mstch::lambda{[](const std::string& txt) -> mstch::node {
      return "__" + txt + "__";
    }}},
    {"Inverted Section", mstch::lambda{[](const std::string&) -> mstch::node {
      return false;
    }}}
};