campo-sirio/ve/clifor.cpp
alex a44a144cea Errori aga105, aga107, aga111, aga116
git-svn-id: svn://10.65.10.50/trunk@5013 c028cbd2-c16b-5b4b-a496-9718f37d4682
1997-08-01 09:20:02 +00:00

141 lines
3.1 KiB
C++
Executable File

#include "clifor.h"
#ifndef __CONFIG_H
#include "config.h"
#endif
#ifndef __VE0100_H
#include "ve0100.h"
#endif
#ifndef __VE0100O_H
#include "ve0100o.h"
#endif
#ifndef __VEINI_H
#include "veini.h"
#endif
#ifndef __VELIB_H
#include "velib.h"
#endif
TOccasionale::TOccasionale() : TRectype(LF_OCCAS)
{
_cod = new TRecfield(*this, OCC_CFPI);
}
TOccasionale::TOccasionale(const TRectype& r) : TRectype(r)
{
_cod = new TRecfield(*this, OCC_CFPI);
}
TRectype & TOccasionale::operator = (const TRectype& r)
{
return TRectype::operator=(r);
}
TOccasionale::~TOccasionale()
{
delete _cod;
}
int TCli_for::write_rewrite(TBaseisamfile& f, bool re) const
{
int err = TMultiple_rectype::write_rewrite(f, re);
if (err == NOERR)
{
TLocalisamfile v(LF_CFVEN);
TRectype & v_rec = vendite();
err = v.write(v_rec);
if (err == _isreinsert)
err = v.write(v_rec);
}
return err;
}
TRectype & TCli_for::vendite() const
{
const char t = tipo();
const long c = codice();
if (_ven_rec.empty() || t != *(const char *) (*_ven_tipo) || c != (long) *_ven_codice)
{
TLocalisamfile v(LF_CFVEN);
((TCli_for *)this)->_ven_rec.zero();
((TCli_for *)this)->_ven_rec.put(CFV_TIPOCF,t);
((TCli_for *)this)->_ven_rec.put(CFV_CODCF, c);
TRectype v_rec(_ven_rec);
if (((TCli_for *)this)->_ven_rec.read(v) != NOERR)
((TCli_for *)this)->_ven_rec = v_rec;
}
return (TRectype &) _ven_rec;
}
int TCli_for::read(TRectype & rec, word op, word lockop)
{
int err = TMultiple_rectype::read(rec, op, lockop);
_ven_rec.zero();
return err;
}
int TCli_for::read(char tipo, long codice, word op, word lockop)
{
zero();
put(CLI_TIPOCF, tipo);
put(CLI_CODCF, codice);
return TMultiple_rectype::read(op, lockop);
}
int TCli_for::remove(TBaseisamfile& f) const
{
TLocalisamfile v(LF_CFVEN);
const int err = vendite().remove(v);
if (err != NOERR && err != _iskeynotfound)
return err;
return TMultiple_rectype:: remove(f);
}
TCli_for::TCli_for(char tipo, long codice) : TMultiple_rectype( LF_CLIFO ), _ven_rec(LF_CFVEN)
{
_tipo = new TRecfield(*this, CLI_TIPOCF);
_codice = new TRecfield(*this, CLI_CODCF);
_ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF);
_ven_codice = new TRecfield(_ven_rec, CFV_CODCF);
add_file(LF_INDSP, IND_CODIND);
read(tipo, codice);
}
TCli_for::TCli_for(const TRectype & rec) : TMultiple_rectype(rec), _ven_rec(LF_CFVEN)
{
_tipo = new TRecfield(*this, CLI_TIPOCF);
_codice = new TRecfield(*this, CLI_CODCF);
_ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF);
_ven_codice = new TRecfield(_ven_rec, CFV_CODCF);
add_file(LF_INDSP, IND_CODIND);
read((TRectype &) rec);
}
TCli_for::TCli_for(const TCli_for & c) : TMultiple_rectype(c), _ven_rec(c._ven_rec)
{
_tipo = new TRecfield(*this, CLI_TIPOCF);
_codice = new TRecfield(*this, CLI_CODCF);
_ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF);
_ven_codice = new TRecfield(_ven_rec, CFV_CODCF);
}
TCli_for::~TCli_for()
{
delete _tipo;
delete _codice;
delete _ven_tipo;
delete _ven_codice;
}