MCPcopy Create free account
hub / github.com/bitfieldaudio/OTTO / replace_substring

Method replace_substring

external/include/json.hpp:7202–7211  ·  view source on GitHub ↗

! @brief replace all occurrences of a substring by another string @param[in,out] s the string to manipulate; changed so that all occurrences of @a f are replaced with @a t @param[in] f the substring to replace with @a t @param[in] t the string to replace @a f @pre The search string @a f must not be empty. **This precondition is enforced with

Source from the content-addressed store, hash-verified

7200 @since version 2.0.0
7201 */
7202 static void replace_substring(std::string& s, const std::string& f,
7203 const std::string& t)
7204 {
7205 assert(not f.empty());
7206 for (auto pos = s.find(f); // find first occurrence of f
7207 pos != std::string::npos; // make sure f was found
7208 s.replace(pos, f.size(), t), // replace with t, and
7209 pos = s.find(f, pos + t.size())) // find next occurrence of f
7210 {}
7211 }
7212
7213 /// escape "~"" to "~0" and "/" to "~1"
7214 static std::string escape(std::string s)

Callers

nothing calls this directly

Calls 3

findMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected