Aggiunto metodo TString::replace().
git-svn-id: svn://10.65.10.50/trunk@2759 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
dff1c492ad
commit
fb2159ee47
@ -343,6 +343,20 @@ int TString::find(const char* s, int from) const
|
|||||||
return p ? int(p - _str) : -1;
|
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%
|
// Certified 99%
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
@ -106,6 +106,8 @@ public:
|
|||||||
int find(char, int from = 0) const;
|
int find(char, int from = 0) const;
|
||||||
// @cmember Ritorna la posizione della stringa s nell'oggetto TString
|
// @cmember Ritorna la posizione della stringa s nell'oggetto TString
|
||||||
int find(const char* s, int from = 0) const;
|
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
|
// @cmember Ritorna l'oggetto TString composto dai count caratteri da sinistra
|
||||||
const TString& left(int count) const;
|
const TString& left(int count) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user