LiteSQL  0.3.10
backend.hpp
Go to the documentation of this file.
1 /* LiteSQL
2  *
3  * The list of contributors at http://litesql.sf.net/
4  *
5  * See LICENSE for copyright information. */
6 
10 #ifndef litesql_backend_hpp
11 #define litesql_backend_hpp
12 #include <memory>
13 #include "litesql/types.hpp"
14 namespace litesql {
15  using namespace std;
16 
17 
19  class Backend {
20  public:
23  class Cursor {
24  public:
26  virtual ~Cursor() {}
31  virtual void setCacheSize(int s) {}
34  virtual Record fetchOne()=0;
35  };
36  class Result {
37  public:
39  virtual ~Result() {}
41  virtual size_t fieldNum() const=0;
43  virtual Record fields() const=0;
45  virtual size_t recordNum() const=0;
47  virtual Records records() const=0;
48 
49  };
51  virtual ~Backend() {}
54  virtual bool supportsSequences() const {
55  return false;
56  }
59  virtual string getRowIDType() const {
60  return "INTEGER PRIMARY KEY";
61  }
64  virtual string getInsertID() const { return ""; }
66  virtual void begin() const {}
68  virtual void commit() const {}
70  virtual void rollback() const {}
74  virtual Result* execute(const string& query) const = 0;
79  virtual Cursor* cursor(const string& query) const = 0;
87  virtual string groupInsert(Record tables, Records fields, Records values,
88  const string& sequence) const;
94  static Backend* getBackend(const string& type,const string& connInfo);
95 
96  };
97 }
98 
99 #endif
Definition: backend.hpp:14
virtual string getRowIDType() const
backend may want to set an AUTO_INCREMENT-attribute for table&#39;s primary key field.
Definition: backend.hpp:59
virtual void rollback() const
rollback SQL transaction
Definition: backend.hpp:70
An abstract base class for cursors that iterate result sets returned by relational database...
Definition: backend.hpp:23
virtual void setCacheSize(int s)
if inherited Cursor can cache its data to speed up iteration, this method is used to set cache size...
Definition: backend.hpp:31
Definition: backend.hpp:36
virtual ~Backend()
empty
Definition: backend.hpp:51
contains class Record and typedef Records
An abstract base class for interfacing with relational databases.
Definition: backend.hpp:19
SQL data row wrapper.
Definition: types.hpp:19
virtual ~Cursor()
empty
Definition: backend.hpp:26
virtual void commit() const
commit SQL transaction
Definition: backend.hpp:68
used to iterate results of SQL statement, creates objects of type T from retrieved records...
Definition: cursor.hpp:22
virtual void begin() const
begin SQL transaction, may or may not have an effect
Definition: backend.hpp:66
std::vector< Record > Records
shortcut
Definition: types.hpp:26
virtual string getInsertID() const
if backend supports this, new primary key of the last insert is returned
Definition: backend.hpp:64
virtual bool supportsSequences() const
return true if backend supports CREATE SEQUENCE - SQL-statements
Definition: backend.hpp:54
virtual ~Result()
empty
Definition: backend.hpp:39

SourceForge.net Logo