MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / SplitEscapedString

Function SplitEscapedString

source/test/gtest/src/gtest.cc:1535–1556  ·  view source on GitHub ↗

The string representation of the values received in EqFailure() are already escaped. Split them on escaped '\n' boundaries. Leave all other escaped characters the same.

Source from the content-addressed store, hash-verified

1533// escaped. Split them on escaped '\n' boundaries. Leave all other escaped
1534// characters the same.
1535std::vector<std::string> SplitEscapedString(const std::string& str) {
1536 std::vector<std::string> lines;
1537 size_t start = 0, end = str.size();
1538 if (end > 2 && str[0] == '"' && str[end - 1] == '"') {
1539 ++start;
1540 --end;
1541 }
1542 bool escaped = false;
1543 for (size_t i = start; i + 1 < end; ++i) {
1544 if (escaped) {
1545 escaped = false;
1546 if (str[i] == 'n') {
1547 lines.push_back(str.substr(start, i - start - 1));
1548 start = i + 1;
1549 }
1550 } else {
1551 escaped = str[i] == '\\';
1552 }
1553 }
1554 lines.push_back(str.substr(start, end - start));
1555 return lines;
1556}
1557
1558} // namespace
1559

Callers 1

EqFailureFunction · 0.85

Calls 3

sizeMethod · 0.45
push_backMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected