Migliorata la add dei TArray
Cambiato metodo add_to degli importi git-svn-id: svn://10.65.10.50/trunk@1491 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5e5cbf3d6b
commit
95edf6412b
@ -1,5 +1,6 @@
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <array.h>
|
||||
#include <strings.h>
|
||||
|
||||
@ -60,7 +61,7 @@ bool TArray::destroy(
|
||||
delete _data[i];
|
||||
_data[i] = NULL;
|
||||
}
|
||||
_items = 0;
|
||||
_items = _next = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,26 +73,33 @@ bool TArray::destroy(
|
||||
}
|
||||
|
||||
|
||||
TArray::TArray(int arraysize) : _size(0), _items(0), _data(NULL)
|
||||
TArray::TArray(int arraysize) : _size(0), _items(0), _next(0), _data(NULL)
|
||||
{
|
||||
if (arraysize) resize(arraysize);
|
||||
}
|
||||
|
||||
TArray::TArray() : _size(0), _items(0), _data(NULL)
|
||||
TArray::TArray() : _size(0), _items(0), _next(0), _data(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
TArray::TArray(const TArray& a) : _size(0), _items(0), _data(NULL)
|
||||
TArray::TArray(const TArray& a) : _size(0), _items(0), _next(0), _data(NULL)
|
||||
{
|
||||
(*this) = a;
|
||||
}
|
||||
|
||||
TArray& TArray::operator= (const TArray& a)
|
||||
{
|
||||
if (_items > 0) destroy();
|
||||
if (_size < a.size()) resize(a.size());
|
||||
for (_items = 0; _items < a.items(); _items++)
|
||||
_data[_items] = a[_items].dup();
|
||||
destroy();
|
||||
if (size() < a.size())
|
||||
resize(a.size());
|
||||
for (int i = a.size()-1; i >= 0; i--)
|
||||
{
|
||||
const TObject* o = a.objptr(i);
|
||||
if (o != NULL) _data[i] = o->dup();
|
||||
}
|
||||
_items = a.items();
|
||||
_next = a._next;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -176,7 +184,8 @@ int TArray::add(
|
||||
//
|
||||
// @xref <mf TArray::insert>
|
||||
{
|
||||
if (index < 0) for (index = 0; index < size() && _data[index]; index++);
|
||||
if (index < 0) for (index = _next; index < size() && _data[index]; index++);
|
||||
|
||||
if (index >= size()) resize(int(3L*index/2) + 1);
|
||||
|
||||
if (_data[index] != NULL)
|
||||
@ -193,8 +202,16 @@ int TArray::add(
|
||||
}
|
||||
|
||||
_data[index] = object;
|
||||
if (object != NULL) _items++;
|
||||
|
||||
if (object != NULL)
|
||||
{
|
||||
_items++;
|
||||
_next = index+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index < _next)
|
||||
_next = index;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -254,6 +271,8 @@ TObject* TArray::remove(
|
||||
{
|
||||
_data[index] = NULL;
|
||||
_items--;
|
||||
if (index < _next)
|
||||
_next = index;
|
||||
}
|
||||
if (dopack) pack();
|
||||
return o;
|
||||
@ -293,6 +312,7 @@ void TArray::pack()
|
||||
next++;
|
||||
}
|
||||
}
|
||||
_next = next;
|
||||
}
|
||||
|
||||
// @func Funzione per permettere il confonto tra 2 oggetti.
|
||||
|
@ -31,7 +31,9 @@ class TArray : public TObject
|
||||
int _size;
|
||||
// @cmember Numero di elementi presenti nell'array
|
||||
int _items;
|
||||
|
||||
// @cmember Prossimo elemento libero nell'array
|
||||
int _next;
|
||||
|
||||
// @access Protected Member
|
||||
protected:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <assoc.h>
|
||||
|
||||
// @doc EXTERNAL
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Cerca l'oggetto con chiave <p k>
|
||||
THash_object* TAssoc_array::_lookup(
|
||||
|
@ -164,8 +164,7 @@ public:
|
||||
|
||||
// if code == NULL it's a base form
|
||||
// otherwise it's integrated by a file definition
|
||||
TForm(const char* form, long code = 0L, int editlevel = 0,
|
||||
const char* desc = "");
|
||||
TForm(const char* form, long code = 0L, int editlevel = 0, const char* desc = "");
|
||||
virtual ~TForm();
|
||||
};
|
||||
|
||||
|
@ -258,7 +258,6 @@ void TMask::read_mask(const char* name, int num, int max)
|
||||
_pagewin[MAX_PAGES] = read_page(scanner, TRUE);
|
||||
}
|
||||
}
|
||||
main_app().end_wait();
|
||||
|
||||
if (_pages < 1)
|
||||
fatal_box("Impossibile leggere la maschera %s", name);
|
||||
@ -267,6 +266,8 @@ void TMask::read_mask(const char* name, int num, int max)
|
||||
|
||||
if (!_sheetmask)
|
||||
_total_time = clock()-start_t;
|
||||
|
||||
main_app().end_wait();
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,12 +335,13 @@ TMask_field* TSpreadsheet::col2field(int pos) const
|
||||
{
|
||||
int num;
|
||||
XI_OBJ** column = xi_get_member_list(_list, &num);
|
||||
CHECKD(pos >= 0 && pos < num, "Bad column number", pos);
|
||||
|
||||
TMask_field* good = NULL;
|
||||
for (short id = column[pos]->cid; ; id += 100)
|
||||
{
|
||||
TMask_field* f = field(id);
|
||||
if (f == NULL) break; // End of search
|
||||
if (f == NULL) break; // Search failed
|
||||
good = f; // We've found a field with the proper ID ...
|
||||
if (f->active()) break; // ... and it's active: end of search
|
||||
}
|
||||
@ -377,7 +378,7 @@ void TSpreadsheet::set_focus_cell(int riga, int colonna)
|
||||
if (!cell_disabled(r, colonna-1))
|
||||
break;
|
||||
|
||||
if (colonna < _columns)
|
||||
if (colonna <= _columns)
|
||||
{
|
||||
XI_OBJ cell;
|
||||
XI_MAKE_CELL(&cell, _list, riga, colonna);
|
||||
|
@ -991,12 +991,12 @@ void TDistrib::init (
|
||||
// Importo
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const TImporto& TImporto::add_to(TToken_string& s) const
|
||||
const TImporto& TImporto::add_to(TToken_string& s, int pos) const
|
||||
{
|
||||
const bool dare = sezione() == 'D';
|
||||
const char* v = valore().string();
|
||||
s.add(dare ? v : "", 0);
|
||||
s.add(dare ? "" : v, 1);
|
||||
s.add(dare ? v : "", pos);
|
||||
s.add(dare ? "" : v, pos+1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -270,9 +270,9 @@ public:
|
||||
|
||||
// @cmember Assegna sezione ed importo all'oggetto
|
||||
const TImporto& set(char s, const real& v);
|
||||
// @cmember Setta i primi due elementi della <c TToken_string>
|
||||
// al valore dell'importo, lasciando bianco il dare (0) o l'avere(1)
|
||||
const TImporto& add_to(TToken_string& s) const;
|
||||
// @cmember Setta i due elementi pos e pos+1 della <c TToken_string>
|
||||
// al valore dell'importo, lasciando bianco il dare (pos) o l'avere (pos+1)
|
||||
const TImporto& add_to(TToken_string& s, int pos) const;
|
||||
|
||||
// @cmember Costruttore
|
||||
TImporto(char s = 'D', const real& v = ZERO)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// $Id: relation.cpp,v 1.47 1995-06-19 14:08:55 alex Exp $
|
||||
// $Id: relation.cpp,v 1.48 1995-06-21 15:35:41 guy Exp $
|
||||
// relation.cpp
|
||||
// fv 12/8/93
|
||||
// relation class for isam files
|
||||
@ -1118,8 +1118,9 @@ TRecnotype TCursor::readrec()
|
||||
|
||||
int TCursor::lock(TReclock l)
|
||||
{
|
||||
CLockRec(&file().filehnd()->f, _pos, l);
|
||||
return file().filehnd()->f.IOR;
|
||||
SecDef* sd = &file().filehnd()->f;
|
||||
CLockRec(sd, _pos, l);
|
||||
return sd->IOR;
|
||||
}
|
||||
|
||||
TRecnotype TCursor::operator =(const TRecnotype pos)
|
||||
|
@ -271,7 +271,6 @@ static BOOLEAN event_hook(HWND hwnd,
|
||||
default:
|
||||
if (msg == WM_WAKEUP && wparam == main_app().waiting())
|
||||
main_app().wake_up();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user