MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / findAndRemove

Method findAndRemove

tests/cpu/UnitTestLogUtils.cpp:71–86  ·  view source on GitHub ↗

Find and remove specified line from g_output. Return true if found, otherwise, false.

Source from the content-addressed store, hash-verified

69// Find and remove specified line from g_output.
70// Return true if found, otherwise, false.
71bool LogGuard::findAndRemove(const std::string & line) const
72{
73 // Escape the line to prevent error in regex if the line contains regex character.
74 std::string escaped_line = std::regex_replace(line, std::regex("[\\[\\](){}*+?.^$|\\\\]"), "\\$&");
75 std::regex pattern(escaped_line + R"([\r\n]+)");
76 std::smatch match;
77 if (std::regex_search(g_output, match, pattern))
78 {
79 // If the line is found, remove it.
80 auto pos = std::next(g_output.begin(), match.position());
81 auto end = std::next(pos, match.length());
82 g_output.erase(pos, end);
83 return true;
84 }
85 return false;
86}
87
88bool LogGuard::findAllAndRemove(const std::string & sPattern) const
89{

Calls 2

eraseMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected