#ifndef __SQLITE_H #define __SQLITE_H #ifndef __SHEET_H #include #endif struct TRecordset_column_info : public TObject { TString _name; int _width; bool _numeric; }; /////////////////////////////////////////////////////////// // TRecordset /////////////////////////////////////////////////////////// enum TRecordsetExportFormat { fmt_unknown, fmt_html, fmt_text, fmt_silk, fmt_campo }; class TRecordset : public TObject { protected: bool save_as_html(const char* path); bool save_as_silk(const char* path); bool save_as_text(const char* path); bool save_as_campo(const char* path); public: // Absolutely needed methods virtual TRecnotype items() const pure; virtual bool move_to(TRecnotype pos) pure; virtual TRecnotype current_row() const pure; virtual unsigned int columns() const pure; virtual const TRecordset_column_info& column_info(unsigned int column) const pure; virtual const TString& get(unsigned int column) const pure; virtual const TString& get(const char* column_name) const; virtual const TToken_string& sheet_head() const; virtual bool save_as(const char* path, TRecordsetExportFormat fmt = fmt_unknown); }; /////////////////////////////////////////////////////////// // TSQL_recordset /////////////////////////////////////////////////////////// class TSQL_recordset : public TRecordset { TString _sql; TRecnotype _firstrow, _pagesize, _items, _current_row; TArray _column; TArray _page; protected: void reset(); public: // TRecordset virtual TRecnotype items() const; virtual bool move_to(TRecnotype pos); virtual TRecnotype current_row() const { return _current_row; } virtual unsigned int columns() const; virtual const TRecordset_column_info& column_info(unsigned int c) const; virtual const TString& get(unsigned int column) const; public: void set(const char* sql); // Internal use only virtual int on_get_items(int argc, char** values, char** columns); const TString_array* row(TRecnotype n); TSQL_recordset(const char* sql); virtual ~TSQL_recordset() { } }; /////////////////////////////////////////////////////////// // TRecordset_sheet /////////////////////////////////////////////////////////// class TRecordset_sheet : public TSheet { TRecordset& _query; protected: virtual void get_row(long r, TToken_string& row); virtual long get_items() const; public: TRecordset_sheet(TRecordset& sql); }; /////////////////////////////////////////////////////////// // Utility /////////////////////////////////////////////////////////// void get_sql_directory(TFilename& path); bool select_sql_file(TFilename& path, const char* ext); #endif