Aggiunti metodi rpad e lpad
git-svn-id: svn://10.65.10.50/trunk@4302 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
29124ed600
commit
6e47eeb7de
@ -441,6 +441,38 @@ TString& TString::cut(int n)
|
||||
return *this;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
// @mfunc Espande la stringa fino alla lunghezza indicata, eventualmente aggiungendo spazi a destra
|
||||
TString& TString::rpad(const int n,const char c)
|
||||
{
|
||||
const int & l= len();
|
||||
|
||||
if (n>l)
|
||||
{
|
||||
if (n > size()) resize(n, TRUE);
|
||||
memset(_str+l, c, n-l);
|
||||
_str[n] = '\0';
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
// @mfunc Espande la stringa fino alla lunghezza indicata, eventualmente aggiungendo spazi a sinistra
|
||||
TString& TString::lpad(const int n,const char c)
|
||||
{
|
||||
int l=len();
|
||||
const int nsp=n-l;
|
||||
if (n>l)
|
||||
{
|
||||
if (n > size()) resize(n, TRUE);
|
||||
for (l--; l>=0; l--)
|
||||
*(_str+l+nsp)=*(_str+l);
|
||||
memset(_str, c, nsp);
|
||||
_str[n] = '\0';
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Elimina gli spazi da sinistra o i primi n caratteri (da sinistra).
|
||||
|
@ -154,6 +154,10 @@ public:
|
||||
// @cmember Composizione di <mf TString::ltrim> e <mf TString::rtrim> per eliminare
|
||||
// gli spazi iniziali e finali
|
||||
TString& trim();
|
||||
// @cmember Aggiunge spazi a destra fino alla dimensione indicata
|
||||
TString& rpad(const int n,const char c=' ');
|
||||
// @cmember Aggiunge spazi a destra fino alla dimensione indicata
|
||||
TString& lpad(const int n,const char c=' ');
|
||||
|
||||
// @cmember Giustifica l'oggetto stringa a destra
|
||||
TString& right_just(int n = -1, char c = ' ');
|
||||
|
Loading…
x
Reference in New Issue
Block a user