MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / replace_substring

Function replace_substring

Source/Utils/json.hpp:12349–12359  ·  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 preconditi

Source from the content-addressed store, hash-verified

12347 @since version 2.0.0
12348 */
12349 static void replace_substring(std::string& s, const std::string& f,
12350 const std::string& t)
12351 {
12352 JSON_ASSERT(!f.empty());
12353 for (auto pos = s.find(f); // find first occurrence of f
12354 pos != std::string::npos; // make sure f was found
12355 s.replace(pos, f.size(), t), // replace with t, and
12356 pos = s.find(f, pos + t.size())) // find next occurrence of f
12357 {
12358 }
12359 }
12360
12361 /// escape "~" to "~0" and "/" to "~1"
12362 static std::string escape(std::string s)

Callers 2

escapeFunction · 0.85
unescapeFunction · 0.85

Calls 3

findMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected