Sanitize field names when generating STL functions

A sanitizing function was already present in FieldVisitor.cpp. I
refactored and moved it to Utilities.
Refs #429
This commit is contained in:
Derek Bankieris
2017-05-18 08:42:40 -05:00
parent 34c62c5aab
commit 05b4d09b2b
4 changed files with 12 additions and 19 deletions

View File

@ -6,6 +6,14 @@
#include "Utilities.hh"
std::string sanitize(const std::string& text) {
std::string result = text;
for (char c : {'<', '>', ' ', ',', ':', '*', '[', ']'}) {
std::replace(result.begin(), result.end(), c, '_');
}
return result ;
}
// removes leading and trailing whitespace from a string
std::string trim(const std::string& str, const std::string& whitespace ) {
size_t strBegin = str.find_first_not_of(whitespace);