8a7486d866
Files correlati : ca2.exe ca2500a.msk Ricompilazione Demo : [ ] Commento : Aggiunto programma di invio a Board. Ripristinate funzioni di visualizzazione e salvataggio ripartizione temporale delle righe nella modifica movimenti analitici git-svn-id: svn://10.65.10.50/branches/R_10_00@23201 c028cbd2-c16b-5b4b-a496-9718f37d4682
174 lines
6.0 KiB
C++
Executable File
174 lines
6.0 KiB
C++
Executable File
#ifndef __RECORDSET_H
|
|
#define __RECORDSET_H
|
|
|
|
#ifndef XVT_INCL_XVT
|
|
#include <xvt.h>
|
|
#endif
|
|
|
|
#ifndef __RELATION_H
|
|
#include <relation.h>
|
|
#endif
|
|
|
|
#ifndef __VARIANT_H
|
|
#include <variant.h>
|
|
#endif
|
|
|
|
struct TRecordset_column_info : public TObject
|
|
{
|
|
TString _name; // Table.Column
|
|
int _width, _pos;
|
|
TFieldtypes _type;
|
|
|
|
void copy(const TRecordset_column_info & i) { _name = i._name; _width = i._width; _pos = i._pos; _type = i._type; }
|
|
virtual TObject* dup() const { return new TRecordset_column_info(*this); }
|
|
|
|
TRecordset_column_info(const TRecordset_column_info & i) {copy(i);}
|
|
TRecordset_column_info() : _width(0), _pos(0), _type(_alfafld) {}
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TAttributes
|
|
///////////////////////////////////////////////////////////
|
|
|
|
struct TAttributes : public TObject
|
|
{
|
|
XVT_FNTID _font;
|
|
COLOR _back;
|
|
COLOR _fore;
|
|
|
|
public:
|
|
XVT_FNTID get_font() const{ return _font; }
|
|
COLOR get_background() const { return _back; }
|
|
COLOR get_foreground() const { return _fore; }
|
|
void set_font(XVT_FNTID font) { _font = font; }
|
|
void set_background(COLOR back) { _back = back; }
|
|
void set_foreground(COLOR fore) { _fore = fore; }
|
|
|
|
TAttributes() : _font(NULL), _back(COLOR_INVALID), _fore(COLOR_INVALID) {}
|
|
virtual ~TAttributes() {}
|
|
};
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TRecordset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
enum TRecordsetExportFormat { fmt_unknown, fmt_html, fmt_text, fmt_campo, fmt_dbf, fmt_as400, fmt_csv };
|
|
|
|
class TRecordset : public TObject
|
|
{
|
|
TAssoc_array _var;
|
|
TString_array _varnames;
|
|
const TRecordset* _parentset;
|
|
char _text_separator;
|
|
|
|
protected:
|
|
virtual bool save_as_html(const char* path);
|
|
virtual bool save_as_text(const char* path);
|
|
virtual bool save_as_as400(const char* path) { set_text_separator(' '); return save_as_text(path);}
|
|
virtual bool save_as_csv(const char* path) { set_text_separator(';'); return save_as_text(path);}
|
|
virtual bool save_as_campo(const char* path);
|
|
virtual bool save_as_dbf(const char* table, int mode);
|
|
|
|
void find_and_reset_vars();
|
|
void parsed_text(TString& sql) const;
|
|
TVariant& get_tmp_var() const;
|
|
bool export_dbf(int logicnum);
|
|
|
|
public: // Absolutely needed methods
|
|
virtual TRecnotype items() const pure;
|
|
virtual bool move_to(TRecnotype pos) pure;
|
|
virtual TRecnotype current_row() const pure;
|
|
virtual void requery() pure;
|
|
bool empty() const { return items() == 0; }
|
|
virtual const TString& query_text() const pure;
|
|
virtual const TString& driver_version() const;
|
|
|
|
virtual char text_separator() const { return _text_separator;}
|
|
virtual void set_text_separator(char sep) { _text_separator = sep;}
|
|
|
|
virtual void freeze() {}
|
|
virtual bool move_first() { return move_to(0); }
|
|
virtual bool move_prev() { return move_to(current_row()-1); }
|
|
virtual bool move_next() { return move_to(current_row()+1); }
|
|
virtual bool move_last() { return move_to(items()-1); }
|
|
virtual bool bof() const { return current_row() == TRecnotype(-1); }
|
|
virtual bool eof() const { return current_row() >= items(); }
|
|
|
|
virtual unsigned int columns() const pure;
|
|
virtual const TRecordset_column_info& column_info(unsigned int column) const pure;
|
|
virtual const TRecordset_column_info& add_column_info(const TRecordset_column_info& c) {return c; }
|
|
virtual const TVariant& get(unsigned int column) const pure;
|
|
|
|
virtual const TString_array& variables() const { return _varnames; }
|
|
virtual const TVariant& get_var(const char* name) const;
|
|
virtual bool set_var(const char* name, const TVariant& var, bool create = false);
|
|
virtual bool ask_variables(bool all);
|
|
|
|
virtual int find_column(const char* column_name) const;
|
|
virtual const TVariant& get(const char* column_name) const;
|
|
virtual bool get_attr(int column, TAttributes & attr, bool header = false) const { return false; }
|
|
bool get_attr(const char* column_name, TAttributes & attr, bool header = false) const { return get_attr(column_name, attr, header); }
|
|
virtual const TToken_string& sheet_head() const;
|
|
|
|
// mode = 0|1=append 2=update 3=update|append 4=zap before writing
|
|
virtual bool save_as(const char* path, TRecordsetExportFormat fmt = fmt_unknown, int mode = 0);
|
|
|
|
void set_parent(const TRecordset* rs) { _parentset = rs; }
|
|
TRecordset();
|
|
virtual ~TRecordset() { }
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TISAM_recordset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TISAM_recordset : public TRecordset
|
|
{
|
|
TString _use;
|
|
|
|
TRelation* _relation;
|
|
TCursor* _cursor;
|
|
TArray _column; // Column infos
|
|
|
|
protected:
|
|
TRelation* relation() const;
|
|
|
|
virtual void reset();
|
|
virtual const TVariant& get_field(int logic, const char* field) const;
|
|
virtual void set_custom_filter(TCursor& cursor) const { }
|
|
|
|
|
|
public:
|
|
bool valid_cursor() const { return _cursor != NULL; }
|
|
virtual TCursor* cursor() const;
|
|
void set(const char* use);
|
|
virtual void requery();
|
|
virtual TRecnotype items() const;
|
|
virtual bool move_to(TRecnotype pos);
|
|
virtual TRecnotype current_row() const;
|
|
virtual unsigned int columns() const;
|
|
virtual const TRecordset_column_info& column_info(unsigned int c) const;
|
|
virtual const TRecordset_column_info& add_column_info(const TRecordset_column_info& c) { _column.add(c); return c; }
|
|
virtual const TVariant& get(unsigned int column) const;
|
|
virtual const TVariant& get(const char* column_name) const;
|
|
virtual const TVariant& get(int logic, const char* field) const { return get_field(logic, field);}
|
|
virtual const TString& driver_version() const;
|
|
virtual const TString& query_text() const { return _use; }
|
|
|
|
TISAM_recordset(const char* use);
|
|
virtual ~TISAM_recordset();
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Utility
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool list_custom_files(const char* ext, const char* library, TString_array& files);
|
|
bool select_custom_file(TFilename& path, const char* ext, const char* library = NULL);
|
|
const TString& logic2table(int logic_num);
|
|
int table2logic(const TString& name);
|
|
TRecordset* create_recordset(const TString& sql);
|
|
|
|
|
|
#endif |