| 514 | } |
| 515 | |
| 516 | ParamsMultiMap ControllerPrivate::parseAttributes(const QMetaMethod &method, |
| 517 | const QByteArray &str, |
| 518 | const QByteArray &name) |
| 519 | { |
| 520 | ParamsMultiMap ret; |
| 521 | std::vector<std::pair<QString, QString>> attributes; |
| 522 | // This is probably not the best parser ever |
| 523 | // but it handles cases like: |
| 524 | // :Args:Local('fo"')o'):ActionClass('foo') |
| 525 | // into |
| 526 | // (("Args",""), ("Local","'fo"')o'"), ("ActionClass","'foo'")) |
| 527 | |
| 528 | int size = str.size(); |
| 529 | int pos = 0; |
| 530 | while (pos < size) { |
| 531 | // find the start of a key |
| 532 | if (str.at(pos) == ':') { |
| 533 | QString key; |
| 534 | QString value; |
| 535 | int keyStart = ++pos; |
| 536 | int keyLength = 0; |
| 537 | while (pos < size) { |
| 538 | if (str.at(pos) == '(') { |
| 539 | // attribute has value |
| 540 | int valueStart = ++pos; |
| 541 | while (pos < size) { |
| 542 | if (str.at(pos) == ')') { |
| 543 | // found the possible end of the value |
| 544 | int valueEnd = pos; |
| 545 | ++pos; |
| 546 | if (pos < size && str.at(pos) == ':') { |
| 547 | // found the start of a key so this is |
| 548 | // really the end of a value |
| 549 | value = |
| 550 | QString::fromLatin1(str.mid(valueStart, valueEnd - valueStart)); |
| 551 | break; |
| 552 | } else if (pos >= size) { |
| 553 | // found the end of the string |
| 554 | // save the remaining as the value |
| 555 | value = |
| 556 | QString::fromLatin1(str.mid(valueStart, valueEnd - valueStart)); |
| 557 | break; |
| 558 | } |
| 559 | // string was not '):' or ')$' |
| 560 | continue; |
| 561 | } |
| 562 | ++pos; |
| 563 | } |
| 564 | break; |
| 565 | } else if (str.at(pos) == ':') { |
| 566 | // Attribute has no value |
| 567 | break; |
| 568 | } |
| 569 | ++keyLength; |
| 570 | ++pos; |
| 571 | } |
| 572 | |
| 573 | // store the key |