Main Page | Namespace List | Class List | File List | Class Members | File Members | Related Pages

datastore.h

Go to the documentation of this file.
00001 #ifndef DATASTORE_H
00002 #define DATASTORE_H 
00003 #include <iostream>
00004 #include <string>
00005 #include <sstream>
00006 #include <cstdlib>
00007 #include <algorithm>
00008 #include <exception>
00009 #include <stdexcept>
00010 #include <sys/types.h>
00011 #include <sys/stat.h>
00012 #include <fcntl.h>
00013 #include <unistd.h>
00014 #include <fstream>
00015 #include <errno.h>
00016 #include "cdb.h"
00017 #include "cdb_make.h"
00018 #define BADLOGRECORD 0
00019 #define CANTBACKUPDATABASE 1
00020 // This code is copyright Joshua Smith 2004
00021 // and is released under the GPL
00022 namespace Constant {
00023 
00028   class Datastore {
00030   private:
00031     cdb *db;
00032     int fd;
00033     std::ofstream logfile;
00034     std::ifstream key_sequencedb;
00035     std::string dbfilename;
00036     std::string logfilename;
00037     std::string last_key;
00038     uint32 end_of_data;
00039   public:
00041     Datastore();
00044     Datastore(const std::string &filen);
00045 
00046     ~Datastore();
00049     std::string fetch(const std::string &key_val);
00050 
00052     std::string fetch_next();
00053 
00056     void setdb(const std::string &filen);
00057 
00060     std::string operator[](const std::string &);
00061 
00067     void initlog(const std::string &logfilen);
00068 
00071     void log(const std::string&,const std::string &);
00072 
00076     void commitlog();
00077     
00081     void commitlog(const std::string &);
00082 
00091     void backupdb();
00092 
00097     void dump(const std::string &dumpfilename);
00098 
00102     std::pair<std::string,std::string> first();
00105     std::pair<std::string,std::string> next();
00106     
00107   private:
00108     int statdb();
00109     //int check_filesys_space();
00110   };
00111 }
00112 #endif

Generated on Mon Apr 26 09:49:22 2004 for ConstantDataStore by doxygen 1.3.6-20040222