COOPY » Guide
version 0.6.5
|
00001 #ifndef COOPY_JACKTEXTBOOK 00002 #define COOPY_JACKTEXTBOOK 00003 00004 #include <coopy/TextBook.h> 00005 #include <coopy/TextBookFactory.h> 00006 00007 namespace coopy { 00008 namespace store { 00009 namespace mdb { 00010 class JackTextBook; 00011 class JackTextBookFactory; 00012 } 00013 } 00014 } 00015 00016 class coopy::store::mdb::JackTextBook : public TextBook { 00017 public: 00018 JackTextBook(); 00019 virtual ~JackTextBook(); 00020 00021 void clear(); 00022 00023 bool read(const char *fname); 00024 00025 virtual bool open(const Property& config); 00026 00027 std::vector<std::string> getNames() { 00028 return names; 00029 } 00030 00031 PolySheet readSheet(const std::string& name); 00032 00033 virtual bool inplace() const { 00034 return true; 00035 } 00036 00037 virtual bool canWrite() const { 00038 return true; 00039 } 00040 00041 virtual bool addSheet(const SheetSchema& schema); 00042 00043 00044 virtual std::string desc() const { 00045 return "JackAccessBook"; 00046 } 00047 00048 private: 00049 void *implementation; 00050 00051 Property config; 00052 00053 std::vector<std::string> names; 00054 00055 std::vector<std::string> getNamesImpl(); 00056 00057 static int uses; 00058 00059 }; 00060 00061 00062 class coopy::store::mdb::JackTextBookFactory : public TextBookFactory { 00063 public: 00064 virtual std::string getName() { 00065 return "jackcess"; 00066 } 00067 00068 virtual TextBook *open(AttachConfig& config, AttachReport& report) { 00069 JackTextBook *book = new JackTextBook(); 00070 if (book==NULL) return NULL; 00071 if (!book->open(config.options)) { 00072 delete book; 00073 book = NULL; 00074 } 00075 if (config.shouldWrite) { 00076 if (config.prevBook!=NULL) { 00077 if (!book->copy(*config.prevBook,config.options)) { 00078 delete book; 00079 book = NULL; 00080 report.msg = "data transfer failed"; 00081 } 00082 } 00083 } 00084 if (book!=NULL) { 00085 report.success = true; 00086 } 00087 return book; 00088 } 00089 }; 00090 00091 #endif