Modificata la funzione len(int) in reset(int)

git-svn-id: svn://10.65.10.50/trunk@490 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-10-31 11:11:19 +00:00
parent 5ca5c84738
commit 7393952fab
2 changed files with 43 additions and 43 deletions

View File

@ -16,37 +16,38 @@
//#include <csort.h>
TSort::TSort(int len)
{
_sortvar = new s_prm;
_sortvar->rc_len = len;
nsortkey = 0;
for (int i = 0; i < NOFLDS; i++)
{
_sortvar->s_fld[i].f_pos = 0;
_sortvar->s_fld[i].f_len = 0;
_sortvar->s_fld[i].ad = ' ';
}
{
_sortvar->s_fld[i].f_pos = 0;
_sortvar->s_fld[i].f_len = 0;
_sortvar->s_fld[i].ad = ' ';
}
}
TSort::~TSort()
{
delete _sortvar;
}
void TSort::init()
{
CHECK(_sortvar->rc_len && nsortkey, "Attempt to initialize undefined sort");
while (retrieve() != NULL);
init_sort(_sortvar);
}
void TSort::sort(const char* record)
{
CHECK(record != NULL, "Bad record to sort");
::sort((char*)record);
@ -54,21 +55,21 @@ void TSort::sort(const char* record)
void TSort::endsort()
{
::sort(NULL);
}
const char* TSort::retrieve()
{
return (const char *) sort_op();
}
void TSort::stats()
{
sort_stats();
}
@ -81,15 +82,16 @@ int TSort::length() const
}
void TSort::length(int len)
void TSort::reset(int len)
{
_sortvar->rc_len = len ;
nsortkey = 0;
}
void TSort::addsortkey(int pos, int len, char direction)
{
CHECK(pos >= 0 && pos+len <= _sortvar->rc_len, "Invalid sort key");
_sortvar->s_fld[nsortkey].f_pos = pos + 1;
@ -99,13 +101,10 @@ void TSort::addsortkey(int pos, int len, char direction)
void TSort::addsortkey(TRecfield& f, char direction)
{
CHECK(f.pos() != NULL, "Invalid sort key");
_sortvar->s_fld[nsortkey].f_pos = (f.pos() - f.record().string()) + 1;
_sortvar->s_fld[nsortkey].f_len = f.len();
_sortvar->s_fld[nsortkey++].ad = direction;
}

View File

@ -2,22 +2,22 @@
#define __SORT_H
#ifndef __OBJECT_H
#include <object.h>
#include <object.h>
#endif
#ifndef __ISAM_H
#include <isam.h>
#include <isam.h>
#endif
/*
@(SH) Header
@(SH) Header
@(C#) PUBBLICHE
@(C#) PUBBLICHE
@(C$) PRIVATE
@(VG#) PUBBLICHE
@(VG$) PRIVATE
*/
@(C$) PRIVATE
@(VG#) PUBBLICHE
@(VG$) PRIVATE
*/
// @C
// Classe TSort
@ -25,24 +25,25 @@
class TSort : public TObject
{
// @DPRIV
friend TRecfield;
struct s_prm* _sortvar; // Puntatore alla struttura di un sort
int nsortkey; // Indice nella tabella dei campi della chiave
// @DPRIV
friend TRecfield;
struct s_prm* _sortvar; // Puntatore alla struttura di un sort
int nsortkey; // Indice nella tabella dei campi della chiave
public:
// @FPUB
void init(); // Chiama init_sort
void sort(const char * record); // Chiama sort (record)
void endsort(); // Chiama sort (NULL)
const char* retrieve(); // Chiama sort_op()
void stats(); // Chiama sort_stats
// @FPUB
void init(); // Chiama init_sort
void sort(const char * record); // Chiama sort (record)
void endsort(); // Chiama sort (NULL)
const char* retrieve(); // Chiama sort_op()
void stats(); // Chiama sort_stats
int length() const; // Ritorna la lunghezza del record di sort
void length(int len); // Imposta la lunghezza del record di sort
void addsortkey(int pos, int len, char direction = 'a');
void addsortkey(TRecfield& f, char direction = 'a');
int length() const; // Ritorna la lunghezza del record di sort
void reset(int len); // Imposta la lunghezza del record di sort
// e inizializza il sort
void addsortkey(int pos, int len, char direction = 'a');
void addsortkey(TRecfield& f, char direction = 'a');
TSort(int reclen = 0);
virtual ~TSort();
TSort(int reclen = 0);
virtual ~TSort();
};
#endif // __SORT_H