Files Classes Functions Hierarchy
#include <stringconvert.h>
Static Public Member Functions | |
| template<typename T > | |
| static stringc | tostring (T const x) |
| Convert from a data type to a string. | |
| template<typename T > | |
| static void | fromstring (T &x, stringc &s) |
| Convert or interpret from a string to a data type. | |
| static void | findandreplace (string &source, stringc &find, stringc &replace) |
| Repeated replace a string on the original source string. | |
| static stringc | findandreplacefn (stringc &source, stringc &find, stringc &replace) |
| Find and replace function. | |
Definition at line 36 of file stringconvert.h.
Repeated replace a string on the original source string.
Taken from http://snipplr.com/view/1055/find-and-replace-one-string-with-another/
Definition at line 88 of file stringconvert.cpp.
Referenced by htmlstring::serialize(), and htmlstring::serializeInverse().
00093 { 00094 size_t pos = 0; 00095 size_t findlen = find.length(); 00096 size_t replacelen = replace.length(); 00097 00098 if( findlen == 0 ) 00099 return; 00100 00101 for( ; (pos = source.find( find, pos )) != string::npos; ) 00102 { 00103 source.replace( pos, findlen, replace ); 00104 pos += replacelen; 00105 } 00106 }
| stringc stringconvert::findandreplacefn | ( | stringc & | source, | |
| stringc & | find, | |||
| stringc & | replace | |||
| ) | [static] |
Find and replace function.
Definition at line 109 of file stringconvert.cpp.
Referenced by mazedisp03::settings().
00114 { 00115 string str(source); 00116 findandreplace(str,find,replace); 00117 return str; 00118 }
Convert from a data type to a string.
Definition at line 42 of file stringconvert.h.
Referenced by mazegameD2state01::settings(), and mazedisp03::settings().
1.5.8