Parse the text of a function signature from the specified line
| 1610 | |
| 1611 | // Parse the text of a function signature from the specified line |
| 1612 | std::string SourceFileAttributesParser::parseSignature(size_t lineNumber) { |
| 1613 | |
| 1614 | // Look for the signature termination ({ or ; not inside quotes) |
| 1615 | // on this line and then subsequent lines if necessary |
| 1616 | std::string signature; |
| 1617 | for (size_t i = lineNumber; i < (size_t)lines_.size(); i++) { |
| 1618 | std::string line; |
| 1619 | line = lines_[i]; |
| 1620 | bool insideQuotes = false; |
| 1621 | char prevChar = 0; |
| 1622 | // scan for { or ; not inside quotes |
| 1623 | for (size_t c = 0; c < line.length(); ++c) { |
| 1624 | // alias character |
| 1625 | char ch = line.at(c); |
| 1626 | // update quotes state |
| 1627 | if (ch == '"' && prevChar != '\\') |
| 1628 | insideQuotes = !insideQuotes; |
| 1629 | // found signature termination, append and return |
| 1630 | if (!insideQuotes && ((ch == '{') || (ch == ';'))) { |
| 1631 | signature.append(line.substr(0, c)); |
| 1632 | return signature; |
| 1633 | } |
| 1634 | // record prev char (used to check for escaped quote i.e. \") |
| 1635 | prevChar = ch; |
| 1636 | } |
| 1637 | |
| 1638 | // if we didn't find a terminator on this line then just append the line |
| 1639 | // and move on to the next line |
| 1640 | signature.append(line); |
| 1641 | signature.push_back(' '); |
| 1642 | } |
| 1643 | |
| 1644 | // Not found |
| 1645 | return std::string(); // #nocov |
| 1646 | } |
| 1647 | |
| 1648 | |
| 1649 | // Parse arguments from function signature. This is tricky because commas |