- metodi lower() e upper() con parametri from-to
- nuovi metodi shift git-svn-id: svn://10.65.10.50/trunk@5325 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d9bc2873d2
commit
a768fc142a
@ -143,6 +143,24 @@ TString::~TString()
|
||||
delete _str;
|
||||
}
|
||||
|
||||
char TString::shift(int n)
|
||||
{
|
||||
CHECK(n>0,"Scorrimento a destra delle stringhe non ancora supportato");
|
||||
CHECK(n<_size,"Errore di scorrimento");
|
||||
char r=*(_str+n-1);
|
||||
if (n)
|
||||
{
|
||||
char *c=_str;
|
||||
while (*c)
|
||||
{
|
||||
*(c)=*(c+n);
|
||||
c++;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
TString& TString::operator <<(const char* s)
|
||||
{
|
||||
if (s && *s)
|
||||
@ -738,17 +756,21 @@ char* TString::get_buffer(int min_size)
|
||||
return _str;
|
||||
}
|
||||
|
||||
// Certified 100%
|
||||
TString& TString::upper()
|
||||
// Certified 99%
|
||||
TString& TString::upper(int from, int to)
|
||||
{
|
||||
for (char* s = _str; *s; s++) *s = toupper(*s);
|
||||
for (int c=0; *(_str+c) && (to<0 || c<=to); c++)
|
||||
if (c>=from)
|
||||
*(_str+c) = toupper(*(_str+c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Certified 100%
|
||||
TString& TString::lower()
|
||||
// Certified 99%
|
||||
TString& TString::lower(int from, int to)
|
||||
{
|
||||
for (char* s = _str; *s; s++) *s = tolower(*s);
|
||||
for (int c=0; *(_str+c) && (to<0 || c<=to); c++)
|
||||
if (c>=from)
|
||||
*(_str+c) = tolower(*(_str+c));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -179,10 +179,10 @@ public:
|
||||
char* get_buffer(int min_size = -1);
|
||||
|
||||
// @cmember Converte la stringa in maiuscolo
|
||||
TString& upper();
|
||||
TString& upper(int from =0, int to=-1);
|
||||
// @cmember Converte la stringa in minuscolo
|
||||
TString& lower();
|
||||
// @cmember Permette di ttrovare il plurale di una stringa
|
||||
TString& lower(int from =0, int to=-1);
|
||||
// @cmember Permette di trovare il plurale di una stringa
|
||||
TString& add_plural(long num, const char * name);
|
||||
|
||||
// @cmember Assegna la stringa passata con indirizzo
|
||||
@ -192,6 +192,11 @@ public:
|
||||
const TString& operator =(const char* s)
|
||||
{ return set(s); }
|
||||
|
||||
// @cmember Fa scorrere a sinistra la stringa e restituisce l'ultimo carattere scartato
|
||||
char shift(int n=1);
|
||||
// @cmember Fa scorrere a destra la stringa e restituisce l'ultimo carattere scartato
|
||||
char rshift(int n=1)
|
||||
{return shift(-n);}
|
||||
// @cmember Concatena una stringa all'oggetto stringa
|
||||
TString& operator <<(const char*);
|
||||
// @cmember Concatena un carattere all'oggetto stringa
|
||||
|
Loading…
x
Reference in New Issue
Block a user