Aggiunti costruttori a TFilename e TFixedstring

git-svn-id: svn://10.65.10.50/trunk@729 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-12-05 14:23:30 +00:00
parent f653e062d1
commit 74475d0641
9 changed files with 1012 additions and 1003 deletions

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.57 1994-12-02 13:30:09 guy Exp $ // $Id: maskfld.cpp,v 1.58 1994-12-05 14:23:15 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -1902,17 +1902,17 @@ const char* TEdit_field::format(const char* d)
if (fpark.not_empty()) if (fpark.not_empty())
{ {
if (fpark.len() > _size) int len = fpark.len();
if (len > _size)
{ {
#ifdef DBG #ifdef DBG
yesnofatal_box("Campo %d troppo lungo: %d > %d", dlg(), fpark.len(), _size); yesnofatal_box("Campo %d troppo lungo: %d > %d", dlg(), fpark.len(), _size);
#endif #endif
fpark.cut(_size); fpark.cut(len = _size);
} }
if (_flags.uppercase) if (len < _size)
fpark.upper(); {
if (_flags.zerofilled) if (_flags.zerofilled)
{ {
if (isdigit(fpark[0]) && real::is_real(fpark)) if (isdigit(fpark[0]) && real::is_real(fpark))
@ -1923,6 +1923,10 @@ const char* TEdit_field::format(const char* d)
fpark.right_just(_size); fpark.right_just(_size);
} }
if (_flags.uppercase)
fpark.upper();
}
return fpark; return fpark;
} }

View File

@ -1081,7 +1081,7 @@ TSheet_field::~TSheet_field()
void TSheet_field::reset() void TSheet_field::reset()
{ {
_sheet->destroy(); _sheet->destroy();
_sheet->mask().reset(); _sheet->sheet_mask().reset();
} }
// Certified 100% // Certified 100%

View File

@ -686,13 +686,12 @@ const TFilename& TFilename::tempdir()
// Certified 50% // Certified 50%
const TFilename& TFilename::temp(const char* prefix) const TFilename& TFilename::temp(const char* prefix)
{ {
const TFilename dirpref(tempdir()); TFilename dirpref(tempdir());
char* t = NULL;
if (prefix) if (prefix && *prefix)
{ {
set(prefix); // Copia prefisso e ... set(prefix); // Copia prefisso e ...
strip("$#"); // ... toglie caratteri jolly strip("$#*?."); // ... toglie caratteri jolly
const TFixed_string f(prefix); const TFixed_string f(prefix);
#if XVT_OS==XVT_OS_SCOUNIX #if XVT_OS==XVT_OS_SCOUNIX
@ -707,19 +706,24 @@ const TFilename& TFilename::temp(const char* prefix)
*this << pid; *this << pid;
} }
#endif #endif
t = tempnam((char*)(const char*)dirpref, (char*)_str);
} }
else else cut(0);
t = tempnam((char*)(const char*)dirpref, NULL);
TFilename oldtmp(getenv("TMP"));
dirpref.insert("TMP=", 0);
putenv(dirpref);
char* t = tempnam(NULL, (char*)_str);
CHECK(t != NULL, "Can't execute tempnam");
set(t); set(t);
free(t);
oldtmp.insert("TMP=", 0);
putenv(oldtmp);
#ifdef DBG #ifdef DBG
if (fexist(_str)) if (fexist(_str))
fatal_box("Il file '%s' esiste gia'", _str); fatal_box("Il file '%s' esiste gia'", _str);
#endif #endif
if (t) free(t);
return *this; return *this;
} }

View File

@ -80,11 +80,11 @@ public:
const TString& sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso) const TString& sub(int from, int to = -1) const; // Ritorna la stringa da FROM a TO (escluso)
const TString& right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra const TString& right(int count) const; // Ritorna l'oggetto TString composto dai count caratteri da destra
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @DES Modifying methods // @DES Modifying methods
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @FPUB // @FPUB
TString& fill(char c, int n = -1); // Riempie con n caratteri c TString& fill(char c, int n = -1); // Riempie con n caratteri c
TString& spaces(int n = -1) { return fill(' ', n); } TString& spaces(int n = -1) { return fill(' ', n); }
@ -109,11 +109,11 @@ public:
TString& upper(); // Mette la stringa in maiuscolo TString& upper(); // Mette la stringa in maiuscolo
TString& lower(); // Mette la stringa in minuscolo TString& lower(); // Mette la stringa in minuscolo
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @DES Standard operators // @DES Standard operators
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// @FPUB // @FPUB
const TString& operator =(const TString& s) { return set(s._str); } const TString& operator =(const TString& s) { return set(s._str); }
const TString& operator =(const char* s) { return set(s); } const TString& operator =(const char* s) { return set(s); }
@ -165,10 +165,10 @@ class TString16 : public TFixed_string
char _str16[17]; char _str16[17];
public: public:
TString16(const char* str = "") : TFixed_string(_str16, 17) { set(str); } TString16(const char* s = "") : TFixed_string(_str16, 17) { set(s); }
TString16(const TString& s) : TFixed_string(_str16, 17) { set(s); } TString16(const TString& s) : TFixed_string(_str16, 17) { set(s); }
const TString& operator =(const TString& s) { return set((const char*)s); } const TString& operator =(const TString& s) { return set((const char*)s); }
const TString& operator =(const char* str) { return set(str); } const TString& operator =(const char* s) { return set(s); }
}; };
class TString80 : public TFixed_string class TString80 : public TFixed_string
@ -176,9 +176,9 @@ class TString80 : public TFixed_string
char _str80[81]; char _str80[81];
public: public:
TString80(const char* str = "") : TFixed_string(_str80, 81) { set(str); } TString80(const char* s = "") : TFixed_string(_str80, 81) { set(s); }
TString80(const TString& s) : TFixed_string(_str80, 81) { set(s); } TString80(const TString& s) : TFixed_string(_str80, 81) { set(s); }
const TString& operator =(const char* str) { return set(str); } const TString& operator =(const char* s) { return set(s); }
const TString& operator =(const TString& s) { return set((const char*)s); } const TString& operator =(const TString& s) { return set((const char*)s); }
}; };
@ -187,9 +187,9 @@ class TString256 : public TFixed_string
char _str256[257]; char _str256[257];
public: public:
TString256(const char* str = "") : TFixed_string(_str256, 257) { set(str); } TString256(const char* s = "") : TFixed_string(_str256, 257) { set(s); }
TString256(const TString& s) : TFixed_string(_str256, 257) { set(s); } TString256(const TString& s) : TFixed_string(_str256, 257) { set(s); }
const TString& operator =(const char* str) { return set(str); } const TString& operator =(const char* s) { return set(s); }
const TString& operator =(const TString& s) { return set((const char*)s); } const TString& operator =(const TString& s) { return set((const char*)s); }
}; };
@ -205,7 +205,8 @@ public:
// @FPUB // @FPUB
TFilename(const char* n = "") : TString80(n) {} TFilename(const char* n = "") : TString80(n) {}
TFilename(const TString& n) : TString80(n) {} TFilename(const TString& n) : TString80((const char*)n) {}
TFilename(const TFilename& n) : TString80((const char*)n) {}
// assegnazione tra TFile e stringa // assegnazione tra TFile e stringa
const TString& operator =(const char* s) { return set(s); } const TString& operator =(const char* s) { return set(s); }