-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathDbConnection.h
62 lines (43 loc) · 1.42 KB
/
DbConnection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __RPOSTGRES_PQ_CONNECTION__
#define __RPOSTGRES_PQ_CONNECTION__
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
class DbResult;
// convenience typedef for shared_ptr to DbConnection
class DbConnection;
typedef boost::shared_ptr<DbConnection> DbConnectionPtr;
// DbConnection ----------------------------------------------------------------
class DbConnection : boost::noncopyable {
PGconn* pConn_;
const DbResult* pCurrentResult_;
bool transacting_;
bool check_interrupts_;
public:
DbConnection(std::vector<std::string> keys, std::vector<std::string> values,
bool check_interrupts);
virtual ~DbConnection();
public:
void disconnect();
PGconn* conn();
void set_current_result(const DbResult* pResult);
void reset_current_result(const DbResult* pResult);
bool is_current_result(const DbResult* pResult);
bool has_query();
void copy_data(std::string sql, List df);
void copy_csv(std::string sql, std::string file);
void check_connection();
List info();
bool is_check_interrupts() const;
SEXP quote_string(const String& x);
SEXP quote_identifier(const String& x);
static SEXP get_null_string();
bool is_transacting() const;
void set_transacting(bool transacting);
void conn_stop(const char* msg);
static void conn_stop(PGconn* conn, const char* msg);
void cleanup_query();
static void finish_query(PGconn* pConn);
private:
void cancel_query();
};
#endif