8d493f3da9
git-svn-id: svn://10.65.10.50/branches/R_10_00@23071 c028cbd2-c16b-5b4b-a496-9718f37d4682
110 lines
3.2 KiB
C++
110 lines
3.2 KiB
C++
#ifndef __777LIB_H
|
|
#define __777LIB_H
|
|
|
|
#ifndef __ISAM_H
|
|
#include <isam.h>
|
|
#endif
|
|
|
|
// Codice fiscale di Sirio Informatica e Sistemi S.p.A.
|
|
#define CF_PRODUTTORE "04879210963"
|
|
|
|
enum { CODE_SIZE = 8, FIELD_SIZE = 16, BLOCK_SIZE = 24, HEADER_SIZE = 89, USEABLE_SIZE = 1800, TOTAL_SIZE = 1900 };
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TRecord770
|
|
///////////////////////////////////////////////////////////
|
|
|
|
enum M770FieldType { AN, CF, CN, PI, DA, DT, NU, PN, PR, CB, VP, VN };
|
|
|
|
struct TField770 : public TObject
|
|
{
|
|
TString _desc;
|
|
int _pos; // Base 1
|
|
int _len;
|
|
M770FieldType _type; // AN,NU,...
|
|
};
|
|
|
|
class TTracciato770 : public TObject
|
|
{
|
|
char _tipo;
|
|
TArray _fields;
|
|
|
|
protected:
|
|
void add_field(const char* name, M770FieldType tipo, int pos, int len, int filedno = 0);
|
|
void add_filler(int pos, int len, M770FieldType tipo = AN) { add_field("Filler", tipo, pos, len); }
|
|
|
|
TTracciato770() {}
|
|
void set_tipo(char t) { _tipo = t; }
|
|
|
|
public:
|
|
bool exists(int pos) const { return _fields.objptr(pos-1) != NULL; }
|
|
const TField770& field(int pos) const;
|
|
void auto_fill(TString& buffer) const;
|
|
int campi_posizionali() const { return _fields.last()+1; }
|
|
|
|
TTracciato770(char tipo);
|
|
virtual ~TTracciato770();
|
|
};
|
|
|
|
|
|
class TRecord770 : public TObject
|
|
{
|
|
TString _buffer;
|
|
|
|
protected: // TObject
|
|
virtual TObject* dup() const { return new TRecord770(*this); }
|
|
virtual void print_on(ostream& outs) const;
|
|
virtual void read_from(istream& ins);
|
|
|
|
protected: // TObject
|
|
virtual const TTracciato770& tracciato() const;
|
|
|
|
const TField770& get_field(int pos) const;
|
|
void set(const TField770& fld, const char* val);
|
|
int calculate_blocks(const char* val) const;
|
|
|
|
public:
|
|
void set(int pos, const char* val);
|
|
void set(int pos, int val);
|
|
void set(int pos, long val);
|
|
void set(int pos, const real& val);
|
|
void set(int pos, const TDate& val);
|
|
void set(int pos, char val);
|
|
void set(int pos, bool val);
|
|
bool np_put(const char* code, const char* val);
|
|
bool np_put(const char* code, const real& val);
|
|
bool np_put(const char* code, long val);
|
|
bool np_put(const char* code, char val);
|
|
bool np_put(const char* code, const TDate& date);
|
|
bool np_put(const char* code, bool cb);
|
|
|
|
const char* get(int pos, TString& str) const;
|
|
int get_int(int pos) const;
|
|
char get_char(int pos) const;
|
|
|
|
bool np_get(int pos, TString& key, TString& val) const;
|
|
bool np_get_real(int pos, TString& key, real& val) const;
|
|
|
|
const TRecord770& operator=(const TRecord770& rec)
|
|
{ _buffer = rec._buffer; return *this; }
|
|
|
|
char tipo_record() const { return _buffer[0]; }
|
|
void tipo_record(char tipo);
|
|
|
|
int campi_posizionali() const { return tracciato().campi_posizionali(); }
|
|
void azzera_campi_non_posizionali();
|
|
virtual bool ha_campi_non_posizionali() const { return strchr("DEFGHJ", tipo_record()) != NULL; }
|
|
bool ha_campi_non_posizionali_compilati() const
|
|
{ return _buffer[90] > ' ' && ha_campi_non_posizionali(); }
|
|
|
|
virtual bool valid() const;
|
|
|
|
TRecord770();
|
|
TRecord770(char tipo);
|
|
TRecord770(const TRecord770& rec);
|
|
TRecord770(const TRectype& rec);
|
|
virtual ~TRecord770();
|
|
};
|
|
|
|
#endif
|