Aggiunto metodo TString::replace().

git-svn-id: svn://10.65.10.50/trunk@2759 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1996-04-24 16:39:11 +00:00
parent dff1c492ad
commit fb2159ee47
2 changed files with 16 additions and 0 deletions

View File

@ -343,6 +343,20 @@ int TString::find(const char* s, int from) const
return p ? int(p - _str) : -1;
}
int TString::replace(char find_char, char replace_char)
{
const int l = len();
int n = 0;
for (int i = 0; i<l; i++)
if (_str[i] == find_char)
{
_str[i] = replace_char;
n++;
}
return n;
}
// Certified 99%
// @doc EXTERNAL

View File

@ -106,6 +106,8 @@ public:
int find(char, int from = 0) const;
// @cmember Ritorna la posizione della stringa s nell'oggetto TString
int find(const char* s, int from = 0) const;
// @cmember Rimpiazza tutte le occorrenze del carattere find_char con il carattere replace_char. Ritorna il numero di sostituzioni effettuate.
int replace(char find_char, char replace_char);
// @cmember Ritorna l'oggetto TString composto dai count caratteri da sinistra
const TString& left(int count) const;