mirror of
https://github.com/nasa/trick.git
synced 2025-06-23 01:08:52 +00:00
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:
@ -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);
|
||||
|
Reference in New Issue
Block a user