-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSQLValue.h
147 lines (124 loc) · 3.81 KB
/
CSQLValue.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright © NetworkDLS 2002, All rights reserved
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _CSQLVALUE_H
#define _CSQLVALUE_H
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <SQL.H>
#include <SQLExt.H>
typedef int(*ErrorHandler)(void* pCaller, const char* sSource, const char* sErrorMsg, const int iErrorNumber);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace SQLTypes {
enum SQLType {
BigInt = 65531,
Bit = 65529,
Decimal = 3,
Float = 6,
Int = 4,
Money = 3,
Numeric = 2,
Real = 7,
SmallInt = 5,
SmallMoney = 3,
TinyInt = 65530,
Binary = 65534, //Not (yet) supported.
Image = 65532,
VarBinary = 65533,
NText = 65526,
Text = 65535,
DateTime = 93,
SmallDateTime = 93,
TimeStamp = 65534,
Char = 1,
NChar = 65528,
NVarChar = 65527,
Variant = 65386,
UniqueIdentifier = 65525,
VarChar = 12
};
}
namespace CTypes {
enum CType {
Char = SQL_C_CHAR,
SShort = SQL_C_SSHORT,
UShort = SQL_C_USHORT,
SLong = SQL_C_SLONG,
ULong = SQL_C_ULONG,
Float = SQL_C_FLOAT,
Double = SQL_C_DOUBLE,
Bit = SQL_C_BIT,
STinyInt = SQL_C_STINYINT,
UTinyInt = SQL_C_UTINYINT,
SBigInt = SQL_C_SBIGINT,
UBigInt = SQL_C_UBIGINT,
Binary = SQL_C_BINARY,
BookMark = SQL_C_BOOKMARK,
VarBookMark = SQL_C_VARBOOKMARK,
Date = SQL_C_TYPE_DATE,
Time = SQL_C_TYPE_TIME,
TimeStamp = SQL_C_TYPE_TIMESTAMP,
Numeric = SQL_C_NUMERIC,
UniqueIdentifier = SQL_C_GUID
};
}
typedef struct _TAG_BINDINGDATA {
LPVOID Buffer;
SQLLEN Size;
bool IsNull;
} RECORDSET_SQLVALUE, * LPRECORDSET_SQLVALUE;
typedef struct _TAG_COLUMNINFO {
RECORDSET_SQLVALUE Data;
char Name[1024];
SQLTypes::SQLType DataType;
SQLULEN MaxSize;
int DecimalPlaces;
int Ordinal;
bool IsBound;
bool IsNullable;
} RECORDSET_COLUMNINFO, * LPRECORDSET_COLUMNINFO;
typedef struct _TAG_COLUMN {
RECORDSET_COLUMNINFO* Column;
int Count;
} RECORDSET_COLUMN, * LPRECORDSET_COLUMN;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CSQLValue {
private:
LPRECORDSET_COLUMNINFO lpCValue;
bool bcTrimCharData;
bool bcReplaceSingleQuotes;
bool bcThrowErrors;
bool bcIsValid;
SQLLEN RTrim(char* sData, SQLLEN iDataSz);
void ReplaceSingleQuotes(char* sData, SQLLEN iDataSz);
public:
void* pPublicData;
void Initialize(LPRECORDSET_COLUMNINFO lpColumnValue,
bool bTrimCharData, bool bReplaceSingleQuotes, bool bThrowErrors);
bool ThrowErrors();
bool ThrowErrors(bool bThrowErrors);
bool TrimCharData(bool bTrimCharData);
bool TrimCharData();
bool ReplaceSingleQuotes(bool bReplaceSingleQuotes);
bool ReplaceSingleQuotes();
bool IsValid();
bool IsNull();
SQLLEN Size();
char* ToString();
SQLLEN ToString(char* sOut, int iMaxSz);
signed int ToSignedInt();
unsigned int ToUnsignedInt();
double ToDouble();
float ToFloat();
unsigned __int64 ToUnsignedInt64();
signed __int64 ToSignedInt64();
bool ToBoolean();
unsigned short ToUnsignedShort();
signed short ToSignedShort();
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif