| 250 | } |
| 251 | |
| 252 | static void StringReplace(const string& from, const string& to, string* s) { |
| 253 | // Split *s into pieces delimited by `from`. |
| 254 | std::vector<string> split; |
| 255 | string::size_type pos = 0; |
| 256 | while (pos < s->size()) { |
| 257 | auto found = s->find(from, pos); |
| 258 | if (found == string::npos) { |
| 259 | split.push_back(s->substr(pos)); |
| 260 | break; |
| 261 | } else { |
| 262 | split.push_back(s->substr(pos, found - pos)); |
| 263 | pos = found + from.size(); |
| 264 | if (pos == s->size()) { // handle case where `from` is at the very end. |
| 265 | split.push_back(""); |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | // Join the pieces back together with a new delimiter. |
| 270 | *s = absl::StrJoin(split, to); |
| 271 | } |
| 272 | |
| 273 | static void RenameInDocs(const string& from, const string& to, |
| 274 | ApiDef* api_def) { |
no test coverage detected