MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / Capturer

Method Capturer

extlibs/catch/include/catch/catch.hpp:11369–11425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11367 }
11368
11369 Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) {
11370 auto trimmed = [&] (size_t start, size_t end) {
11371 while (names[start] == ',' || isspace(names[start])) {
11372 ++start;
11373 }
11374 while (names[end] == ',' || isspace(names[end])) {
11375 --end;
11376 }
11377 return names.substr(start, end - start + 1);
11378 };
11379 auto skipq = [&] (size_t start, char quote) {
11380 for (auto i = start + 1; i < names.size() ; ++i) {
11381 if (names[i] == quote)
11382 return i;
11383 if (names[i] == '\\')
11384 ++i;
11385 }
11386 CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched quote");
11387 };
11388
11389 size_t start = 0;
11390 std::stack<char> openings;
11391 for (size_t pos = 0; pos < names.size(); ++pos) {
11392 char c = names[pos];
11393 switch (c) {
11394 case '[':
11395 case '{':
11396 case '(':
11397 // It is basically impossible to disambiguate between
11398 // comparison and start of template args in this context
11399// case '<':
11400 openings.push(c);
11401 break;
11402 case ']':
11403 case '}':
11404 case ')':
11405// case '>':
11406 openings.pop();
11407 break;
11408 case '"':
11409 case '\'':
11410 pos = skipq(pos, c);
11411 break;
11412 case ',':
11413 if (start != pos && openings.size() == 0) {
11414 m_messages.emplace_back(macroName, lineInfo, resultType);
11415 m_messages.back().message = trimmed(start, pos);
11416 m_messages.back().message += " := ";
11417 start = pos;
11418 }
11419 }
11420 }
11421 assert(openings.size() == 0 && "Mismatched openings");
11422 m_messages.emplace_back(macroName, lineInfo, resultType);
11423 m_messages.back().message = trimmed(start, names.size() - 1);
11424 m_messages.back().message += " := ";
11425 }
11426 Capturer::~Capturer() {

Callers

nothing calls this directly

Calls 4

substrMethod · 0.80
sizeMethod · 0.45
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected