Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
isam.*      Migliorate get e put field_buffer() e update()
            Eliminato _cod dai TRectype
maskfld.c*  Corretta gestione selezione files
*.*         Corretti conflitti generati dal riporto della 1.5


git-svn-id: svn://10.65.10.50/trunk@7426 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-11-10 10:07:12 +00:00
parent d0ab8cc457
commit 062476b25d
15 changed files with 87 additions and 117 deletions

View File

@ -519,18 +519,6 @@ void TApplication::set_perms()
}
}
void TApplication::open_files(int logicnum, ...)
{
va_list marker;
va_start(marker, logicnum);
while (logicnum > 0)
{
CHECKD(_used_files.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
_used_files.add(new TLocalisamfile(logicnum), logicnum);
logicnum = va_arg(marker, int);
}
}
// @doc EXTERNAL
// @mfunc Legge il parametro /uUTENTE e lo toglie dalla lista

View File

@ -54,8 +54,6 @@ class TApplication
// @cmember:(INTERNAL) Indica se l'applicazione e' stata creata con successo
bool _create_ok;
// @cmember:(INTERNAL) array dei files usati
TArray _used_files;
// @cmember:(INTERNAL) Termine dell'applicazione
void terminate();
// @cmember:(INTERNAL) Cambia il cursore del mouse
@ -102,7 +100,8 @@ protected:
// @cmember apre i files necessari
void open_files(int logicnum, ...);
// @access Public Member
// @access Public Member
public:
// @cmember Modifca la barra dei menu' inserendo la <p menubar>
// void setbar(int menubar) { _bar = menubar;}
@ -186,8 +185,6 @@ public:
bool add_menu(TString_array& menu, MENU_TAG id = 0);
// @cmember Elimina il menu' <p id> (Ritorna se ce l'ha fatta???)
bool remove_menu(MENU_TAG id);
// Aggiunge uno o piu' file a quelli aperti
void open_files(int logicnum, ...);
// @cmember Costruttore
TApplication();

View File

@ -75,8 +75,6 @@ protected:
void _write_file();
// @cmember Inizializza il paragrafo leggendo dal file di nome <p fn > i dati
void init(const char *fn, const char* pa, bool warning);
// @cmember Carica una variabile da una riga
bool add_line(const TString& l);
// @access Public Memeber
public:
@ -144,9 +142,6 @@ public:
// se sort=TRUE, l'array è ordinato per nomevar(i), altrimenti è in ordine HASH
int list_variables(TString_array& vl, bool add_value = FALSE, const char* section = NULL, const bool sort=FALSE);
// @cmember Chiama cfgcb per ogni paragrafo
int for_each_paragraph(CONFIG_CALLBACK cfgcb, void* jolly);
// @cmember Ritorna l'intero array delle variabili della sezione
// eventualmente specificata da <p section>
TAssoc_array& list_variables(const char* section = NULL);

View File

@ -453,8 +453,8 @@ public:
// @cmember operator const | real& | | Ritorna il valore real dell'espressione
operator const real&() { return as_real(); }
// @cmember operator const | char* | | Ritorna il valore dell'espressione come stringa
const TString & as_string();
// @cmember operator const | TString& | | Ritorna il valore dell'espressione come stringa
operator const TString&() { return as_string(); }
// @cmember Ritorna il valore dell'espressione come booleano
operator bool() { return as_bool(); }
// @cmember Ritorna il nome della variabile di posto <p varnum>

View File

@ -1123,8 +1123,6 @@ public:
virtual const char* get() const;
virtual bool set(const char*);
TFieldref& field(int i) const { return (TFieldref&)_field[i]; }
TForm_string(TPrint_section* section);
virtual ~TForm_string() {}
};

View File

@ -76,7 +76,8 @@ void write_journal(TJournalHeader& jh, void* data, int len)
#define READTYPES 0x00FF
#define INVFLD 255
Str80 cprefix;
Str80 cprefix;
bool __field_changed = FALSE;
HIDDEN char _isam_string[257];
@ -92,7 +93,7 @@ HIDDEN bool __autoload = TRUE;
int hashfun(const char *s)
{
int l = strlen(s);
int l = strlen(s);
unsigned short temp = 0, *pw = (unsigned short *) s;
const unsigned short * end = (unsigned short *) (s + (l - 1));
@ -118,14 +119,15 @@ int findfld(const RecDes *recd, const char *s)
stp -= MaxFields;
byte p = stp + i;
const int fp = recd->SortFd[p];
if (fp == INVFLD) return(FIELDERR);
if (fp == INVFLD)
return(FIELDERR);
const int cmp = strcmp(recd->Fd[fp].Name, s);
if (!cmp)
if (cmp == 0)
return (int) fp;
else
if (cmp > 0) return(FIELDERR);
if (cmp > 0)
return(FIELDERR);
}
return(FIELDERR);
}
@ -252,16 +254,32 @@ void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
len = 1;
}
__field_changed = FALSE;
const char c = (t == _intzerofld || t == _longzerofld) ? '0' : ' ';
for (i = l - len - 1; i >= 0; i--) recout[i] = c;
for (i = l - len - 1; i >= 0; i--)
{
__field_changed |= recout[i] != c;
recout[i] = c;
}
if (!__field_changed)
{
__field_changed = memcmp(s, &recout, l) != 0;
if (!__field_changed)
return;
}
strncpy(&recout[l - len], s, len) ;
}
else
{
if (exceeded)
len = l;
__field_changed = memcmp(s, &recout, l) != 0;
if (!__field_changed)
return;
strncpy(recout, s, len) ;
for (i = l - 1; i >= len; i--) recout[i] = ' ';
for (i = l - 1; i >= len; i--)
recout[i] = ' ';
}
}
@ -1211,12 +1229,7 @@ TLocalisamfile::TLocalisamfile(int logicnum, bool tmpfile)
TLocalisamfile::~TLocalisamfile()
{
if (_isamfile && openf[num()-1] != NULL)
{
if (_was_open)
setkey(_oldkey);
close();
}
close();
}
int TLocalisamfile::close()
@ -1733,11 +1746,10 @@ int TSystemisamfile::update(
if (dir.eod() > 0 && oldrec.len() > 0)
{
err = _open_ex(_excllock);
err = _open_ex(_excllock, FALSE);
if (err != NOERR)
return err;
// Apro il file destinazione in modo esclusivo e senza indici
int tmpnum = num();
TIsam_handle ishandle = prefix().open_isamfile(tmpnum, tmpfname, TRUE, FALSE);
@ -1782,7 +1794,19 @@ int TSystemisamfile::update(
TRecfield* out_fld = (TRecfield*)outfld.objptr(j);
if (in_fld != NULL && out_fld != NULL)
{
const char* fld_val = *in_fld;
char* fld_val = (char*)(const char*)*in_fld;
if (out_fld->type() != _datefld && out_fld->type() != _memofld)
{
const int l1 = out_fld->len();
const int l2 = strlen(fld_val);
if (l1 < l2)
{
if (out_fld->type() != _alfafld)
*fld_val = '\0';
else
fld_val[l1] = '\0';
}
}
*out_fld = fld_val;
}
}
@ -2306,7 +2330,7 @@ void TBaseisamfile::recover()
////////////////////////////////////////////////////////////
TRectype::TRectype(int logicnum)
: _cod(NULL), _memo_data(NULL), _memo_dirty(NULL)
: _memo_data(NULL), _memo_dirty(NULL)
{
_logicnum = logicnum;
@ -2324,7 +2348,7 @@ TRectype::TRectype(int logicnum)
}
TRectype::TRectype(const TBaseisamfile* i)
: _cod(NULL), _memo_data(NULL), _memo_dirty(NULL)
: _memo_data(NULL), _memo_dirty(NULL)
{
_logicnum = i->num();
_length = prefix().get_reclen(_logicnum);
@ -2342,7 +2366,7 @@ TRectype::TRectype(const TBaseisamfile* i)
TRectype::TRectype(const TRectype& r)
: _logicnum(r._logicnum), _cod(NULL),
: _logicnum(r._logicnum),
_memo_data(NULL), _memo_dirty(NULL)
{
@ -2358,14 +2382,11 @@ TRectype::TRectype(const TRectype& r)
memcpy(_rec, r._rec, _length);
strcpy(_tab, r._tab);
if (r._cod != NULL)
_cod = new TRecfield(*this, "COD");
setempty(r.empty());
}
TRectype::~TRectype()
{
if (_cod != NULL) delete _cod;
if (_rec != NULL) delete _rec;
if (_memo_data != NULL ) delete _memo_data;
if (_memo_dirty != NULL ) delete _memo_dirty;
@ -2404,14 +2425,7 @@ void TRectype::init_memo( const TRecnotype recno)
void TRectype::settab(const char *tab)
{
if (_cod != NULL)
{
delete _cod;
_cod = NULL;
}
strcpy(_tab, tab);
if (*_tab != '\0')
_cod = new TRecfield(*this, "COD");
zero();
}
@ -2594,19 +2608,19 @@ const char* TRectype::fieldname(int i) const
const TString& TRectype::get_str(const char* fieldname) const
{
char * s = _isam_string;
static TFixed_string tmp(_isam_string, sizeof(_isam_string));
const RecDes * recd = rec_des();
int nf = findfld(recd, fieldname);
const int nf = findfld(recd, fieldname);
if (nf == FIELDERR)
{
unknown_field(fieldname);
*s = '\0';
tmp.cut(0);
}
else
__getfieldbuff(recd->Fd[nf].Len, recd->Fd[nf].TypeF,
_rec + recd->Fd[nf].RecOff, s);
{
const RecFieldDes& fd = recd->Fd[nf];
__getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, _isam_string);
}
return tmp;
}
@ -2614,9 +2628,19 @@ const TString& TRectype::get_str(const char* fieldname) const
const TString& TRectype::get(const char* fieldname) const
{
if(type( fieldname ) == _memofld )
const RecDes* recd = rec_des();
const int index = findfld(recd, fieldname);
if (index == FIELDERR)
{
unknown_field(fieldname);
return EMPTY_STRING;
}
const RecFieldDes& fd = recd->Fd[index];
const TFieldtypes ft = TFieldtypes(fd.TypeF);
if(ft == _memofld )
{
int index( findfld( rec_des( ), ( char * )fieldname ) );
if ( _memo_data->objptr( index ) && (*_memo_dirty)[ index ] )
return _memo_data->row( index );
if( _memo_recno >= 0L )
@ -2639,7 +2663,6 @@ const TString& TRectype::get(const char* fieldname) const
int TRectype::get_int(const char* fieldname) const
{
return atoi(get_str(fieldname));
}
@ -2651,28 +2674,23 @@ long TRectype::get_long(const char* fieldname) const
word TRectype::get_word(const char* fieldname) const
{
return (word)atoi(get_str(fieldname));
}
real TRectype::get_real(const char* fieldname) const
{
real r(get_str(fieldname));
return r;
}
char TRectype::get_char(const char* fieldname) const
{
return *(get_str(fieldname));
}
bool TRectype::get_bool(const char* fieldname) const
{
return *(get_str(fieldname)) == 'X';
}
@ -2702,7 +2720,6 @@ bool TRectype::get_memo(
TDate TRectype::get_date(const char* fieldname) const
{
TDate d(get_str(fieldname));
return d;
@ -2796,17 +2813,14 @@ void TRectype::put_str(const char* fieldname, const char* val)
unknown_field(fieldname);
return;
}
const TFieldtypes ft = (TFieldtypes)recd->Fd[nf].TypeF;
const RecFieldDes& fd = recd->Fd[nf];
const TFieldtypes ft = TFieldtypes(fd.TypeF);
if (val == NULL)
val = "";
if (ft == _boolfld)
val = (*val && strchr("1STXY", toupper(*val)) != NULL) ? "T" : "F";
if (*val == '\0') // Da provare
{
TRecfield f(*this, fieldname);
if (*f.pos() == '\0') return;
}
if(ft == _memofld)
{
@ -2815,17 +2829,17 @@ void TRectype::put_str(const char* fieldname, const char* val)
}
else
{
__putfieldbuff(recd->Fd[nf].Len, recd->Fd[nf].Dec, ft, val,
_rec + recd->Fd[nf].RecOff);
__putfieldbuff(fd.Len, fd.Dec, ft, val, _rec + fd.RecOff);
}
setempty(FALSE);
}
void TRectype::zero(const char* fieldname)
{
if (_cod != NULL && strcmp(fieldname , "COD") == 0)
*_cod = _tab;
if (*_tab && strcmp(fieldname , "COD") == 0)
put("COD", _tab);
else
{
const RecDes * recd = rec_des();
@ -2865,11 +2879,11 @@ void TRectype::zero(const char* fieldname)
void TRectype::zero(char c)
{
memset(_rec, c, len());
recall();
memset(_rec + 1, c, len() - 1);
if (_cod != NULL)
*_cod = _tab;
if (*_tab)
put("COD", _tab);
if(has_memo())
init_memo( RECORD_NON_FISICO );

View File

@ -62,7 +62,6 @@ protected:
// @cmember:(INTERNAL) Indentificatore della tabella
char _tab[5];
// @cmember:(INTERNAL) Campo "COD" della tabella
TRecfield* _cod;
TBit_array* _memo_dirty;
TString_array* _memo_data;
TRecnotype _memo_recno;

View File

@ -2575,25 +2575,12 @@ KEY TFile_select::run()
return good ? K_ENTER : K_ESC;
}
// CHECK_NONE Nessun controllo
// CHECK_NORMAL Se non e' vuoto deve esistere
// CHECK_REQUIRED Non puo' essere vuoto e deve esistere
// CHECK_SEARCH Puo' essere vuoto e puo' non matchare il filtro
bool TFile_select::check(CheckTime)
{
bool ok = TRUE;
const CheckType ct = field().check_type();
if (ct != CHECK_NONE)
{
const TFilename name = field().get();
if (name.empty() && ct != CHECK_REQUIRED)
return TRUE;
ok = _filter.not_empty() && name.match(_filter);
if (ok && ct != CHECK_SEARCH)
ok = name.exist();
}
const TFilename name = field().get();
bool ok = _filter.empty() || name.match(_filter);
if (ok && field().roman()) // Must exist
ok = name.exist();
return ok;
}

View File

@ -453,9 +453,6 @@ public:
// @cmember Esegue il messaggio <p n>-esimo sul campo
bool do_message(int n);
// @cmember Ritorna il messaggio <p n>-esimo del campo
TToken_string* message(int m, bool crea = FALSE);
// @cmember Controlla se il campo ha un messaggio
virtual bool has_message() const
{ return _message != NULL; }

View File

@ -276,9 +276,9 @@ int TMultiple_rectype::compare(const TSortable& s) const
{
int res = TRectype::compare(s);
TMultiple_rectype & m = (TMultiple_rectype &) s;
for (int i = 0 ; res == 0 && i < _nfiles; i++)
for (int i = 0 ; res == 0 && i < _logicnums.items(); i++)
{
int logicnum = lognum(i);
const int logicnum = lognum(i);
TRecord_array & r = body(logicnum);
TRecord_array & r1 = m.body(logicnum);
res = r.rows() - r1.rows();

View File

@ -1,7 +1,8 @@
#include <stdlib.h>
#define XVT_INCL_NATIVE
#include <progind.h>
#include <config.h>
#include <fstream.h>
// skstream.h
// Copyright (C) 1995, 1996 by John C. Wang. All Rights Reserved.

View File

@ -477,7 +477,6 @@ void TFile_cache::test_firm()
_last_firm = cur_firm;
_cache.destroy();
}
<<<<<<< recarray.cpp
}
bool flush_needed = FALSE;

View File

@ -153,7 +153,7 @@ TString& TString::set(
// @mfunc Espande la stringa per altri caratteri
int TString::make_room(
int s) // @parm Numero di caratteri di cui si cuole aspandere la stringa
int s) // @parm Numero di caratteri di cui si vuole aspandere la stringa
// @comm La stringa viene espansa di un numero di caratteri doppio (per sicurezza) di
// quello passato per parametro
@ -264,7 +264,7 @@ TString& TString::operator <<(const TObject& obj)
ostrstream out(spark.get_buffer(), spark.size());
obj.print_on(out);
out << ends;
return operator <<(spork);
return operator <<(spark);
}

View File

@ -22,8 +22,6 @@ protected:
// @cmember Controlla se il campo <p fld_id> esiste
bool present(short fld_id) const { return id2pos(fld_id) >= 0; }
TVariable_mask() : TMask () { }
public:
// @cmember Esegue il check e i messaggi sul campo <p fld_id> della maschera
virtual void check_field( short fld_id );
@ -40,7 +38,7 @@ public:
// @cmember Legge il campo da file
virtual TMask_field* parse_field(TScanner& scanner);
// @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk)
TVariable_mask( );
TVariable_mask();
// @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk)
TVariable_mask( const char* name, int num = 0, int max = MAX_PAGES);
// @cmember Distruttore

View File

@ -200,9 +200,6 @@ public:
// @cmember Distruttore
virtual ~TWindow();
// @cmember Ritorna l'handler della finestra padre
WINDOW parent() const;
// @cmember Ritorna l'identificatore della classe finestra
virtual word class_id() const;