| 345 | } |
| 346 | |
| 347 | std::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 | |
| 370 | std::string url_encode(const std::string& text) { |
| 371 | char hex[5]; |
no test coverage detected