ARC SDK
DBInterface.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 #ifndef __ARC_DBINTERFACE_H__
4 #define __ARC_DBINTERFACE_H__
5 
6 #include <vector>
7 #include <string>
8 
9 namespace Arc {
11 
15  class Database {
16  public:
18  Database() {}
20  Database(std::string& server, int port) {}
22  Database(const Database& other) {}
24  virtual ~Database() {}
25 
27 
31  virtual bool connect(std::string& dbname, std::string& user,
32  std::string& password) = 0;
34  virtual bool isconnected() const = 0;
36  virtual void close() = 0;
38 
43  virtual bool enable_ssl(const std::string& keyfile = "", const std::string& certfile = "",
44  const std::string& cafile = "", const std::string& capath = "") = 0;
46  virtual bool shutdown() = 0;
47  };
48 
49  typedef std::vector<std::vector<std::string> > QueryArrayResult;
50  typedef std::vector<std::string> QueryRowResult;
51 
53 
54  class Query {
55  public:
57  Query() {}
59 
61  Query(Database *db) {}
62  //Query(Database* db, const std::string& sqlstr);
64  virtual ~Query() {}
65 
67  virtual int get_num_colums() = 0;
69  virtual int get_num_rows() = 0;
70 
72 
73  virtual bool execute(const std::string& sqlstr) = 0;
75 
77  virtual QueryRowResult get_row(int row_number) const = 0;
79 
81  virtual QueryRowResult get_row() const = 0;
83 
87  virtual std::string get_row_field(int row_number, std::string& field_name) = 0;
89 
96  virtual bool get_array(std::string& sqlstr, QueryArrayResult& result, std::vector<std::string>& arguments) = 0;
97  };
98 
99 } // namespace Arc
100 
101 #endif /* __ARC_DBINTERFACE_H__ */