| 262 | } |
| 263 | |
| 264 | inline std::string fixName(std::string name) |
| 265 | { |
| 266 | |
| 267 | char replaceChar = '_'; |
| 268 | |
| 269 | auto isvalid = [replaceChar](int c) |
| 270 | { |
| 271 | return std::isalpha(c) || std::isdigit(c) || c == replaceChar || c == ' '; |
| 272 | }; |
| 273 | |
| 274 | // if first character isn't an alpha, we |
| 275 | // are going to replace it with _ |
| 276 | if (!std::isalpha(name[0])) |
| 277 | name[0] = replaceChar; |
| 278 | |
| 279 | for (std::size_t i = 0; i < name.size(); ++i) |
| 280 | { |
| 281 | if (!isvalid(name[i])) name[i] = replaceChar; |
| 282 | } |
| 283 | return name; |
| 284 | } |
| 285 | |
| 286 | inline bool nameValid(std::string name) |
| 287 | { |