-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConnection.h
More file actions
89 lines (67 loc) · 2 KB
/
Copy pathConnection.h
File metadata and controls
89 lines (67 loc) · 2 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright © 2002 CCP ehf.
/*
*************************************************************************
Connection.h
Project: EVE Server Database Access
Description:
Database connection object.
Dependencies:
Blue, Python
*************************************************************************
*/
#ifndef _CONNECTION_H_
#define _CONNECTION_H_
class Connection :
public IRoot
{
public:
EXPOSE_TO_BLUE();
// mSchema is a Tuple of two dicts. First dict has key as stored proc name and
// value is list of parameter columns info.
// Second dict has key as table name and value is list of columns info
PyObject* mSchema;
Connection();
~Connection();
PyObject* GetSchema(CSession& session, bool refresh = false);
private:
static PyObject *EnumerateProcParams(CSession &s);
};
TYPEDEF_BLUECLASS(Connection);
//A class for the limited proc parameter info that we need.
#include <atldbsch.h>
#include <set>
#include <string>
class CMiniProcParamsInfo
{
public:
CMiniProcParamsInfo(const CProcedureParameterInfo &other) :
m_szParameterName(StringStore(other.m_szParameterName)),
m_nOrdinalPosition(other.m_nOrdinalPosition),
m_nType(other.m_nType),
m_bIsNullable(!!other.m_bIsNullable),
m_nDataType(other.m_nDataType),
m_nMaxLength(other.m_nMaxLength),
m_nPrecision(other.m_nPrecision),
m_nScale(other.m_nScale) {}
const char *m_szParameterName;
ULONG m_nMaxLength;
USHORT m_nOrdinalPosition;
USHORT m_nType;
USHORT m_nDataType;
USHORT m_nPrecision;
SHORT m_nScale;
bool m_bIsNullable;
//use a static string store, to reuse the considerable amount of common parameter names
static const char *StringStore(const char *input){
typedef std::set<std::string> store_t;
static store_t store;
std::pair<store_t::iterator, bool> r = store.insert(input);
return r.first->c_str();
}
static void Destructor(PyObject *obj) {
CMiniProcParamsInfo *self = reinterpret_cast<CMiniProcParamsInfo*>(
PyCapsule_GetPointer(obj, "CMiniProcParamsInfo"));
delete self;
}
};
#endif