-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathconnection.h
51 lines (46 loc) · 1.63 KB
/
connection.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
// Copyright 2011 Mariano Iglesias <[email protected]>
#ifndef CONNECTION_H_
#define CONNECTION_H_
#include <pthread.h>
#include <stdint.h>
#include <cstring>
#include <string>
#include "./exception.h"
#include "./result.h"
namespace node_db {
class Connection {
public:
const char quoteString;
Connection();
virtual ~Connection();
virtual std::string getHostname() const;
virtual void setHostname(const std::string& hostname);
virtual std::string getUser() const;
virtual void setUser(const std::string& user);
virtual std::string getPassword() const;
virtual void setPassword(const std::string& password);
virtual std::string getDatabase() const;
virtual void setDatabase(const std::string& database);
virtual uint32_t getPort() const;
virtual void setPort(uint32_t port);
virtual bool isAlive(bool ping = false);
virtual std::string escapeName(const std::string& string) const throw(Exception&);
virtual void open() throw(Exception&) = 0;
virtual void close() = 0;
virtual std::string escape(const std::string& string) const throw(Exception&) = 0;
virtual std::string version() const = 0;
virtual Result* query(const std::string& query) const throw(Exception&) = 0;
virtual void lock();
virtual void unlock();
protected:
std::string hostname;
std::string user;
std::string password;
std::string database;
uint32_t port;
bool alive;
char quoteName;
pthread_mutex_t connectionLock;
};
}
#endif // CONNECTION_H_