MCPcopy Create free account
hub / github.com/CleverRaven/Cataclysm-DDA / string_replace

Function string_replace

src/output.cpp:836–854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834}
835
836std::string string_replace( std::string text, const std::string &before, const std::string &after )
837{
838 // Check if there's something to replace (mandatory) and it's necessary (optional)
839 // Second condition assumes that text is much longer than both &before and &after.
840 if( before.empty() || before == after ) {
841 return text;
842 }
843
844 const size_t before_len = before.length();
845 const size_t after_len = after.length();
846 size_t pos = 0;
847
848 while( ( pos = text.find( before, pos ) ) != std::string::npos ) {
849 text.replace( pos, before_len, after );
850 pos += after_len;
851 }
852
853 return text;
854}
855
856std::string replace_colors( std::string text )
857{

Callers 5

replace_colorsFunction · 0.85
get_dir_gridMethod · 0.85
display_helpMethod · 0.85
list_missionsMethod · 0.85
load_legacy_dataMethod · 0.85

Calls 3

emptyMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected