Patch level : 12.00 1402

Files correlati     : ve01.exe

Commento                :
Corretta generazione report
This commit is contained in:
Alessandro Bonazzi 2026-01-14 23:58:30 +01:00
parent d5673958bf
commit 1d4fc13c13
31 changed files with 566 additions and 283 deletions

View File

@ -148,15 +148,15 @@ void TArray::resize(
// @mfunc Rimuove uno o tutti (default) gli elementi // @mfunc Rimuove uno o tutti (default) gli elementi
// @rdesc Ritorna uno dei seguenti parametri: // @rdesc Ritorna uno dei seguenti parametri:
// //
// @flag TRUE | Se l'operazione e' riuscita con successo // @flag true | Se l'operazione e' riuscita con successo
// @flag FALSE | Se il numero di elementi e' rimasto invariato // @flag false | Se il numero di elementi e' rimasto invariato
bool TArray::destroy( bool TArray::destroy(
int index, // @parm Numero dell'elemento da eliminare (default -1) int index, // @parm Numero dell'elemento da eliminare (default -1)
bool pack) // @parm Se true richiama la funzione <mf TArray::pack> per compattare gli elementi dell'array (default FALSE) bool pack) // @parm Se true richiama la funzione <mf TArray::pack> per compattare gli elementi dell'array (default false)
// @comm Permette la rimozione di uno (index > 0 ) o di tutti (default) gli // @comm Permette la rimozione di uno (index > 0 ) o di tutti (default) gli
// elementi dell'array assegnandone il valore nullptr. // elementi dell'array assegnandone il valore nullptr.
// <nl>Nel caso il parametro pack sia TRUE permette di rendere contigui // <nl>Nel caso il parametro pack sia true permette di rendere contigui
// tutti gli elementi diversi da nullptr tramite la chiamata alla funzione // tutti gli elementi diversi da nullptr tramite la chiamata alla funzione
// <mf TArray::pack>. // <mf TArray::pack>.
@ -278,8 +278,8 @@ void TArray::print_on(
// @mfunc Controlla se si tratta di un oggetto valido // @mfunc Controlla se si tratta di un oggetto valido
// //
// @rdesc Ritorna uno dei seguenti parametri: // @rdesc Ritorna uno dei seguenti parametri:
// @flag TRUE | Se l'array contiene degli elementi // @flag true | Se l'array contiene degli elementi
// @flag FALSE | Se l'array e' vuoto // @flag false | Se l'array e' vuoto
bool TArray::ok() const bool TArray::ok() const
// @comm Controlla se la dimensione dell'array e' uguale a 0 e se esistono // @comm Controlla se la dimensione dell'array e' uguale a 0 e se esistono
@ -420,7 +420,7 @@ int TArray::insert(const TObject& object, int index, bool force)
TObject* TArray::remove( TObject* TArray::remove(
int index, // @parm Indica la posizione dell'elemento da eliminare int index, // @parm Indica la posizione dell'elemento da eliminare
bool dopack) // @parm Indica se si vuole richiamare la funzione bool dopack) // @parm Indica se si vuole richiamare la funzione
// <mf TArray::pack> (default FALSE) per spostare gli elementi successivi dell'array // <mf TArray::pack> (default false) per spostare gli elementi successivi dell'array
{ {
CHECKD(index >= 0, "Can't remove array item ", index); CHECKD(index >= 0, "Can't remove array item ", index);
@ -449,8 +449,8 @@ TObject* TArray::remove_item(bool pack )
void TArray::swap(int i1, int i2) void TArray::swap(int i1, int i2)
{ {
TObject* o1 = remove(i1, FALSE); TObject* o1 = remove(i1, false);
TObject* o2 = remove(i2, FALSE); TObject* o2 = remove(i2, false);
if (o1) add(o1, i2); if (o1) add(o1, i2);
if (o2) add(o2, i1); if (o2) add(o2, i1);
} }
@ -855,15 +855,15 @@ int TFiles_array::find(const char* s, int from) const // @parm Posizione dalla q
// @mfunc Rimuove uno o tutti (default) gli elementi // @mfunc Rimuove uno o tutti (default) gli elementi
// @rdesc Ritorna uno dei seguenti parametri: // @rdesc Ritorna uno dei seguenti parametri:
// //
// @flag TRUE | Se l'operazione e' riuscita con successo // @flag true | Se l'operazione e' riuscita con successo
// @flag FALSE | Se il numero di elementi e' rimasto invariato // @flag false | Se il numero di elementi e' rimasto invariato
bool TPointer_array::destroy( bool TPointer_array::destroy(
int index, // @parm Numero dell'elemento da eliminare (default -1) int index, // @parm Numero dell'elemento da eliminare (default -1)
bool pack) // @parm Se true richiama la funzione <mf TArray::pack> per compattare gli elementi dell'array (default FALSE) bool pack) // @parm Se true richiama la funzione <mf TArray::pack> per compattare gli elementi dell'array (default false)
// @comm Permette la rimozione di uno (index > 0 ) o di tutti (default) gli // @comm Permette la rimozione di uno (index > 0 ) o di tutti (default) gli
// elementi dell'array assegnandone il valore nullptr. // elementi dell'array assegnandone il valore nullptr.
// <nl>Nel caso il parametro pack sia TRUE permette di rendere contigui // <nl>Nel caso il parametro pack sia true permette di rendere contigui
// tutti gli elementi diversi da nullptr tramite la chiamata alla funzione // tutti gli elementi diversi da nullptr tramite la chiamata alla funzione
// <mf TArray::pack>. // <mf TArray::pack>.
@ -1028,7 +1028,7 @@ void TBit_array::resize(
bool TBit_array::operator[] (long n) const bool TBit_array::operator[] (long n) const
{ {
const word i = index(n); const word i = index(n);
if (i >= _size) return FALSE; if (i >= _size) return false;
return (_bit[i] & mask(n)) != 0; return (_bit[i] & mask(n)) != 0;
} }
@ -1167,8 +1167,8 @@ bool TBit_array::some_one() const
// //
// @rdesc Ritorna uno dei seguenti parametri: // @rdesc Ritorna uno dei seguenti parametri:
// //
// @flag TRUE | Se l'array contiene degli elementi // @flag true | Se l'array contiene degli elementi
// @flag FALSE | Se l'array e' vuoto // @flag false | Se l'array e' vuoto
bool TBit_array::ok() const bool TBit_array::ok() const
// @comm Controlla se la dimensione dell'array e' maggiore di 0 e se esistono // @comm Controlla se la dimensione dell'array e' maggiore di 0 e se esistono
@ -1361,7 +1361,7 @@ TObject* TMatrix::remove(
int r, // @parm Riga in cui aggiungere l'oggetto int r, // @parm Riga in cui aggiungere l'oggetto
int c, // @parm Colonna in cui aggiungere l'oggetto int c, // @parm Colonna in cui aggiungere l'oggetto
bool dopack) // @parm Indica se si vuole richiamare la funzione bool dopack) // @parm Indica se si vuole richiamare la funzione
// <mf TMatrix::pack> (default FALSE) per spostare gli elementi successivi dell'array // <mf TMatrix::pack> (default false) per spostare gli elementi successivi dell'array
{ {
TArray & rw = operator[](r); TArray & rw = operator[](r);

View File

@ -5,6 +5,10 @@
#include <object.h> #include <object.h>
#endif #endif
#ifndef __RECTYPES_H
#include <rectypes.h>
#endif
#ifndef NULL #ifndef NULL
#define NULL 0L #define NULL 0L
#endif #endif
@ -95,12 +99,11 @@ public:
// @class TFilepos | oggetto per incapsulare una posizione su file (streampos) // @class TFilepos | oggetto per incapsulare una posizione su file (streampos)
// @base public | TObject // @base public | TObject
class TFilepos : public TObject class TFilepos : public TSortable
// @author:(INTERNAL) Alex // @author:(INTERNAL) Alex
{ {
// @access:(INTERNAL) Private Member // @access:(INTERNAL) Private Member
// @cmember:(INTERNAL) posizione // @cmember:(INTERNAL) posizione
streampos _pos; streampos _pos;
@ -109,13 +112,16 @@ protected:
// @cmember Permette di stampare l'oggetto // @cmember Permette di stampare l'oggetto
virtual void print_on(ostream& out) const { out << _pos; } virtual void print_on(ostream& out) const { out << _pos; }
// @cmember Duplica il numero reale (vedi classe <c TObject>) TFilepos & copy(const TFilepos & p) { _pos = p._pos; return *this; }
virtual TObject* dup() const { return new TFilepos(*this); }
// @access Public Member // @access Public Member
public: public:
const streampos & pos() const { return _pos ; } virtual int compare(const TSortable& s) const { return (int)(_pos - ((const TFilepos&)s)._pos); }
TFilepos& operator =(const TFilepos& p) { _pos = p._pos; return *this; } // @cmember Duplica la posizione (vedi classe <c TObject>)
virtual TObject* dup() const { return new TFilepos(*this); }
streampos val() const { return _pos ; }
operator streampos() const { return val(); }
TFilepos& operator =(const TFilepos& p) { return copy(p); }
// @cmember Aggiunge ad un reale il valore passato (passato per indirizzo) // @cmember Aggiunge ad un reale il valore passato (passato per indirizzo)
// @cmember Costruttore // @cmember Costruttore
TFilepos() : _pos(0L) {} TFilepos() : _pos(0L) {}
@ -131,6 +137,29 @@ public:
virtual ~TFilepos() {} virtual ~TFilepos() {}
}; };
class TORecnotype :public TSortable // @author:(INTERNAL) Bonazzi
// TORecnotype per utilizzarlo negli array
{
TRecnotype _r;
protected:
// @cmember Permette di stampare l'oggetto
virtual void print_on(ostream& out) const { out << _r; }
TORecnotype & copy(const TORecnotype & r) { _r = r._r; return *this; }
public:
virtual int compare(const TSortable& s) const override { return int(_r - ((TORecnotype&)s)._r); }
virtual TObject* dup() const { return new TORecnotype(*this); }
TRecnotype val() const { return _r; }
operator long() const { return val(); }
TORecnotype & operator ==(TORecnotype& r) { return copy(r); }
TORecnotype & operator ==(TRecnotype r) { _r = r; return *this; }
TORecnotype(TRecnotype r = 0L) : _r(r) { }
~TORecnotype() = default;
};
// @doc EXTERNAL // @doc EXTERNAL
// @class TContainer | Generico contenitore ad accesso casuale (con indice) // @class TContainer | Generico contenitore ad accesso casuale (con indice)
@ -241,8 +270,6 @@ public:
virtual bool is_kind_of(word cid) const; virtual bool is_kind_of(word cid) const;
// @cmember Stampa un array // @cmember Stampa un array
virtual void print_on(ostream& out) const ; virtual void print_on(ostream& out) const ;
// @cmember Controlla se si tratta di un oggetto valido
virtual bool ok() const ;
// @cmember Ritorna la grandezza dell'array // @cmember Ritorna la grandezza dell'array
int size() const int size() const
@ -273,6 +300,8 @@ public:
// @cmember Ritorna l'indice del primo oggetto che precede l'i-esimo // @cmember Ritorna l'indice del primo oggetto che precede l'i-esimo
int pred(int i) const; int pred(int i) const;
// @cmember Controlla se si tratta di un oggetto valido
bool ok() const;
// @cmember Ritorna l'oggetto nella posizione index // @cmember Ritorna l'oggetto nella posizione index
TObject& operator[] (int index) const ; TObject& operator[] (int index) const ;
// @cmember Ritorna l'oggetto nella posizione index // @cmember Ritorna l'oggetto nella posizione index
@ -471,6 +500,7 @@ public:
virtual ~TFiles_array() virtual ~TFiles_array()
{} {}
}; };
class TPointer_array : public TArray class TPointer_array : public TArray
{ {
protected: protected:

View File

@ -603,7 +603,7 @@ bool TConfig::set(const char* var, long value, const char* section,
bool force, int index) bool force, int index)
{ {
TString16 t; t << value; TString16 t; t << value;
return set(var,t,section,force,index); return set(var, t, section, force, index);
} }
bool TConfig::set_color(const char* var, COLOR col, const char* section, bool TConfig::set_color(const char* var, COLOR col, const char* section,
@ -940,6 +940,13 @@ void ini_del_memo(const char* file, const char* para, const char* name)
ini_remove(file, para, name, i); ini_remove(file, para, name, i);
} }
void ini_remove_paragraph(const char* file, const char* para)
{
TConfig cfg(file, para);
cfg.remove_all();
}
int ini_get_rows_memo(const char* file, const char* para, const char* name) int ini_get_rows_memo(const char* file, const char* para, const char* name)
{ {
int idx = 0; int idx = 0;
@ -1128,7 +1135,6 @@ bool ini_remove_array(int cfg, const char* para, const char* name)
return ini_remove_array(filename, para, name); return ini_remove_array(filename, para, name);
} }
const TString& ini_get_memo(int cfg, const char* para, const char* name) const TString& ini_get_memo(int cfg, const char* para, const char* name)
{ {
DECLARE_FILENAME(cfg); DECLARE_FILENAME(cfg);
@ -1177,6 +1183,12 @@ void ini_del_memo(int cfg, const char* para, const char* name)
ini_del_memo(filename, para, name); ini_del_memo(filename, para, name);
} }
void ini_remove_paragraph(int cfg, const char* para)
{
DECLARE_FILENAME(cfg);
ini_remove_paragraph(filename, para);
}
const TString& get_oem_info(const char* varname, const char* def) const TString& get_oem_info(const char* varname, const char* def)
{ {
TString& tmp = get_tmp_string(50); TString& tmp = get_tmp_string(50);

View File

@ -221,6 +221,7 @@ void ini_set_memo (const char* file, const char* paragraph, const char* na
int ini_get_rows_memo(const char* file, const char* paragraph, const char* name); int ini_get_rows_memo(const char* file, const char* paragraph, const char* name);
const TString& ini_get_line_memo(const char* file, const char* paragraph, const char* name, int idx); const TString& ini_get_line_memo(const char* file, const char* paragraph, const char* name, int idx);
void ini_del_memo (const char* file, const char* para, const char* name); void ini_del_memo (const char* file, const char* para, const char* name);
void ini_remove_paragraph(const char* file, const char* para);
// High level utilities // High level utilities
bool ini_get_bool (int cfg, const char* para, const char* name, bool defval = false, int idx = -1); bool ini_get_bool (int cfg, const char* para, const char* name, bool defval = false, int idx = -1);
@ -240,6 +241,7 @@ bool ini_remove_array(int cfg, const char* para, const char* name);
const TString& ini_get_memo (int cfg, const char* para, const char* name); const TString& ini_get_memo (int cfg, const char* para, const char* name);
void ini_set_memo (int cfg, const char* para, const char* name, const char* msg); void ini_set_memo (int cfg, const char* para, const char* name, const char* msg);
void ini_del_memo (int cfg, const char* para, const char* name); void ini_del_memo (int cfg, const char* para, const char* name);
void ini_remove_paragraph(int cfg, const char* para);
const TString& get_oem_info(const char* varname, const char* defval = ""); // ini_get_string(CONFIG_OEM, "OEM_?", varname, defval); const TString& get_oem_info(const char* varname, const char* defval = ""); // ini_get_string(CONFIG_OEM, "OEM_?", varname, defval);
bool is_aga_version(bool power_user_only = false); bool is_aga_version(bool power_user_only = false);

View File

@ -907,6 +907,9 @@ void TExpression::eval()
evalstack.push(perc); evalstack.push(perc);
} }
break; break;
case _abs:
evalstack.peek_real() = abs(evalstack.peek_real());
break;
default: default:
NFCHECK("operazione non valida %d", (int) instr.getsym()); NFCHECK("operazione non valida %d", (int) instr.getsym());
break; break;
@ -926,22 +929,22 @@ HIDDEN char _tok[255];
TCodesym TExpression::tok2fun(const char* tok) const TCodesym TExpression::tok2fun(const char* tok) const
{ {
const int MAX_TOK = 35; const int MAX_TOK = 36;
HIDDEN const char* fnstr[MAX_TOK] = { "ANSI", "BETWEEN","BOOL", "CEIL", "CF_CHECK", HIDDEN const char* fnstr[MAX_TOK] = { "ABS", "ANSI", "BETWEEN","BOOL", "CEIL", "CF_CHECK",
"COS", "EXP", "EXP10", "IF", "LEFT", "LEN", "COS", "EXP", "EXP10", "IF", "LEFT", "LEN",
"LOG", "LOG10", "MAX", "MID", "MIN", "LOG", "LOG10", "MAX", "MID", "MIN",
"NUM", "PERC", "PI_CHECK","POW", "RIGHT", "NUM", "PERC", "PI_CHECK","POW", "RIGHT",
"ROUND", "SCON2PERC", "SCORP","SIN", "SQR", "SQRT", "ROUND", "SCON2PERC", "SCORP","SIN", "SQR", "SQRT",
"STR", "SUBSTR", "TAN", "TRIM", "TRUNC", "STR", "SUBSTR", "TAN", "TRIM", "TRUNC",
"UPPER", "YEAR", "ZEROFILL" }; "UPPER", "YEAR", "ZEROFILL", };
HIDDEN TCodesym fntok[MAX_TOK] = { _ansi, _between, _bool, _ceil, _cfcheck, HIDDEN TCodesym fntok[MAX_TOK] = { _abs, _ansi, _between, _bool, _ceil, _cfcheck,
_cos, _exp, _exp10, _if, _left, _len, _cos, _exp, _exp10, _if, _left, _len,
_log, _log10, _max, _mid, _min, _log, _log10, _max, _mid, _min,
_num, _perc, _picheck, _pow, _right, _num, _perc, _picheck, _pow, _right,
_round, _scon2perc,_scorp, _sin, _sqr, _round, _scon2perc,_scorp, _sin, _sqr,
_sqrt, _str, _substr, _tan, _trim, _sqrt, _str, _substr, _tan, _trim,
_trunc, _upper, _year, _zerofill }; _trunc, _upper, _year, _zerofill};
int f = 0, l = MAX_TOK-1, i = MAX_TOK/2; int f = 0, l = MAX_TOK-1, i = MAX_TOK/2;
for (;;) for (;;)
@ -1260,6 +1263,7 @@ TCodesym TExpression::__factor(TCodesym startsym)
case _year: case _year:
case _scon2perc: case _scon2perc:
case _bool: case _bool:
case _abs:
sym = __function(1); sym = __function(1);
_code.add(startsym); _code.add(startsym);
break; break;

View File

@ -80,6 +80,7 @@ enum TCodesym {
_zerofill, // @emem riepie di zeri l'inizio di una stringa _zerofill, // @emem riepie di zeri l'inizio di una stringa
_scon2perc, // @emem converte una espressione in percentuale di sconto _scon2perc, // @emem converte una espressione in percentuale di sconto
_bool, // @emem converte una espressione in booleano (0 o 1) _bool, // @emem converte una espressione in booleano (0 o 1)
_abs // @emem valore assoluto
}; };
// @doc INTERNAL // @doc INTERNAL

View File

@ -84,7 +84,8 @@ bool html2pdf(const char* url, const char * dest)
TExternal_app app(cmd); TExternal_app app(cmd);
return app.run(false, false) == 0; app.run(false, false);
return true;
} }
bool xml2html(const char* xml, const char * style, bool add, const char * dest) bool xml2html(const char* xml, const char * style, bool add, const char * dest)
@ -657,7 +658,7 @@ bool TGolem_field::on_key(KEY key)
do_message(0); do_message(0);
} }
else else
if (key == K_ESC) if (key == K_ESC && _tool)
update_tool(); update_tool();
} }
else else

View File

@ -450,7 +450,7 @@ HIDDEN void browse_null(char *start, int nc)
// Traduce l'espressione chiave di CodeBase // Traduce l'espressione chiave di CodeBase
HIDDEN int __build_key(const RecDes& recd, int numkey, const RecType recin, char *key, bool build_x_cb) HIDDEN int __build_key(const RecDes& recd, int numkey, const RecType recin, char *key, bool build_x_cb, bool token = false)
/* *recd; descrittore record */ /* *recd; descrittore record */
/* numkey; numero chiave */ /* numkey; numero chiave */
/* recin; buffer contenente il record */ /* recin; buffer contenente il record */
@ -511,36 +511,36 @@ HIDDEN int __build_key(const RecDes& recd, int numkey, const RecType recin, cha
int w = l, j = l + len; int w = l, j = l + len;
while (w < j && key[w] == ' ') w++; while (w < j && key[w] == ' ') w++;
while (w < j && key[w] == '0') key[w++] = ' '; while (w < j && key[w] == '0') key[w++] = ' ';
if (w == j) key[w-1] = build_x_cb ? '0' : null_char; if (w == j) key[w - 1] = build_x_cb ? '0' : null_char;
} }
if (upp) if (upp)
for (int i = l+len-1; i >= l; i--) for (int i = l + len - 1; i >= l; i--)
key[i] = toupper(key[i]); key[i] = toupper(key[i]);
l += len; l += len;
if (!build_x_cb && token && i < recd.Ky[numkey].NkFields - 1)
key[l++] = '';
} }
// rtrim // rtrim
if (build_x_cb) if (build_x_cb)
{ {
for (l--; l>=0 && key[l] == ' '; l--); for (l--; l >= 0 && key[l] == ' '; l--);
key[l + 1] = '\0'; key[l + 1] = '\0';
} }
else else
{ {
for (l--; l>=0 && (key[l] == ' ' || key[l] == null_char); l--); for (l--; l >= 0 && (key[l] == ' ' || key[l] == null_char); l--);
key[l + 1] = '\0'; key[l + 1] = '\0';
for (;l >= 0; l--) for (; l >= 0; l--)
if (key[l] == null_char) if (key[l] == null_char)
key[l] = '0'; key[l] = '0';
} }
return(NOERR); return(NOERR);
} }
return(_ispatherr); return(_ispatherr);
} }
HIDDEN int cisread(int fhnd, int knum, TRectype& record, int mode, TRecnotype& curr_recno) HIDDEN int cisread(int fhnd, int knum, TRectype& record, int mode, TRecnotype& curr_recno)
{ {
CHECKD(fhnd >= 0, "Can't use codebase handle ", fhnd); CHECKD(fhnd >= 0, "Can't use codebase handle ", fhnd);
@ -3635,6 +3635,18 @@ const char* TRectype::build_key(int num) const
return tmp; return tmp;
} }
const TToken_string & TRectype::build_token_key(int num) const
{
TString256 str;
TToken_string& tmp = get_tmp_string(256);
__build_key(rec_des(), num, string(), str.get_buffer(), false, true);
str.replace("", "|");
tmp = str;
return tmp;
}
const char* TRectype::last_key_field(int key) const const char* TRectype::last_key_field(int key) const
{ {
const KeyDes& kd = rec_des().Ky[key]; const KeyDes& kd = rec_des().Ky[key];

View File

@ -195,6 +195,8 @@ public:
// @cmember Ritorna il valaore della chiave <p key>-esima di ordinamento sul file // @cmember Ritorna il valaore della chiave <p key>-esima di ordinamento sul file
const char* build_key(int key = 1) const; const char* build_key(int key = 1) const;
// @cmember Ritorna il valaore della chiave <p key>-esima di ordinamento sul file come Token_string
const TToken_string & TRectype::build_token_key(int num) const;
// @cmember Confronta le chiavi di due record // @cmember Confronta le chiavi di due record
int compare_key(const TRectype& rec, int key = 1, int skip_last = 0) const; int compare_key(const TRectype& rec, int key = 1, int skip_last = 0) const;
// @cmember Ritorna true se le chiavi di due record sono uguali (vedi <mf TRectype::compare_key>) // @cmember Ritorna true se le chiavi di due record sono uguali (vedi <mf TRectype::compare_key>)

View File

@ -2,22 +2,22 @@
#include <diction.h> #include <diction.h>
#include <isamrpc.h> #include <isamrpc.h>
#include <netsock.h> #include <netsock.h>
#include <utility.h>
static TSocketClient* _client = NULL; HIDDEN TSocketClient* _client = nullptr;
HIDDEN CONNID _connection = 0;
static CONNID _connection = 0;
bool rpc_Start() bool rpc_Start()
{ {
bool ok = true; bool ok = true;
if (_client == NULL) if (_client == nullptr)
{ {
srand(clock()); srand(clock());
_client = new TSocketClient; _client = new TSocketClient;
if (!_client->IsOk()) if (!_client->IsOk())
{ {
delete _client; delete _client;
_client = NULL; _client = nullptr;
ok = error_box(TR("Errore di inizializzazione del socket client.")); ok = error_box(TR("Errore di inizializzazione del socket client."));
} }
} }
@ -29,7 +29,7 @@ bool rpc_Stop()
if (_client) if (_client)
{ {
delete _client; delete _client;
_client = NULL; _client = nullptr;
_connection = 0; _connection = 0;
} }
return true; return true;
@ -44,7 +44,7 @@ bool rpc_Call(const char* cmd)
int rpc_Timeout(int sec) int rpc_Timeout(int sec)
{ {
CHECK(_client != NULL, "Client not initialized"); CHECK(_client != nullptr, "Client not initialized");
const int to = _client->Timeout(); const int to = _client->Timeout();
if (sec >= 0) if (sec >= 0)
_client->SetTimeout(sec); _client->SetTimeout(sec);
@ -295,13 +295,13 @@ static unsigned int create_password(TString& pass)
bool rpc_UserLogin(const char* server, const char* user, bool rpc_UserLogin(const char* server, const char* user,
const char* dummy_password, const char* application) const char* dummy_password, const char* application)
{ {
if (_client == NULL) if (_client == nullptr)
{ {
if (!rpc_Start()) if (!rpc_Start())
return false; return false;
} }
const bool local = server == NULL || *server == '\0' || const bool local = server == nullptr || *server == '\0' ||
xvt_str_same(server, "127.0.0.1") || xvt_str_same(server, "127.0.0.1") ||
xvt_str_same(server, "localhost"); xvt_str_same(server, "localhost");
TString80 name; TString80 name;
@ -484,7 +484,7 @@ bool http_dir(const char* server, const char* remote_dir, TString_array& list, i
} }
bool http_post(const char* server, const char* remote_file, TString & content, char * & answer, size_t& length, bool http_post(const char* server, const char* remote_file, TString & content, char * & answer, size_t& length,
int timeout, int port, bool port_stmt, int type, const char * agent, const char* authorization) int timeout, int port, bool port_stmt, http_media_types type, const char * agent, const char* authorization)
{ {
TSocketClient client; TSocketClient client;
@ -515,7 +515,7 @@ bool http_post(const char* server, const char* remote_file, TString & content, c
bool http_post(const char* server, const char* remote_file, bool http_post(const char* server, const char* remote_file,
const char* local_file, char * & answer, size_t& length, const char* local_file, char * & answer, size_t& length,
int timeout, int port, bool port_stmt, int type, const char * agent, const char* authorization) int timeout, int port, bool port_stmt, http_media_types type, const char * agent, const char* authorization)
{ {
TSocketClient client; TSocketClient client;
@ -544,6 +544,90 @@ bool http_post(const char* server, const char* remote_file,
return ok; return ok;
} }
bool http_curl_get(const char* url, const char* remote_file, const char* local_file, const char* user, const char * password)
{
TString remote = url;
remote << remote_file;
int rescode = xvt_http_get(remote, local_file, user, password);
bool ok = rescode > 199 && rescode < 400;
if (!ok)
error_box(FR("Impossibile ricevere il file %s errore %d"), remote_file, rescode);
return ok;
}
bool http_curl_dir(const char* url, const char* remote_dir, const char * type, bool subdirs, TString_array& list, const char* user, const char * password)
{
TString remote = url;
list.destroy();
remote << remote_dir;
if (!remote.ends_with("/"))
remote << "/";
SLIST files = xvt_fsys_list_files("", remote, subdirs);
const int count = xvt_slist_count(files);
if (count > 0)
{
for (SLIST_ELT e = xvt_slist_get_first(files); e; e = xvt_slist_get_next(files, e))
{
const char* n = xvt_slist_get(files, e, nullptr);
list.add(n);
}
}
xvt_slist_destroy(files);
return list.items() > 0;
}
bool http_curl_post(const char* url, const char* remote_file,
http_media_types type, TString& request, TString& answer,
const char* user, const char * password)
{
TFilename temp;
TString remote = url;
remote << remote_file ;
temp.temp("post");
int rescode = xvt_http_post(remote, temp, http_content(type), request, user, password);
bool ok = rescode > 199 && rescode < 400;
if (!ok)
error_box(FR("Post fallito %s errore %d"), (const char *)remote,
(const char *)rescode);
else
{
long size = fsize(temp);
ifstream resp(temp);
char * buffer = new char[size + 1];
resp.read(buffer, size);
buffer[size] = '\0';
answer = buffer;
}
return ok;
}
bool http_curl_put(const char* url, const char* local_file, const char* remote_file, const char* user, const char * password)
{
TString remote = url;
remote << remote_file;
int rescode = xvt_http_get(local_file, remote, user, password);
bool ok = rescode > 199 && rescode < 400;
if (!ok)
error_box(FR("Impossibile inviare il file %s errore %d"), local_file, rescode);
return ok;
}
bool ftp_get(const char* server, const char* remote_file, const char* local_file, bool ftp_get(const char* server, const char* remote_file, const char* local_file,
int port, const char * user, const char* pass) int port, const char * user, const char* pass)
{ {

View File

@ -5,11 +5,16 @@
#include <real.h> #include <real.h>
#endif #endif
#define CONTENT_TXT 0 #ifndef __STRINGS_H
#define CONTENT_JSON 1 #include <strings.h>
#endif
#ifndef __MEDIATYPES_H
#include <mediatypes.h>
#endif
bool rpc_Call(const char* cmd); bool rpc_Call(const char* cmd);
char* rpc_Request(const char* cmd, unsigned long& size, real& time); // char* rpc_Request(const char* cmd, unsigned long& size, real& time);
bool rpc_DongleHasModule(word af); bool rpc_DongleHasModule(word af);
bool rpc_DongleModules(TBit_array& ba); bool rpc_DongleModules(TBit_array& ba);
@ -27,14 +32,33 @@ bool rpc_Start();
bool rpc_Stop(); bool rpc_Stop();
bool http_isredirected_server(TString & server, TFilename & remote_file, int port = 0, const char* authorization = nullptr); bool http_isredirected_server(TString & server, TFilename & remote_file, int port = 0, const char* authorization = nullptr);
bool http_get(const char* server, const char* remote_file, const char* local_file, bool http_get(const char* server, const char* remote_file, const char* local_file,
int port = 80, const char * agent = nullptr, const char* authorization = nullptr); int port = 80, const char * agent = nullptr, const char* authorization = nullptr);
bool http_dir(const char* server, const char* remote_dir, TString_array & list, bool http_dir(const char* server, const char* remote_dir, TString_array & list,
int port = 80, const char * agent = nullptr, const char* authorization = nullptr); int port = 80, const char * agent = nullptr, const char* authorization = nullptr);
bool http_post(const char* server, const char* remote_file, TString & content, char * & answer, size_t& length, bool http_post(const char* server, const char* remote_file, TString & content, char * & answer, size_t& length,
int timeout, int port = 80, bool port_stmt = true, int type = CONTENT_TXT, const char * agent = nullptr, const char* authorization = nullptr); int timeout, int port = 80, bool port_stmt = true, int type = media_txt, const char * agent = nullptr, const char* authorization = nullptr);
bool http_post(const char* server, const char* remote_file, const char* local_file, char * & answer, size_t& length, bool http_post(const char* server, const char* remote_file, const char* local_file, char * & answer, size_t& length,
int timeout, int port = 80, bool port_stmt = true, int type = CONTENT_TXT, const char * agent = nullptr, const char* authorization = nullptr); int timeout, int port = 80, bool port_stmt = true, http_media_types type = media_txt, const char * agent = nullptr, const char* authorization = nullptr);
bool http_curl_get(const char* url, const char* remote_file,
const char* local_file,
const char* user = nullptr,
const char * password = nullptr);
bool http_curl_dir(const char* url, const char* remote_dir,
const char * type, bool subdirs, TString_array& list,
const char* user = nullptr,
const char * password = nullptr);
bool http_curl_post(const char* url, const char* remote_file,
http_media_types type, TString& request,
TString& answer, const char* user = nullptr,
const char * password = nullptr);
bool http_curl_put(const char* url, const char* local_file,
const char* remote_file,
const char* user = nullptr,
const char * password = nullptr);
bool ftp_get(const char* server, const char* remote_file, const char* local_file, bool ftp_get(const char* server, const char* remote_file, const char* local_file,
int port = 21, const char * user = nullptr, const char* pass = nullptr); int port = 21, const char * user = nullptr, const char* pass = nullptr);
bool ftp_dir(const char* server, const char* remote_dir, TString_array & list, bool ftp_dir(const char* server, const char* remote_dir, TString_array & list,

View File

@ -567,7 +567,7 @@ public:
// @cmember Controlla se il campo ha un messaggio // @cmember Controlla se il campo ha un messaggio
virtual bool has_message() const virtual bool has_message() const
{ return _message != NULL; } { return _message != nullptr; }
// @cmember Setta l'handler del controllo // @cmember Setta l'handler del controllo
virtual void set_handler(CONTROL_HANDLER handler) virtual void set_handler(CONTROL_HANDLER handler)
@ -926,7 +926,7 @@ public:
virtual bool has_check() const; virtual bool has_check() const;
// @cmember Controlla se il campo ha una ricerca // @cmember Controlla se il campo ha una ricerca
virtual bool has_query_button() const virtual bool has_query_button() const
{ return _browse != NULL || _flags.button; } { return _browse != nullptr || _flags.button; }
// @cmember Imposta la ricerca del campo // @cmember Imposta la ricerca del campo
virtual void set_query_button(TBrowse_button* ); virtual void set_query_button(TBrowse_button* );

View File

@ -1790,5 +1790,5 @@ typedef enum {
media_zstd } http_media_types; media_zstd } http_media_types;
const char * http_content(http_media_types type); const char * http_content(http_media_types type);
#endif #endif

View File

@ -6,6 +6,7 @@ extern "C"
#include <xiutils.h> #include <xiutils.h>
} }
#include <automask.h>
#include <colors.h> #include <colors.h>
#include <config.h> #include <config.h>
#include <controls.h> #include <controls.h>
@ -194,6 +195,10 @@ bool TRow_property::get(int col, COLOR & back, COLOR & fore) const
// di una maschera // di una maschera
// //
// @base public | TWindow // @base public | TWindow
// @cmember:(INTERNAL) costanti
enum { MAX_COL = 96 };
class TSpreadsheet : public TControl class TSpreadsheet : public TControl
{ {
// @author:(INTERNAL) Guido // @author:(INTERNAL) Guido
@ -202,8 +207,6 @@ class TSpreadsheet : public TControl
friend class TSheet_field; friend class TSheet_field;
// @access:(INTERNAL) Private Member // @access:(INTERNAL) Private Member
// @cmember:(INTERNAL) costanti
enum { MAX_COL=96 };
static int ROW_NUMBER_WIDTH; static int ROW_NUMBER_WIDTH;
// @cmember:(INTERNAL) Array di TToken_strings contenenti le righe // @cmember:(INTERNAL) Array di TToken_strings contenenti le righe
@ -2963,7 +2966,7 @@ void TSpreadsheet::paste_rows()
TSheet_field::TSheet_field(TMask* m) TSheet_field::TSheet_field(TMask* m)
: TLoadable_field(m), _append(true), : TLoadable_field(m), _append(true),
_separator('|'), _enable_autoload(false), _sheetfile(NULL), _separator('|'), _enable_autoload(false), _sheetfile(NULL),
_linee_rec(NULL), _external_record(false), _userput(NULL),_userget(NULL), _linee_rec(NULL), _external_record(false), _userput(NULL), _userget(NULL),
_extended(false) _extended(false)
{ {
} }

View File

@ -106,7 +106,7 @@ public:
// record e I/O // record e I/O
virtual void dirty_fields() {} virtual void dirty_fields() {}
virtual void set_fields(TAuto_variable_rectype & rec) {} virtual void set_fields(TAuto_variable_rectype & rec) {}
virtual void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); } virtual void reset_fields(TAuto_variable_rectype & rec, bool all = true) { rec.remove_field(nullptr, all); }
virtual TMultiple_rectype & operator =(const TMultiple_rectype & r) { return copy(r);} virtual TMultiple_rectype & operator =(const TMultiple_rectype & r) { return copy(r);}
virtual TRectype & operator =(const TRectype & r); virtual TRectype & operator =(const TRectype & r);

View File

@ -4,6 +4,7 @@
#include <agasys.h> #include <agasys.h>
#include <diction.h> #include <diction.h>
#include <progind.h> #include <progind.h>
#include <isamrpc.h>
#include <real.h> #include <real.h>
#include <utility.h> #include <utility.h>
#include <netsock.h> #include <netsock.h>
@ -51,7 +52,6 @@ protected:
SOCKET &_socket ; SOCKET &_socket ;
} ; } ;
HIDDEN const char * __content_type[] = { "text/plain", "application/json" };
// //
// skstream // skstream
// //
@ -1040,7 +1040,7 @@ bool TSocketClient::HttpSoap(CONNID id, const char* cmd, const char * agent)
if (agent && *agent) if (agent && *agent)
buf << "User-Agent: " << agent << "\r\n"; buf << "User-Agent: " << agent << "\r\n";
buf << "Host: " << hostname << "\n" buf << "Host: " << hostname << "\n"
<< "Content-Type: " << __content_type[0] << "; charset=utf-8\n" << "Content-Type: " << http_content(media_txt) << "; charset=utf-8\n"
<< "Content-length: " << content.len() << "\n" << "Content-length: " << content.len() << "\n"
<< "SOAPAction: \"/\"\r\n\r\n" << "SOAPAction: \"/\"\r\n\r\n"
<< content; << content;
@ -1079,7 +1079,7 @@ bool TSocketClient::HttpSoap(CONNID id, const char* cmd, const char * agent)
static const char* const eol = "\r\n"; static const char* const eol = "\r\n";
bool TSocketClient::HttpPost(CONNID id, const char* remote, TString & content, int timeout, int port, bool port_stmt, int type, const char * agent, const char* authorization) bool TSocketClient::HttpPost(CONNID id, const char* remote, TString & content, int timeout, int port, bool port_stmt, http_media_types type, const char * agent, const char* authorization)
{ {
TSocket_connection* conn = (TSocket_connection*)GetConnection(id); TSocket_connection* conn = (TSocket_connection*)GetConnection(id);
skstream* cur_socket = conn->GetSocket(); skstream* cur_socket = conn->GetSocket();
@ -1100,7 +1100,7 @@ bool TSocketClient::HttpPost(CONNID id, const char* remote, TString & content, i
buf << "User-Agent: " << agent << eol; buf << "User-Agent: " << agent << eol;
else else
buf << "User-Agent: Mozilla/4.0" << eol; buf << "User-Agent: Mozilla/4.0" << eol;
buf << "Content-Type: " << __content_type[type] << eol buf << "Content-Type: " << http_content(type) << eol
<< "Content-Length: " << length + 2 << eol; << "Content-Length: " << length + 2 << eol;
if (authorization && *authorization) if (authorization && *authorization)
buf << "Authorization: " << authorization << eol; buf << "Authorization: " << authorization << eol;
@ -1147,7 +1147,7 @@ bool TSocketClient::HttpPost(CONNID id, const char* remote, TString & content, i
return ok; return ok;
} }
bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* local, int timeout, int port, bool port_stmt, int type, const char * agent, const char* authorization) bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* local, int timeout, int port, bool port_stmt, http_media_types type, const char * agent, const char* authorization)
{ {
TString content; TString content;
@ -1164,7 +1164,6 @@ bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* loca
break; break;
} }
return HttpPost(id, remote, content, timeout, port, port_stmt, type, agent, authorization); return HttpPost(id, remote, content, timeout, port, port_stmt, type, agent, authorization);
} }
bool TSocketClient::HttpPutFile(CONNID id, const char* remote, const char* local, const char * agent, const char* authorization) bool TSocketClient::HttpPutFile(CONNID id, const char* remote, const char* local, const char * agent, const char* authorization)

View File

@ -5,6 +5,10 @@
#include "netutils.h" #include "netutils.h"
#endif #endif
#ifndef __MEDIATYPES_H__
#include "mediatypes.h"
#endif
class TSocketServer : public TLanServer class TSocketServer : public TLanServer
{ {
byte* m_pData; byte* m_pData;
@ -55,8 +59,8 @@ public:
bool HttpGetFile(CONNID id, const char* remote, const char* local, const char * agent = nullptr, const char* authorization = nullptr); bool HttpGetFile(CONNID id, const char* remote, const char* local, const char * agent = nullptr, const char* authorization = nullptr);
bool HttpGetDir(CONNID id, const char* remote, TString_array& list, const char * agent = nullptr, const char* authorization = nullptr); bool HttpGetDir(CONNID id, const char* remote, TString_array& list, const char * agent = nullptr, const char* authorization = nullptr);
bool HttpSoap(CONNID id, const char* query, const char * agent = nullptr); bool HttpSoap(CONNID id, const char* query, const char * agent = nullptr);
bool HttpPost(CONNID id, const char* remote, TString & content, int timeout, int port, bool port_stmt = true, int type = 0, const char * agent = nullptr, const char* authorization = nullptr); bool HttpPost(CONNID id, const char* remote, TString & content, int timeout, int port, bool port_stmt = true, http_media_types type = media_txt, const char * agent = nullptr, const char* authorization = nullptr);
bool HttpPostFile(CONNID id, const char* remote, const char* local, int timeout, int port, bool port_stmt = true, int type = 0, const char * agent = nullptr, const char* authorization = nullptr); bool HttpPostFile(CONNID id, const char* remote, const char* local, int timeout, int port, bool port_stmt = true, http_media_types type = media_txt, const char * agent = nullptr, const char* authorization = nullptr);
bool HttpPutFile(CONNID id, const char* remote, const char* local, const char * agent = nullptr, const char* authorization = nullptr); bool HttpPutFile(CONNID id, const char* remote, const char* local, const char * agent = nullptr, const char* authorization = nullptr);
bool FtpGetDir(CONNID id, const char* remote, TString_array& list, const char* user = nullptr, const char* pass = nullptr); bool FtpGetDir(CONNID id, const char* remote, TString_array& list, const char* user = nullptr, const char* pass = nullptr);
bool FtpGetFile(CONNID id, const char* remote, const char* local, const char* user = nullptr, const char* pass = nullptr); bool FtpGetFile(CONNID id, const char* remote, const char* local, const char* user = nullptr, const char* pass = nullptr);

View File

@ -26,7 +26,7 @@
// @class TObject | Classe base per la definizione della gerarchia degli oggetti // @class TObject | Classe base per la definizione della gerarchia degli oggetti
class TObject class TObject
// @author:(INTERNAL) Guido // @author:(INTERNAL) Guido
{ {
// @access Public Member // @access Public Member
public: public:
@ -261,6 +261,29 @@ inline bool operator !=(
return res != 0 && res != UNDEFINED; return res != 0 && res != UNDEFINED;
} }
class TShort :public TSortable
// @author:(INTERNAL) Bonazzi
// Short per utilizzarlo negli array
{
int _s;
protected:
// @cmember Permette di stampare l'oggetto
virtual void print_on(ostream& out) const { out << _s; }
TShort & copy(const TShort & i) { _s = i._s; return *this; }
public:
virtual int compare(const TSortable& s) const override { return _s - ((TShort&)s)._s; }
virtual TObject* dup() const { return new TShort(*this); }
short val() const { return _s; }
operator short() const { return val(); }
TShort & operator ==(TShort& s) { return copy(s); }
TShort & operator ==(short s) { _s = s; return *this; }
TShort(short s = 0) : _s(s) { }
~TShort() = default;
};
#ifdef __OBJECT_CPP #ifdef __OBJECT_CPP
#define extern #define extern
#endif #endif

View File

@ -38,6 +38,7 @@ const real VENTUNO(21.0);
const real VENTIDUE(22.0); const real VENTIDUE(22.0);
const real CINQUANTA(50.0); const real CINQUANTA(50.0);
const real CENTO(100.0); const real CENTO(100.0);
const real MILLE(1000.0);
#include <gm.h> #include <gm.h>
//#include <ctype.h> //#include <ctype.h>

View File

@ -47,6 +47,7 @@ extern const real VENTUNO;
extern const real VENTIDUE; extern const real VENTIDUE;
extern const real CINQUANTA; extern const real CINQUANTA;
extern const real CENTO; extern const real CENTO;
extern const real MILLE;
#define UN_CENTESIMO PUNTO_ZERO_UNO #define UN_CENTESIMO PUNTO_ZERO_UNO
#define REALE_ZERO(r) (abs(r) < UN_CENTESIMO) #define REALE_ZERO(r) (abs(r) < UN_CENTESIMO)

View File

@ -1065,10 +1065,11 @@ bool list_custom_files(const char* ext, const char* classe, TString_array& files
if (ok) if (ok)
{ {
get_xml_child(stringona, "description", desc);
TToken_string* riga = new TToken_string; TToken_string* riga = new TToken_string;
get_xml_child(stringona, "description", desc);
if (desc.blank())
desc << "Report " << path.name_only();
if (type[0] == 'D') if (type[0] == 'D')
{ {
riga->add(desc); riga->add(desc);
@ -1143,8 +1144,8 @@ protected:
void parse_filter(TToken_string& filter); void parse_filter(TToken_string& filter);
void parse_select(TToken_string& filter); void parse_select(TToken_string& filter);
void parse_region(TRectype& rec, bool final); void parse_region(TRectype& rec, bool final);
void parse_join_param(TRelation* rel, const TString& j, int to); void parse_join_param(TRelation* rel, const TString& j, int to, bool connect = false);
void parse_join(); void parse_join(bool connect = false);
void parse_sortedjoin(); void parse_sortedjoin();
public: public:
@ -1339,8 +1340,7 @@ void TCursor_parser::parse_region(TRectype& rec, bool final)
push(); push();
} }
void TCursor_parser::parse_join_param(TRelation* rel, const TString& j, int to, bool connect)
void TCursor_parser::parse_join_param(TRelation* rel, const TString& j, int to)
{ {
int key = 1; int key = 1;
const TString& tok = pop(); const TString& tok = pop();
@ -1372,16 +1372,17 @@ void TCursor_parser::parse_join_param(TRelation* rel, const TString& j, int to)
yesnofatal_box("JOIN senza espressioni INTO"); yesnofatal_box("JOIN senza espressioni INTO");
const int logicnum = table2logic(j); const int logicnum = table2logic(j);
switch (logicnum) switch (logicnum)
{ {
case LF_TABGEN: case LF_TABGEN:
case LF_TABCOM: case LF_TABCOM:
case LF_TAB: case LF_TAB:
case LF_TABMOD: case LF_TABMOD:
rel->add(j, exp, key, to, alias); // join table rel->add(j, exp, key, to, alias, false, connect); // join table
break; break;
default: default:
rel->add(logicnum, exp, key, to, alias); // join file rel->add(logicnum, exp, key, to, alias, false, connect); // join file
break; break;
} }
@ -1394,7 +1395,7 @@ void TCursor_parser::parse_join_param(TRelation* rel, const TString& j, int to)
add_column_info(tabname, rec); add_column_info(tabname, rec);
} }
void TCursor_parser::parse_join() void TCursor_parser::parse_join(bool connect)
{ {
const TString j = pop(); // File or table const TString j = pop(); // File or table
@ -1407,8 +1408,7 @@ void TCursor_parser::parse_join()
} }
else else
push(); push();
parse_join_param(_relation, j, to, connect);
parse_join_param(_relation, j, to);
} }
void TCursor_parser::parse_sortedjoin() void TCursor_parser::parse_sortedjoin()
@ -1605,13 +1605,19 @@ TCursor_parser::TCursor_parser(istream& instr, TArray& col)
{ {
pop(); pop();
if (tok.starts_with("FR")) if (tok.starts_with("FR"))
parse_region(rec_start, false); else parse_region(rec_start, false);
else
if (tok.starts_with("TO")) if (tok.starts_with("TO"))
parse_region(rec_stop, true); else parse_region(rec_stop, true);
else
if (tok.starts_with("JO")) if (tok.starts_with("JO"))
parse_join(); else parse_join();
else
if (tok.starts_with("SO")) if (tok.starts_with("SO"))
parse_sortedjoin(); parse_sortedjoin();
else
if (tok.starts_with("RI"))
parse_join(true);
else else
break; break;
} }

View File

@ -119,6 +119,7 @@ public: // Absolutely needed methods
virtual const TVariant& get(unsigned int column) const pure; virtual const TVariant& get(unsigned int column) const pure;
virtual const TString_array& variables() const { return _varnames; } virtual const TString_array& variables() const { return _varnames; }
virtual void clear_variables() { _varnames.destroy(); }
virtual const TVariant& get_var(const char* name) const; virtual const TVariant& get_var(const char* name) const;
virtual bool set_var(const char* name, const TVariant& var, bool create = false); virtual bool set_var(const char* name, const TVariant& var, bool create = false);
virtual bool ask_variables(bool all); virtual bool ask_variables(bool all);

View File

@ -4,6 +4,7 @@
#include <extcdecl.h> #include <extcdecl.h>
#include <prefix.h> #include <prefix.h>
#include <progind.h> #include <progind.h>
#include <recarray.h>
#include <relation.h> #include <relation.h>
#include <sheet.h> #include <sheet.h>
#include <sort.h> #include <sort.h>
@ -83,6 +84,7 @@ class TRelationdef : public TObject
bool _first_match : 1; // primo match (ed esiste) bool _first_match : 1; // primo match (ed esiste)
bool _allow_lock : 1; // ?? bool _allow_lock : 1; // ??
bool _write_enable : 1; bool _write_enable : 1;
bool _right : 1;
public: // TObject public: // TObject
virtual void print_on(ostream& out) const; virtual void print_on(ostream& out) const;
@ -107,11 +109,11 @@ public:
TRelationdef(const TRelation* rel, int file, byte key, TRelationdef(const TRelation* rel, int file, byte key,
int linkto, const char* relexprs, int alias, int linkto, const char* relexprs, int alias,
bool allow_lock); bool allow_lock, bool right = false);
// Costruttore di copia // Costruttore di copia
TRelationdef(const TRelationdef& reldef); TRelationdef(const TRelationdef& reldef);
virtual ~TRelationdef() {} virtual ~TRelationdef() = default;
}; };
TRelationdef & TRelationdef::copy(const TRelationdef & reldef) TRelationdef & TRelationdef::copy(const TRelationdef & reldef)
@ -126,16 +128,17 @@ TRelationdef & TRelationdef::copy(const TRelationdef & reldef)
_first_match = reldef._first_match; _first_match = reldef._first_match;
_allow_lock = reldef._allow_lock; _allow_lock = reldef._allow_lock;
_write_enable = reldef._write_enable; _write_enable = reldef._write_enable;
_right = reldef._right;
return *this; return *this;
} }
TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key, TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
int idx_to, const char* relexprs, int alias, int idx_to, const char* relexprs, int alias,
bool allow_lock) bool allow_lock, bool right)
: _rel(rel), _num(idx_file), _numto(idx_to), : _rel(rel), _num(idx_file), _numto(idx_to),
_alias(alias), _key(key), _fields(4), _exprs(4), _alias(alias), _key(key), _fields(4), _exprs(4),
_first_match(FALSE), _allow_lock(allow_lock), _first_match(false), _allow_lock(allow_lock),
_write_enable(FALSE) _write_enable(false), _right(right)
{ {
TToken_string rels(relexprs); TToken_string rels(relexprs);
int i = 0; int i = 0;
@ -151,7 +154,7 @@ TRelationdef::TRelationdef(const TRelation* rel, int idx_file, byte key,
s = r.left(eq); // Parte a sinistra dell' = s = r.left(eq); // Parte a sinistra dell' =
#ifdef DBG #ifdef DBG
const char* n = s; TString n = s;
const int p = s.find('['); const int p = s.find('[');
if (p > 0) n = s.left(p); if (p > 0) n = s.left(p);
if (rel->file(_num).curr().exist(n) == FALSE) if (rel->file(_num).curr().exist(n) == FALSE)
@ -192,6 +195,9 @@ void TRelationdef::print_on(ostream& out) const
{ {
const TLocalisamfile& f = _rel->file(_num); const TLocalisamfile& f = _rel->file(_num);
if (_right)
out << "CONNECT ";
else
out << "JOIN "; out << "JOIN ";
print_name(out, f); print_name(out, f);
@ -266,7 +272,6 @@ void TRelationdef::print_on(TToken_string& out) const
} }
} }
const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to) const const char* TRelationdef::evaluate_expr(int j, const TLocalisamfile& to) const
{ {
const TRectype& rec = to.curr(); const TRectype& rec = to.curr();
@ -340,7 +345,9 @@ TRelation::TRelation(const char* tabname)
TRelation::TRelation(TLocalisamfile* l) TRelation::TRelation(TLocalisamfile* l)
: _files(4), _reldefs(4), _errors(NOERR) : _files(4), _reldefs(4), _errors(NOERR)
{ _files.add(l); } {
_files.add(l);
}
TRelation::TRelation(const TRelation & rel) TRelation::TRelation(const TRelation & rel)
{ {
@ -560,7 +567,8 @@ bool TRelation::add(
int key, // @parm Chiave del file int key, // @parm Chiave del file
int linkto, // @parm Posizione alla quale aggiungere il file int linkto, // @parm Posizione alla quale aggiungere il file
int alias, // @parm Alias da dare al file da aggiungere int alias, // @parm Alias da dare al file da aggiungere
bool allow_lock) // @parm Indica se fare il lock sul file oppure ignorarli bool allow_lock, // @parm Indica se fare il lock sul file oppure ignorarli
bool right) // @parm Indica se fare una connessione con la cache
// @parm int | logicnum | Numero logico del file da aggiungere // @parm int | logicnum | Numero logico del file da aggiungere
// @parm const char* | tabname | Nome della tabella da aggiungere // @parm const char* | tabname | Nome della tabella da aggiungere
@ -584,30 +592,28 @@ bool TRelation::add(
CHECK(relexprs && *relexprs, "Mancano le espressioni di collegamento"); CHECK(relexprs && *relexprs, "Mancano le espressioni di collegamento");
TRelationdef* r = new TRelationdef(this, idx, key, idxto, TRelationdef* r = new TRelationdef(this, idx, key, idxto, relexprs, alias,
relexprs, alias, allow_lock); allow_lock, right);
_reldefs.add(r); _reldefs.add(r);
return true;
return TRUE;
} }
bool TRelation::add(int logicnum, const char* relexprs, int key, bool TRelation::add(int logicnum, const char* relexprs, int key,
int linkto, int alias, bool allow_lock) int linkto, int alias, bool allow_lock, bool right)
{ {
TLocalisamfile* f = new TLocalisamfile(logicnum); TLocalisamfile* f = new TLocalisamfile(logicnum);
return add(f, relexprs, key, linkto, alias, allow_lock); return add(f, relexprs, key, linkto, alias, allow_lock, right);
} }
bool TRelation::add(const char* tabname, const char* relexprs, int key, bool TRelation::add(const char* tabname, const char* relexprs, int key,
int linkto, int alias, bool allow_lock) int linkto, int alias, bool allow_lock, bool right)
{ {
TLocalisamfile* t = NULL; TLocalisamfile* t = nullptr;
if (*tabname == '&') if (*tabname == '&')
t = new TModule_table(tabname); t = new TModule_table(tabname);
else else
t = new TTable(tabname); t = new TTable(tabname);
return add(t, relexprs, key, linkto, alias, allow_lock); return add(t, relexprs, key, linkto, alias, allow_lock, right);
} }
// @doc EXTERNAL // @doc EXTERNAL
@ -714,15 +720,27 @@ int TRelation::position_rels(
for (int j = 0; j < rd._fields.items(); j++) // for each field for (int j = 0; j < rd._fields.items(); j++) // for each field
{ {
expr = rd.evaluate_expr(j, to); expr = rd.evaluate_expr(j, to);
const TFieldref& s = (const TFieldref&) rd._fields[j]; const TFieldref& s = (const TFieldref&)rd._fields[j];
s.write(expr, furr); s.write(expr, furr);
} // for each field } // for each field
const TReclock lck = rd._allow_lock ? lockop : _nolock; const TReclock lck = rd._allow_lock ? lockop : _nolock;
from.read(_isgteq, lck); bool eq = false;
if (rd._right)
{
const TToken_string key = furr.build_token_key(rd._key);
furr = cache().get(furr.num(), key, rd._key);
// record read : if not found, zero current record // record read : if not found, zero current record
bool eq = !from.bad(); eq = furr.full();
}
else
{
from.read(_isgteq, lck);
// record read : if not found, zero current record
eq = !from.bad();
}
for (int kk = 0; eq && kk < rd._fields.items(); kk++) for (int kk = 0; eq && kk < rd._fields.items(); kk++)
{ {
TFieldref& fl = (TFieldref&)rd._fields[kk]; TFieldref& fl = (TFieldref&)rd._fields[kk];
@ -1124,6 +1142,7 @@ bool TCursor::has_simple_filter() const
{ {
const RecDes& recd = curr().rec_des(); // Descrizione del record della testata const RecDes& recd = curr().rec_des(); // Descrizione del record della testata
const KeyDes& kd = recd.Ky[_nkey-1]; // Elenco dei campi della chiave del cursore const KeyDes& kd = recd.Ky[_nkey-1]; // Elenco dei campi della chiave del cursore
for (int i = _fexpr->numvar()-1; yes && i >= 0; i--) for (int i = _fexpr->numvar()-1; yes && i >= 0; i--)
{ {
const char * vn = _fexpr->varname(i); const char * vn = _fexpr->varname(i);

View File

@ -115,11 +115,11 @@ public:// TObject
bool next_match(int logicnum, const char* fieldlist = NULL, int nkey = 0); bool next_match(int logicnum, const char* fieldlist = NULL, int nkey = 0);
// @cmember Aggiunge una nuovo file alla relazione partendo dal descrittore del file // @cmember Aggiunge una nuovo file alla relazione partendo dal descrittore del file
bool add(TLocalisamfile* f, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = FALSE); bool add(TLocalisamfile* f, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = false, bool right = false);
// @cmember Aggiunge una nuovo file alla relazione partendo dal numero logico del file // @cmember Aggiunge una nuovo file alla relazione partendo dal numero logico del file
bool add(int logicnum, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = FALSE); bool add(int logicnum, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = false, bool right = false);
// @cmember Aggiunge una nuovo file alla relazione partendo dal nome della tabella // @cmember Aggiunge una nuovo file alla relazione partendo dal nome della tabella
bool add(const char* tabname, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = FALSE); bool add(const char* tabname, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = false, bool right = false);
// @cmember Sostituisce nella relazione il file di indice index // @cmember Sostituisce nella relazione il file di indice index
void replace(TLocalisamfile* f, int index = 0,const char * relexprs="",int key=1); void replace(TLocalisamfile* f, int index = 0,const char * relexprs="",int key=1);
// @cmember Sostituisce nella relazione il file di ID lognum // @cmember Sostituisce nella relazione il file di ID lognum

View File

@ -1337,7 +1337,7 @@ bool TBook::print_page(TWindow& win, size_t page)
RCT rct_riga; win.log2dev(rect_riga, rct_riga); RCT rct_riga; win.log2dev(rect_riga, rct_riga);
const int default_10row_height = rct_riga.bottom - rct_riga.top; const int default_10row_height = rct_riga.bottom - rct_riga.top;
const streampos pos = ((const TFilepos &)_index[page]).pos(); const streampos pos = (const TFilepos &)_index[page];
ifstream ifs(_file); ifstream ifs(_file);
ifs.seekg(pos); ifs.seekg(pos);
@ -2156,7 +2156,7 @@ void TBook::split_file(int colonne)
{ {
if (!pi.setstatus(page)) if (!pi.setstatus(page))
break; break;
const streampos pos = ((const TFilepos &)_index[page]).pos(); const streampos pos = (const TFilepos &)_index[page];
for (int c = 0; c < colonne; c++) for (int c = 0; c < colonne; c++)
{ {
const TRectangle rct_page(c*_page_size.x, 0, _page_size.x, _page_size.y); const TRectangle rct_page(c*_page_size.x, 0, _page_size.x, _page_size.y);

View File

@ -1012,7 +1012,7 @@ TSheet::TSheet(short x, short y, short dx, short dy,
const char* title, const char* head, const char* title, const char* head,
byte buttons, short sht_y, WINDOW parent) byte buttons, short sht_y, WINDOW parent)
: TMask(title, 1, dx, dy, x, y, parent), : TMask(title, 1, dx, dy, x, y, parent),
_sheet(nullptr), _select_row(-1), _parked(-1) _sheet(nullptr), _select_row(-1), _parked(-1), _head(head)
{ {
create_bar(1); // Crea toolbar in alto create_bar(1); // Crea toolbar in alto
@ -1635,7 +1635,7 @@ TCursor_sheet::TCursor_sheet(TCursor* cursor, const char* fields,
const char* title, const char* head, const char* title, const char* head,
byte buttons, short sht_y, WINDOW parent) byte buttons, short sht_y, WINDOW parent)
: TSheet(sht_y ? 3 : 0, sht_y ? 3 : 0, sht_y ? -3 : 0, sht_y ? -3 : 0, : TSheet(sht_y ? 3 : 0, sht_y ? 3 : 0, sht_y ? -3 : 0, sht_y ? -3 : 0,
title, head, buttons, sht_y, parent), _cursor(cursor) title, head, buttons, sht_y, parent), _cursor(cursor), _sorted(false)
{ {
TToken_string fldlst(fields); TToken_string fldlst(fields);
int campo = 0; int campo = 0;
@ -1680,6 +1680,9 @@ long TCursor_sheet::get_items() const
void TCursor_sheet::get_row(long row, TToken_string& l) void TCursor_sheet::get_row(long row, TToken_string& l)
{ {
if (_nrecs.items() > 0 && _nrecs.objptr(row) != nullptr)
*_cursor = ((TORecnotype &)_nrecs[row]).val();
else
*_cursor = (TRecnotype)row; *_cursor = (TRecnotype)row;
l.cut(0); l.cut(0);
const int last = _fields.last(); const int last = _fields.last();

View File

@ -1,12 +1,21 @@
#ifndef __SHEET_H #ifndef __SHEET_H
#define __SHEET_H #define __SHEET_H
#ifndef __ISAM_H
#include <isam.h>
#endif
#ifndef __MASK_H #ifndef __MASK_H
#include <mask.h> #include <mask.h>
#endif #endif
class TCursor_sheet;
// @doc INTERNAL // @doc INTERNAL
//typedef (*SHEET_ROWS_COMPARE_FUNCTION)(const TCursor_sheet &, const TToken_string&);
typedef int(*SHEET_ROWS_COMPARE_FUNCTION)(TCursor_sheet & s, int r1, int r2);
// @class TSheet | Classe per la definizione e la gestione degli sheet per le ricerche // @class TSheet | Classe per la definizione e la gestione degli sheet per le ricerche
// //
// @base public | TScroll_window // @base public | TScroll_window
@ -18,6 +27,7 @@ class TSheet : public TMask
{ {
friend class TSheet_control; friend class TSheet_control;
TSheet_control* _sheet; // Spreadsheet contenuto TSheet_control* _sheet; // Spreadsheet contenuto
TToken_string _head;
TToken_string _park; // Ultima riga richiesta TToken_string _park; // Ultima riga richiesta
long _select_row; // Riga da selezionare long _select_row; // Riga da selezionare
@ -117,6 +127,12 @@ public:
// @cmember Forza l'aggiornamento di una o tutte le righe visibili // @cmember Forza l'aggiornamento di una o tutte le righe visibili
void force_update(int r = -1); void force_update(int r = -1);
int columns() const { return _head.items(); }
// @cmember Setta il titolo della colonna
void set_column_header(const int col, const TString& header) { _head.add(header, col); }
// @cmember Getta il titolo della colonna
const char* get_column_header(const int col) { return _head.get(col); }
// @cmember Costruttore // @cmember Costruttore
TSheet(short x, short y, short dx, short dy, const char* title, TSheet(short x, short y, short dx, short dy, const char* title,
const char* head, byte buttons = 0, short sht_y = 0, WINDOW parent = NULL_WIN); const char* head, byte buttons = 0, short sht_y = 0, WINDOW parent = NULL_WIN);
@ -165,6 +181,7 @@ public:
long insert(const TToken_string& s, long n); long insert(const TToken_string& s, long n);
// @cmember Azzera l'array dello sheet // @cmember Azzera l'array dello sheet
bool destroy(int i = -1); bool destroy(int i = -1);
}; };
@ -181,6 +198,8 @@ class TCursor_sheet : public TSheet
{ {
// @cmember:(INTERNAL) Array di <c TRecfield> // @cmember:(INTERNAL) Array di <c TRecfield>
TArray _fields; TArray _fields;
bool _sorted;
TArray _nrecs;
// @cmember:(INTERNAL) Cursore da cui prelevare i dati // @cmember:(INTERNAL) Cursore da cui prelevare i dati
TCursor* _cursor; TCursor* _cursor;

View File

@ -5,6 +5,9 @@
#include <real.h> #include <real.h>
#include <utility.h> #include <utility.h>
#define _MAX_DRIVE_PROTO _MAX_DIR+6
// @doc EXTERNAL // @doc EXTERNAL
// @func Ritorna il nome dell'utente attuale // @func Ritorna il nome dell'utente attuale
@ -1183,7 +1186,8 @@ void TFilename::ext(const char* e)
*this << e; *this << e;
} }
*/ */
char v[_MAX_DRIVE], d[_MAX_DIR], n[_MAX_FNAME], p[_MAX_PATH]; char v[_MAX_DRIVE_PROTO], d[_MAX_DIR], n[_MAX_FNAME], p[_MAX_PATH];
xvt_fsys_parse_pathname(_str, v, d, n, nullptr, nullptr); xvt_fsys_parse_pathname(_str, v, d, n, nullptr, nullptr);
xvt_fsys_build_pathname(p, v, d, n, e, nullptr); xvt_fsys_build_pathname(p, v, d, n, e, nullptr);
set(p); set(p);
@ -1249,7 +1253,7 @@ const char* TFilename::path() const
*/ */
if (full()) if (full())
{ {
char v[_MAX_DRIVE], d[_MAX_DIR]; char v[_MAX_DRIVE_PROTO], d[_MAX_DIR];
v[0] = '\0'; v[0] = '\0';
xvt_fsys_parse_pathname(_str, find(":") > 0 ? v : nullptr, d, nullptr, nullptr, nullptr); xvt_fsys_parse_pathname(_str, find(":") > 0 ? v : nullptr, d, nullptr, nullptr, nullptr);
@ -1440,6 +1444,8 @@ TFilename& TFilename::temp(
bool TFilename::is_absolute_path() const bool TFilename::is_absolute_path() const
{ {
const char* s = _str; const char* s = _str;
if (is_remote(_str))
return true;
if (isalpha(*s) && s[1] == ':') if (isalpha(*s) && s[1] == ':')
s += 2; s += 2;
return is_slash(*s); return is_slash(*s);
@ -1465,7 +1471,7 @@ bool TFilename::exist() const
bool TFilename::fremove() const bool TFilename::fremove() const
{ {
return xvt_fsys_remove_file(_str) != false; return full() ? xvt_fsys_remove_file(_str) != false : true;
} }
bool TFilename::frename(const char* src_path, const char* dst_path) bool TFilename::frename(const char* src_path, const char* dst_path)

View File

@ -110,14 +110,17 @@ bool fcopy(
if (xvt_str_same(orig, dest)) if (xvt_str_same(orig, dest))
return true; // Or FALSE? return true; // Or FALSE?
FILE* i = NULL; fopen_s(&i, orig, rflag); FILE* i = nullptr; fopen_s(&i, orig, rflag);
if (i == NULL)
if (i == nullptr)
return error_box(FR("Impossibile leggere il file '%s'\nda copiare in '%s'\nErrore %d"), orig, dest, errno); return error_box(FR("Impossibile leggere il file '%s'\nda copiare in '%s'\nErrore %d"), orig, dest, errno);
if (!append) if (!append)
xvt_fsys_remove_file(dest); xvt_fsys_remove_file(dest);
FILE* o = NULL; fopen_s(&o, dest, wflag);
if (o == NULL) FILE* o = nullptr; fopen_s(&o, dest, wflag);
if (o == nullptr)
{ {
fclose(i); fclose(i);
if (append) if (append)
@ -187,19 +190,28 @@ bool fmove(
bool fexist( bool fexist(
const char* file) // @parm Nome del file di cui controllare l'esistenza const char* file) // @parm Nome del file di cui controllare l'esistenza
{ {
return file && *file && xvt_fsys_file_exists(file) != 0; return file && *file && (is_remote(file) || xvt_fsys_file_exists(file) != 0);
} }
bool dexist( bool dexist(
const char* file) // @parm Nome del direttorio di cui controllare l'esistenza const char* file) // @parm Nome del direttorio di cui controllare l'esistenza
{ {
return file && *file && xvt_fsys_dir_exists(file) != 0; return file && *file && (is_remote(file) || xvt_fsys_dir_exists(file) != 0);
} }
bool is_dir( bool is_dir(const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza
const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza
{ {
return file && *file && xvt_fsys_file_attr(file, XVT_FILE_ATTR_DIRECTORY) != 0; return file && *file && (is_remote(file) || xvt_fsys_file_attr(file, XVT_FILE_ATTR_DIRECTORY) != 0);
}
bool is_ftp(const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza
{
return file && *file && strncmp(file, "ftp:", 4) == 0;
}
bool is_http(const char* file) // @parm ritorna se file è un direttorio di cui controllare l'esistenza
{
return file && *file && (strncmp(file, "http:", 5) == 0 || strncmp(file, "https:", 6) == 0);
} }
long fsize(const char* name) long fsize(const char* name)
@ -277,7 +289,7 @@ TDate mldate(const char* file)
// @flag FALSE | Se l'operazione non e' riuscita // @flag FALSE | Se l'operazione non e' riuscita
bool make_dir(const char* dir) // @parm Nome della directory da creare bool make_dir(const char* dir) // @parm Nome della directory da creare
{ {
return xvt_fsys_mkdir(dir) != 0; return !is_remote(dir) && xvt_fsys_mkdir(dir) != 0;
} }
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -61,6 +61,9 @@ bool fexist(const char* file);
long fsize(const char* file); long fsize(const char* file);
bool dexist(const char* file); bool dexist(const char* file);
bool is_dir(const char* file); bool is_dir(const char* file);
bool is_ftp(const char* file);
bool is_http(const char* file);
inline bool is_remote(const char* file) { return is_ftp(file) || is_http(file); }
void log_message(const char* fmt, ...); void log_message(const char* fmt, ...);
const time_t atime(const char* file); // access time const time_t atime(const char* file); // access time

View File

@ -1,4 +1,4 @@
#include <aes256.h> #include <aes256.h>
#include <colors.h> #include <colors.h>
#include <dongle.h> #include <dongle.h>
#include <real.h> #include <real.h>
@ -126,73 +126,73 @@ HIDDEN void findbadseq(TString &str, istream& inf)
if (str.starts_with("Agrave")) if (str.starts_with("Agrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("À"); str.insert("À");
} }
else else
if (str.starts_with("Egrave")) if (str.starts_with("Egrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("È"); str.insert("È");
} }
else else
if (str.starts_with("Eacuto")) if (str.starts_with("Eacuto"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("É"); str.insert("É");
} }
else else
if (str.starts_with("Igrave")) if (str.starts_with("Igrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("Ì"); str.insert("Ì");
} }
else else
if (str.starts_with("Ograve")) if (str.starts_with("Ograve"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("Ò"); str.insert("Ò");
} }
else else
if (str.starts_with("Ugrave")) if (str.starts_with("Ugrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("Ù"); str.insert("Ù");
} }
else else
if (str.starts_with("agrave")) if (str.starts_with("agrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("à"); str.insert("à");
} }
else else
if (str.starts_with("egrave")) if (str.starts_with("egrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("è"); str.insert("è");
} }
else else
if (str.starts_with("eacuto")) if (str.starts_with("eacuto"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("é"); str.insert("é");
} }
else else
if (str.starts_with("igrave")) if (str.starts_with("igrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("ì"); str.insert("ì");
} }
else else
if (str.starts_with("ograve")) if (str.starts_with("ograve"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("ò"); str.insert("ò");
} }
else else
if (str.starts_with("ugrave")) if (str.starts_with("ugrave"))
{ {
str = str.smid(5); str = str.smid(5);
str.insert("ù"); str.insert("ù");
} }
else else
if (str.starts_with("amp")) if (str.starts_with("amp"))
@ -248,40 +248,40 @@ const TString& EscapeSequence(char cStart, istream& inf)
str =" "; str =" ";
else else
if (str == "Agrave") if (str == "Agrave")
str ="À"; str ="À";
else else
if (str == "Egrave") if (str == "Egrave")
str ="È"; str ="È";
else else
if (str == "Eacuto") if (str == "Eacuto")
str ="É"; str ="É";
else else
if (str == "Igrave") if (str == "Igrave")
str ="Ì"; str ="Ì";
else else
if (str == "Ograve") if (str == "Ograve")
str ="Ò"; str ="Ò";
else else
if (str == "Ugrave") if (str == "Ugrave")
str ="Ù"; str ="Ù";
else else
if (str == "agrave") if (str == "agrave")
str ="à"; str ="à";
else else
if (str == "egrave") if (str == "egrave")
str ="è"; str ="è";
else else
if (str == "eacuto") if (str == "eacuto")
str ="é"; str ="é";
else else
if (str == "igrave") if (str == "igrave")
str ="ì"; str ="ì";
else else
if (str == "ograve") if (str == "ograve")
str ="ò"; str ="ò";
else else
if (str == "ugrave") if (str == "ugrave")
str ="ù"; str ="ù";
else else
if (str == "amp") if (str == "amp")
str = "&"; str = "&";
@ -343,40 +343,40 @@ void WriteXmlString(ostream& outf, const char* str)
if (!cdata && c == '&') if (!cdata && c == '&')
outf << "&amp;"; outf << "&amp;";
else else
if (!cdata && c == 'À') if (!cdata && c == 'À')
outf << "&Agrave;"; outf << "&Agrave;";
else else
if (!cdata && c == 'È') if (!cdata && c == 'È')
outf << "&Egrave;"; outf << "&Egrave;";
else else
if (!cdata && c == 'É') if (!cdata && c == 'É')
outf << "&Eacuto;"; outf << "&Eacuto;";
else else
if (!cdata && c == 'Ì') if (!cdata && c == 'Ì')
outf << "&Igrave;"; outf << "&Igrave;";
else else
if (!cdata && c == 'Ò') if (!cdata && c == 'Ò')
outf << "&Ograve;"; outf << "&Ograve;";
else else
if (!cdata && c == 'Ù') if (!cdata && c == 'Ù')
outf << "&Ugrave;"; outf << "&Ugrave;";
else else
if (!cdata && c == 'à') if (!cdata && c == 'à')
outf << "&agrave;"; outf << "&agrave;";
else else
if (!cdata && c == 'è') if (!cdata && c == 'è')
outf << "&egrave;"; outf << "&egrave;";
else else
if (!cdata && c == 'é') if (!cdata && c == 'é')
outf << "&eacuto;"; outf << "&eacuto;";
else else
if (!cdata && c == 'ì') if (!cdata && c == 'ì')
outf << "&igrave;"; outf << "&igrave;";
else else
if (!cdata && c == 'ò') if (!cdata && c == 'ò')
outf << "&Ograve;"; outf << "&Ograve;";
else else
if (!cdata && c == 'ù') if (!cdata && c == 'ù')
outf << "&ugrave;"; outf << "&ugrave;";
else else
if (!cdata && c == '\'') if (!cdata && c == '\'')
@ -545,7 +545,7 @@ bool TXmlItem::GetWord(istream& inf, TString& str) const
const bool bIsString = cFirstChar == '"' || cFirstChar == '\''; const bool bIsString = cFirstChar == '"' || cFirstChar == '\'';
if (!bIsString) if (!bIsString)
{ {
if (strchr("<=/>", cFirstChar) != NULL) if (strchr("<=/>", cFirstChar) != nullptr)
return true; // Simboli terminali return true; // Simboli terminali
if (cFirstChar == '&' && !_noescape) if (cFirstChar == '&' && !_noescape)
str = EscapeSequence(cFirstChar, inf); str = EscapeSequence(cFirstChar, inf);
@ -564,9 +564,16 @@ bool TXmlItem::GetWord(istream& inf, TString& str) const
c = ' '; c = ' ';
str << char(c); str << char(c);
} }
if (c == cFirstChar) if (c == cFirstChar || c == '<')
{
if (c == '<')
{
str.rtrim(1);
inf.putback(c);
}
break; break;
} }
}
else else
{ {
if (c >= '\0' && c <= ' ') if (c >= '\0' && c <= ' ')
@ -962,6 +969,8 @@ bool TXmlItem::GetEnclosedDate(const char* strAttr, TDate & d) const
if (GetEnclosedText(strAttr, s)) if (GetEnclosedText(strAttr, s))
{ {
s.strip_spaces(); s.strip_spaces();
while (s.len() > 8 && s.len() != 10)
s.rtrim(1);
d = TDate(s); d = TDate(s);
return true; return true;
} }
@ -1454,20 +1463,22 @@ TXmlItem::TXmlItem(const TFilename & name, const char * strXmlHeader, const char
: m_strXmlHeader(nullptr), m_strTag(15), m_strText(nullptr), m_Attributes(nullptr), : m_strXmlHeader(nullptr), m_strTag(15), m_strText(nullptr), m_Attributes(nullptr),
m_Children(nullptr), _noescape(noescape) m_Children(nullptr), _noescape(noescape)
{ {
ifstream i(name);
const int size = fsize(name) + 512;
char * Buffer = new char[size];
i.rdbuf()->pubsetbuf(Buffer, size);
SetXmlHeader(strXmlHeader); SetXmlHeader(strXmlHeader);
if (binary) if (binary)
{ {
ifstream i(name);
char c = i.get(); char c = i.get();
int count = 0; int count = 0;
while (count++ < 120 && c != '<') while (count++ < 120 && c != '<')
c = i.get(); c = i.get();
i.putback(c); i.putback(c);
Read(i, strSkipTags);
} }
else Read(i, strSkipTags);
Read(name, strSkipTags);
} }
TXmlItem::~TXmlItem() TXmlItem::~TXmlItem()