-
Notifications
You must be signed in to change notification settings - Fork 2
/
postgresconfig.h
66 lines (53 loc) · 1.4 KB
/
postgresconfig.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
63
64
65
66
#ifndef _POSTGRESCONFIG_H_
#define _POSTGRESCONFIG_H_
#include "qtlconfig.h"
#include <qtl_postgres.hpp>
struct pgtype
{
Oid _id;
std::string _name;
char category;
Oid _arrayid;
};
struct pgfield
{
std::string _name;
std::string _type;
};
struct pgclass
{
Oid _id;
std::string _name;
std::vector<pgfield> _fields;
};
struct postgres_connection : public connection_config
{
std::string _host;
uint16_t _port;
std::string _user;
std::string _password;
std::string _schema;
qtl::postgres::database _db;
postgres_connection() : _port(5432) { }
virtual bool open() override;
std::string template_file() const override;
virtual void scan_tables(std::vector<std::unique_ptr<qtlstmt>>& queries) override;
virtual std::string escape_token(const std::string& text) override;
std::string find_type(Oid typid) const;
const pgtype* find_type(const std::string& name) const;
std::string convert_type(Oid typid, uint32_t length);
const pgclass* find_class(const std::string& name) const;
public:
std::vector<pgtype> _types;
std::vector<pgclass> _classes;
};
struct postgres_stmt : public qtlstmt
{
explicit postgres_stmt(postgres_connection& connection) : _connection(connection) { }
virtual void init_fields() override;
virtual void init_primaries() override;
private:
postgres_connection& _connection;
std::string convert_type(const std::string& type_name, uint32_t length);
};
#endif //_POSTGRESCONFIG_H_