| 75 | } |
| 76 | |
| 77 | std::string CodeGenerator::stringToUpperCase(std::string_view _str) |
| 78 | { |
| 79 | // replace lower case sharacters with upper case characters and add '_' between words |
| 80 | // words is either Word or WORD, for example TestXMLPanelName return TEST_XML_PANEL_NAME |
| 81 | std::string ret; |
| 82 | if (_str.empty()) |
| 83 | return ret; |
| 84 | bool previousIsLowerCase = false; |
| 85 | for (size_t i = 0; i < _str.length(); i++) |
| 86 | { |
| 87 | if ((i != 0) && |
| 88 | ((previousIsLowerCase && isupper(_str[i])) || |
| 89 | (isupper(_str[i]) && (i + 1 < _str.length()) && islower(_str[i + 1])))) |
| 90 | { |
| 91 | ret.push_back('_'); |
| 92 | } |
| 93 | ret.push_back((char)toupper(_str[i])); |
| 94 | previousIsLowerCase = (islower(_str[i]) != 0); |
| 95 | } |
| 96 | return ret; |
| 97 | } |
| 98 | |
| 99 | void CodeGenerator::printWidgetDeclaration(WidgetContainer* _container, std::ofstream& _stream) |
| 100 | { |