MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / SplitEscapedString

Function SplitEscapedString

test/common/gtest/gtest.cpp:2744–2765  ·  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

2742// escaped. Split them on escaped '\n' boundaries. Leave all other escaped
2743// characters the same.
2744std::vector<std::string> SplitEscapedString(const std::string& str) {
2745 std::vector<std::string> lines;
2746 size_t start = 0, end = str.size();
2747 if (end > 2 && str[0] == '"' && str[end - 1] == '"') {
2748 ++start;
2749 --end;
2750 }
2751 bool escaped = false;
2752 for (size_t i = start; i + 1 < end; ++i) {
2753 if (escaped) {
2754 escaped = false;
2755 if (str[i] == 'n') {
2756 lines.push_back(str.substr(start, i - start - 1));
2757 start = i + 1;
2758 }
2759 } else {
2760 escaped = str[i] == '\\';
2761 }
2762 }
2763 lines.push_back(str.substr(start, end - start));
2764 return lines;
2765}
2766
2767} // namespace
2768

Callers 1

EqFailureFunction · 0.85

Calls 2

push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected