COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libaccess/include/coopy/AccessSheet.h
Go to the documentation of this file.
00001 #ifndef COOPY_ACCESSSHEET
00002 #define COOPY_ACCESSSHEET
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 AccessSheet;
00014       class AccessSheetSchema;
00015     }
00016   }
00017 }
00018 
00022 class coopy::store::mdb::AccessSheet : public DataSheet {
00023 public:
00024   AccessSheet(void *db, const char *name, const Property& config);
00025 
00026   bool connect();
00027 
00028   virtual ~AccessSheet();
00029 
00030   virtual int width() const  { return w; }
00031   virtual int height() const { return h; }
00032 
00033   virtual std::string cellString(int x, int y) const;
00034 
00035   virtual std::string cellString(int x, int y, bool& escaped) const;
00036 
00037   virtual ColumnInfo getColumnInfo(int x) {
00038     ColumnType t(col2type[x]);
00039     t.primaryKey = col2pk[x];
00040     t.primaryKeySet = true;
00041     //printf(">> %d %s\n", x, col2sql[x].c_str());
00042     return ColumnInfo(col2sql[x],t);
00043   }
00044 
00045   virtual int getColumnCount() const {
00046     return (int)col2sql.size();
00047   }
00048 
00049   virtual SheetSchema *getSchema() const;
00050 
00051   virtual bool hasExternalColumnNames() const {
00052     return true;
00053   }
00054 
00055   std::string getName() const {
00056     return name;
00057   }
00058 
00059   virtual ColumnRef insertColumn(const ColumnRef& base, const ColumnInfo& kind) {
00060     return ColumnRef();
00061   }
00062 
00063   virtual bool modifyColumn(const ColumnRef& base, const ColumnInfo& kind) {
00064     return false;
00065   }
00066 
00067   virtual bool canWrite() { return false; }
00068 
00069 private:
00070   AccessSheetSchema *schema;
00071   Property config;
00072   void *implementation;
00073   void *table_implementation;
00074   std::string name;
00075   int w, h;
00076   std::vector<std::string> col2sql;
00077   std::vector<std::string> col2type;
00078   std::vector<bool> col2pk;
00079   SparseStringSheet cache;
00080   SparseByteSheet cacheFlag;
00081  
00082 };
00083 
00087 class coopy::store::mdb::AccessSheetSchema : public SheetSchema {
00088 public:
00089   AccessSheet *sheet;
00090 
00091   virtual std::string getSheetName() const {
00092     return sheet->getName();
00093   }
00094 
00095   virtual ColumnInfo getColumnInfo(int x) const {
00096     return sheet->getColumnInfo(x);
00097   }
00098 
00099   virtual int getColumnCount() const {
00100     return sheet->getColumnCount();
00101   }
00102 
00103   virtual bool providesPrimaryKeys() const {
00104     return true;
00105   }
00106 };
00107 
00108 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines