Back to index

nordugrid-arc-nox  1.1.0~rc6
DBInterface.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_DBINTERFACE_H__
00004 #define __ARC_DBINTERFACE_H__
00005 
00006 #include <vector>
00007 #include <string>
00008 
00009 namespace Arc {
00011 
00014   class Database {
00015   public:
00017     Database() {}
00020     Database(std::string& server, int port) {}
00022     Database(const Database& other) {}
00024     virtual ~Database() {}
00025 
00031     virtual bool connect(std::string& dbname, std::string& user,
00032                          std::string& password) = 0;
00034     virtual bool isconnected() const = 0;
00036     virtual void close() = 0;
00043     virtual bool enable_ssl(const std::string keyfile = "", const std::string certfile = "",
00044                             const std::string cafile = "", const std::string capath = "") = 0;
00046     virtual bool shutdown() = 0;
00047   };
00048 
00049   typedef std::vector<std::vector<std::string> > QueryArrayResult;
00050   typedef std::vector<std::string> QueryRowResult;
00051 
00052   class Query {
00053   public:
00055     Query() {}
00058     Query(Database *db) {}
00059     //Query(Database* db, const std::string& sqlstr);
00061     virtual ~Query() {}
00062 
00064     virtual int get_num_colums() = 0;
00066     virtual int get_num_rows() = 0;
00067 
00070     virtual bool execute(const std::string& sqlstr) = 0;
00074     virtual QueryRowResult get_row(int row_number) const = 0;
00077     virtual QueryRowResult get_row() const = 0;
00083     virtual std::string get_row_field(int row_number, std::string& field_name) = 0;
00090     virtual bool get_array(std::string& sqlstr, QueryArrayResult& result, std::vector<std::string>& arguments) = 0;
00091   };
00092 
00093 } // namespace Arc
00094 
00095 #endif /* __ARC_DBINTERFACE_H__ */