| 73 | } |
| 74 | |
| 75 | std::unordered_map<std::string, std::string> parseAttributes(const std::string& attrText) { |
| 76 | std::unordered_map<std::string, std::string> result; |
| 77 | std::string text = trim(attrText); |
| 78 | if (text.empty()) return result; |
| 79 | |
| 80 | size_t i = 0; |
| 81 | while (i < text.size()) { |
| 82 | // Extract attribute name |
| 83 | size_t nameStart = i; |
| 84 | while (i < text.size() && text[i] != '(' && text[i] != ',' && text[i] != ']') |
| 85 | ++i; |
| 86 | std::string name = trim(text.substr(nameStart, i - nameStart)); |
| 87 | |
| 88 | std::string value; |
| 89 | if (i < text.size() && text[i] == '(') { |
| 90 | ++i; |
| 91 | int depth = 1; |
| 92 | size_t valStart = i; |
| 93 | while (i < text.size() && depth > 0) { |
| 94 | if (text[i] == '(') depth++; |
| 95 | else if (text[i] == ')') depth--; |
| 96 | ++i; |
| 97 | } |
| 98 | value = trim(text.substr(valStart, i - valStart - 1)); |
| 99 | } |
| 100 | |
| 101 | result[name] = value; |
| 102 | |
| 103 | // Skip comma and whitespace |
| 104 | while (i < text.size() && (text[i] == ',' || isspace((unsigned char)text[i]))) |
| 105 | ++i; |
| 106 | } |
| 107 | |
| 108 | return result; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | Utils::CPP::Struct Utils::CPP::parseDataStruct(const std::string &sourceCode, const std::string &structName) |
no test coverage detected