| 67 | } |
| 68 | |
| 69 | void replace_all(std::string & s, const std::string & search, const std::string & replace) { |
| 70 | if (search.empty()) { |
| 71 | return; |
| 72 | } |
| 73 | std::string builder; |
| 74 | builder.reserve(s.length()); |
| 75 | size_t pos = 0; |
| 76 | size_t last_pos = 0; |
| 77 | while ((pos = s.find(search, last_pos)) != std::string::npos) { |
| 78 | builder.append(s, last_pos, pos - last_pos); |
| 79 | builder.append(replace); |
| 80 | last_pos = pos + search.length(); |
| 81 | } |
| 82 | builder.append(s, last_pos, std::string::npos); |
| 83 | s = std::move(builder); |
| 84 | } |
| 85 | |
| 86 | std::string format(const char * fmt, ...) { |
| 87 | va_list ap; |
no test coverage detected