MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / ReplaceInPlace

Function ReplaceInPlace

src/utils/StringUtils.h:253–268  ·  view source on GitHub ↗

In place replace the 'search' substring by the 'replace' string in 'str'.

Source from the content-addressed store, hash-verified

251
252// In place replace the 'search' substring by the 'replace' string in 'str'.
253inline bool ReplaceInPlace(std::string & subject, const std::string & search, const std::string & replace)
254{
255 if (search.empty()) return false;
256
257 bool changed = false;
258
259 size_t pos = 0;
260 while ((pos = subject.find(search, pos)) != std::string::npos)
261 {
262 subject.replace(pos, search.length(), replace);
263 pos += replace.length();
264 changed = true;
265 }
266
267 return changed;
268}
269
270// Replace the 'search' substring by the 'replace' string in 'str'.
271inline std::string Replace(const std::string & subject, const std::string & search, const std::string & replace)

Callers 15

ReplaceFunction · 0.85
BuildResourceNameFunction · 0.85
instantiateDisplayMethod · 0.85
GetLut3DGPUShaderProgramFunction · 0.85
BuildResourceNameIndexedFunction · 0.85
GetLut1DGPUShaderProgramFunction · 0.85
BuildResourceNameIndexedFunction · 0.85
_Add_Reach_tableFunction · 0.85
_Add_Toe_funcFunction · 0.85
_Add_Tonescale_funcFunction · 0.85
_Add_Cusp_tableFunction · 0.85

Calls 1

emptyMethod · 0.45

Tested by 1

OCIO_ADD_TESTFunction · 0.68