MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / replace

Function replace

lib/errorlogger.cpp:589–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

587}
588
589static void replace(std::string& source, const std::unordered_map<std::string, std::string> &substitutionMap)
590{
591 std::string::size_type index = 0;
592 while ((index = source.find('{', index)) != std::string::npos) {
593 const std::string::size_type end = source.find('}', index);
594 if (end == std::string::npos)
595 break;
596 const std::string searchFor = source.substr(index, end-index+1);
597 const auto it = substitutionMap.find(searchFor);
598 if (it == substitutionMap.end()) {
599 index += 1;
600 continue;
601 }
602 const std::string& replaceWith = it->second;
603 source.replace(index, searchFor.length(), replaceWith);
604 index += replaceWith.length();
605 }
606}
607
608static void replaceColors(std::string& source, bool erase) {
609 // TODO: colors are not applied when either stdout or stderr is not a TTY because we resolve them before the stream usage

Callers 9

parseFileMethod · 0.85
replaceColorsFunction · 0.85
toStringMethod · 0.85
addStateMethod · 0.85
assumeMethod · 0.85
toNativeSeparatorsMethod · 0.85
fromNativeSeparatorsMethod · 0.85
simplifyPathFunction · 0.85

Calls 3

findMethod · 0.45
endMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected