COOPY » Guide
version 0.6.5
|
00001 #ifndef COOPY_JACKSHEET 00002 #define COOPY_JACKSSHEET 00003 00004 #include <coopy/DataSheet.h> 00005 #include <coopy/SparseSheet.h> 00006 #include <coopy/Property.h> 00007 00008 #include <vector> 00009 00010 namespace coopy { 00011 namespace store { 00012 namespace mdb { 00013 class JackSheet; 00014 class JackSheetSchema; 00015 } 00016 } 00017 } 00018 00019 class coopy::store::mdb::JackSheet : public DataSheet { 00020 public: 00021 JackSheet(void *db, void *box, const char *name, const Property& config); 00022 00023 bool connect(); 00024 00025 virtual ~JackSheet(); 00026 00027 virtual int width() const { return w; } 00028 virtual int height() const { return h; } 00029 00030 virtual std::string cellString(int x, int y) const; 00031 00032 virtual std::string cellString(int x, int y, bool& escaped) const; 00033 00034 virtual bool cellString(int x, int y, const std::string& str) { 00035 return cellString(x,y,str,false); 00036 } 00037 00038 virtual bool cellString(int x, int y, const std::string& str, bool escaped); 00039 00040 virtual ColumnInfo getColumnInfo(int x) { 00041 ColumnType t(col2type[x]); 00042 t.primaryKey = col2pk[x]; 00043 t.primaryKeySet = true; 00044 return ColumnInfo(col2sql[x],t); 00045 } 00046 00047 virtual int getColumnCount() const { 00048 return (int)col2sql.size(); 00049 } 00050 00051 virtual SheetSchema *getSchema() const; 00052 00053 virtual bool hasExternalColumnNames() const { 00054 return true; 00055 } 00056 00057 std::string getName() const { 00058 return name; 00059 } 00060 00061 virtual ColumnRef insertColumn(const ColumnRef& base, const ColumnInfo& kind) { 00062 return ColumnRef(); 00063 } 00064 00065 virtual bool modifyColumn(const ColumnRef& base, const ColumnInfo& kind) { 00066 return false; 00067 } 00068 00069 virtual bool canWrite() { return true; } 00070 00071 private: 00072 JackSheetSchema *schema; 00073 Property config; 00074 void *implementation; 00075 void *box_implementation; 00076 void *table_implementation; 00077 void *cursor_implementation; 00078 std::string name; 00079 int w, h; 00080 std::vector<std::string> col2sql; 00081 std::vector<std::string> col2type; 00082 std::vector<bool> col2pk; 00083 std::vector<void *> savepoint; 00084 std::vector<void *> col2raw; 00085 SparseStringSheet cache; 00086 SparseByteSheet cacheFlag; 00087 00088 }; 00089 00090 class coopy::store::mdb::JackSheetSchema : public SheetSchema { 00091 public: 00092 JackSheet *sheet; 00093 00094 virtual std::string getSheetName() const { 00095 return sheet->getName(); 00096 } 00097 00098 virtual ColumnInfo getColumnInfo(int x) const { 00099 return sheet->getColumnInfo(x); 00100 } 00101 00102 virtual int getColumnCount() const { 00103 return sheet->getColumnCount(); 00104 } 00105 00106 virtual bool providesPrimaryKeys() const { 00107 return true; 00108 } 00109 }; 00110 00111 #endif