summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/name_helpers.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-11-23 21:50:16 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-04 15:47:50 -0300
commitd93e9ff286ce1961f530d56b5536881f47104ebd (patch)
treed9fd8cd25a64b9ab6b23ae34b92c342dc8e6b543 /src/bin/eolian_mono/eolian/mono/name_helpers.hh
parent9391407319424c503a78479b407737ccead945b7 (diff)
eolian_mono: Added code for eolian_mono generator
Based on the eolian_cxx library generators. Buildsystem files will come in a future commmit.
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/name_helpers.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh139
1 files changed, 139 insertions, 0 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
new file mode 100644
index 0000000000..6b40829b20
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -0,0 +1,139 @@
1#ifndef EOLIAN_MONO_NAME_HELPERS_HH
2#define EOLIAN_MONO_NAME_HELPERS_HH
3
4#include <algorithm>
5#include <cctype>
6#include <iterator>
7#include <sstream>
8#include <string>
9#include <vector>
10
11namespace eolian_mono {
12
13namespace name_helpers {
14
15static const std::vector<std::string> verbs =
16 {
17 "add",
18 "get",
19 "is",
20 "del",
21 "thaw",
22 "freeze",
23 "save",
24 "wait",
25 "eject",
26 "raise",
27 "lower",
28 "load",
29 "dup",
30 "reset",
31 "unload",
32 "close",
33 "set",
34 "interpolate",
35 "has",
36 "grab",
37 "check",
38 "find",
39 "ungrab",
40 "unset",
41 "clear",
42 "pop",
43 "new",
44 "peek",
45 "push",
46 "update",
47 "show",
48 "move",
49 "hide",
50 "calculate",
51 "resize",
52 "attach",
53 "pack",
54 "unpack",
55 "emit",
56 "call",
57 "append"
58 };
59
60const std::vector<std::string> not_verbs =
61 {
62 "below",
63 "above",
64 "name",
65 "unfreezable",
66 "value",
67 "r",
68 "g",
69 "b",
70 "a",
71 "finalize",
72 "destructor",
73 "to",
74 "circle",
75 "rect",
76 "path",
77 "commands",
78 "type",
79 "colorspace"
80 "op",
81 "type",
82 "properties",
83 "status",
84 "status",
85 "relative",
86 "ptr",
87 "pair",
88 "pos",
89 "end"
90 };
91
92void reorder_verb(std::vector<std::string> &names)
93{
94 if (names.size() <= 1)
95 return;
96
97 std::string verb = names.back();
98
99 if (std::find(verbs.begin(), verbs.end(), verb) != verbs.end())
100 {
101 names.pop_back();
102 names.insert(names.begin(), verb);
103 }
104}
105
106std::vector<std::string> split(std::string const &input, char delim)
107{
108 std::stringstream ss(input);
109 std::string name;
110 std::vector<std::string> names;
111
112 while (std::getline(ss, name, delim)) {
113 if (!name.empty())
114 names.push_back(name);
115 }
116 return names;
117}
118
119std::string pascal_case(const std::vector<std::string> &names)
120{
121 std::vector<std::string> outv(names.size());
122 std::stringstream osstream;
123
124 std::transform(names.begin(), names.end(), outv.begin(),
125 [](std::string name) {
126 name[0] = std::toupper(name[0]);
127 return name;
128 });
129
130 std::copy(outv.begin(), outv.end(), std::ostream_iterator<std::string>(osstream, ""));
131
132 return osstream.str();
133}
134
135} // namespace name_helpers
136
137} // namespace eolian_mono
138
139#endif