| 281 | } |
| 282 | |
| 283 | string sanitize_signature(string signature) |
| 284 | { |
| 285 | if (signature.find("->") == string::npos) |
| 286 | { |
| 287 | map<char, size_t> symbol_count{}; |
| 288 | for (auto c: signature) |
| 289 | { |
| 290 | if (c == ',' || c == '-' || c == '>' || c == '\0') |
| 291 | continue; |
| 292 | if (symbol_count.count(c) == 0) |
| 293 | symbol_count[c] = 0; |
| 294 | symbol_count[c]++; |
| 295 | } |
| 296 | for (auto item : symbol_count) |
| 297 | if (item.second != 2) |
| 298 | throw NG_EXCEPTION("Signature does not contain '->'. ATM, this " |
| 299 | "is only allowed if each index appears " |
| 300 | "exactly twice."); |
| 301 | signature += "->"; |
| 302 | } |
| 303 | return signature; |
| 304 | } |
| 305 | |
| 306 | vector<string> split_signature(string signature) |
| 307 | { |