This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathcdbcursor.cpp
More file actions
99 lines (84 loc) · 2.79 KB
/
cdbcursor.cpp
File metadata and controls
99 lines (84 loc) · 2.79 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
90
91
92
93
94
95
96
97
98
99
/* Copyright (C) 2003-2015 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
#include "dbdrivercommon.cpp"
//DBCURSOR STUFF
char *CDBCursor::getErrorMessage() {return connection->getErrorMessage();}
Bool CDBCursor::IsError() {return connection->IsError();}
unsigned int CDBCursor::getFieldLength(unsigned int fieldnum)
{
//offset by zero
fieldnum--;
//check that field is in range
if (fieldnum >= fieldCount) return NULL;
return (unsigned int)fields[fieldnum]->maxlength;
}
/*getFieldName - get name of a field by field number (1 based)
Input: fieldnum - number of field to get name of
Output: name of field, NULL on error*/
char *CDBCursor::getFieldName(unsigned int fieldnum)
{
//offset by zero
fieldnum--;
//check that field is in range
if (fieldnum >= fieldCount) return NULL;
return fields[fieldnum]->fieldName;
}
DBFieldType CDBCursor::getFieldType(unsigned int fieldnum)
{
fieldnum--;
if (fieldnum >= fieldCount) return FT_NULL;
return fields[fieldnum]->fieldType;
}
/*getFieldDataBinary - get data of a column
Input:
fieldnum - number of field to get data from
fdlength - will recieve length of data
Output: pointer to fields data, NULL on error*/
char *CDBCursor::getFieldDataBinary(unsigned int fieldnum,unsigned int &fdlength)
{
fieldnum--;
if (fieldnum >= fieldCount) return NULL;
//fill in data size
fdlength = fields[fieldnum]->dataSize;
//return pointer to data..if NULL return pointer to blank value
return fields[fieldnum]->isNull == True? (char *)DBNullValue: fields[fieldnum]->data;
}
/*getFieldDataString - Return the stored data as a string.
Input:
fieldnum - number of field to get name of
Output: copy of fields data as null terminated string,
NULL on error*/
char *CDBCursor::getFieldDataString(unsigned int fieldnum)
{
unsigned int fdlength = 0;
char *fdata = getFieldDataBinary(fieldnum, fdlength);
if (fdata == NULL) return NULL;
//allocate space for copy of data plus the trailing null
if (fdata != DBNullValue)
fdata[fdlength] = '\0';
return fdata;
}
Bool CDBCursor::getFieldIsNull(unsigned int fieldnum)
{
fieldnum--;
if (fieldnum >= fieldCount) return False;
return fields[fieldnum]->isNull;
}
void CDBCursor::FreeFields()
{
if (fields){
for (unsigned int i = 0; i < fieldCount; i++)
delete fields[i];
delete fields;
}
fields = NULL;
}