MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / replace_all

Function replace_all

plugins/plugin_utils/plugin_utils.cpp:347–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347std::string replace_all(const std::string& in, const std::string& replaceMe, const std::string& withMe) {
348 std::string result;
349 std::string::size_type beginPos = 0;
350 std::string::size_type endPos = 0;
351 std::ostringstream tempStream;
352
353 endPos = in.find(replaceMe);
354 if (endPos == std::string::npos) {
355 return in; // can't find anything to replace
356 }
357 if (replaceMe.empty()) { return in; } // can't replace nothing with something -- can do reverse
358
359 while (endPos != std::string::npos) {
360 // push the part up to
361 tempStream << in.substr(beginPos, endPos - beginPos);
362 tempStream << withMe;
363 beginPos = endPos + replaceMe.size();
364 endPos = in.find(replaceMe, beginPos);
365 }
366 tempStream << in.substr(beginPos);
367 return tempStream.str();
368}
369
370std::string url_encode(const std::string& text) {
371 char hex[5];

Callers 7

doneMethod · 0.70
convertPathToDelimsFunction · 0.70
getFileTextFunction · 0.70
listMethod · 0.50
processMethod · 0.50
keyCallbackMethod · 0.50
getKeyMethod · 0.50

Calls 4

strMethod · 0.80
findMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected