Commit a4cfe5ef authored by Jakob Otto's avatar Jakob Otto

Fix string generation for enums

parent ea05c879
...@@ -11,6 +11,17 @@ using std::find_if; ...@@ -11,6 +11,17 @@ using std::find_if;
using std::string; using std::string;
using std::vector; using std::vector;
void split(const string& str, const string& separator, vector<string>& dest) {
size_t current, previous = 0;
current = str.find(separator);
while (current != std::string::npos) {
dest.emplace_back(str.substr(previous, current - previous));
previous = current + separator.size();
current = str.find(separator, previous);
}
dest.push_back(str.substr(previous, current - previous));
}
void trim(string& str) { void trim(string& str) {
auto not_space = [](char c) { return isspace(c) == 0; }; auto not_space = [](char c) { return isspace(c) == 0; };
str.erase(str.begin(), find_if(str.begin(), str.end(), not_space)); str.erase(str.begin(), find_if(str.begin(), str.end(), not_space));
...@@ -71,7 +82,7 @@ int main(int argc, char** argv) { ...@@ -71,7 +82,7 @@ int main(int argc, char** argv) {
line.pop_back(); line.pop_back();
line.erase(line.begin(), find(line.begin(), line.end(), ' ')); line.erase(line.begin(), find(line.begin(), line.end(), ' '));
trim(line); trim(line);
namespaces.emplace_back(line); split(line, "::", namespaces);
} }
} }
// Sanity checking. // Sanity checking.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment