diff options
Diffstat (limited to 'indra/llcommon/llstring.h')
-rw-r--r-- | indra/llcommon/llstring.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index a15d6a9a14..c6dcdd6d12 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -281,7 +281,8 @@ public: static void replaceTabsWithSpaces( std::basic_string<T>& string, size_type spaces_per_tab ); static void replaceNonstandardASCII( std::basic_string<T>& string, T replacement ); static void replaceChar( std::basic_string<T>& string, T target, T replacement ); - + static void replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement ); + static BOOL containsNonprintable(const std::basic_string<T>& string); static void stripNonprintable(std::basic_string<T>& string); @@ -1189,11 +1190,22 @@ template<class T> void LLStringUtilBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement ) { size_type found_pos = 0; - for (found_pos = string.find(target, found_pos); - found_pos != std::basic_string<T>::npos; - found_pos = string.find(target, found_pos)) + while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos ) { string[found_pos] = replacement; + found_pos++; // avoid infinite defeat if target == replacement + } +} + +//static +template<class T> +void LLStringUtilBase<T>::replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement ) +{ + size_type found_pos = 0; + while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos ) + { + string.replace( found_pos, target.length(), replacement ); + found_pos += replacement.length(); // avoid infinite defeat if replacement contains target } } |