DCL 4.1
Loading...
Searching...
No Matches
SQLField.cpp File Reference
#include <dcl/Config.h>
#include <time.h>
#include <string.h>
#include <wctype.h>
#include <float.h>
#include <math.h>
#include <wchar.h>
#include <dcl/Object.h>
#include <dcl/Charset.h>
#include <dcl/SQL.h>

Go to the source code of this file.

Functions

__DCL_BEGIN_NAMESPACE IMPLEMENT_CLASSINFO (SQLField, Object) SQLField
 __DCL_ASSERT (n<=INT32_MAX)
buf release ()
 catch (Exception *e)
int __ABS (int n)
 switch (dataType())

Variables

void CharsetConvertException *size_t n = dataSize()
ByteBuffer * buf = ByteBuffer::create(n)
 try
buf __dataLength = n
 _r = UTF8Decoder::decode(buf->data(), buf->__dataLength)
String CharsetConvertException *size_t nDataSize = dataSize()
return result

Function Documentation

◆ __ABS()

int __ABS ( int n)
inline

Definition at line 866 of file SQLField.cpp.

867{
868 return n < 0 ? -n : n;
869}
void CharsetConvertException *size_t n
Definition SQLField.cpp:254

◆ __DCL_ASSERT()

__DCL_ASSERT ( n<= INT32_MAX)

◆ catch()

catch ( Exception * e)

Definition at line 264 of file SQLField.cpp.

264 {
265 buf->release();
266 throw e;
267 }
ByteBuffer * buf

◆ IMPLEMENT_CLASSINFO()

__DCL_BEGIN_NAMESPACE IMPLEMENT_CLASSINFO ( SQLField ,
Object  )

Definition at line 34 of file SQLField.cpp.

44{
45 __handle = NULL;
46 __query = NULL;
47}
#define NULL
Definition Config.h:340

◆ release()

buf release ( )

◆ switch()

switch ( dataType() )

Definition at line 943 of file SQLField.cpp.

943 {
944 case SQL::typeInteger: {
945 if (nDataSize <= sizeof(int32_t)) {
946 int32_t _r;
947 getValue(_r);
949 }
950 else {
951 int64_t _r;
952 getValue(_r);
954 }
955 break;
956 }
957 case SQL::typeUInteger: {
958 if (nDataSize <= sizeof(int32_t)) {
959 uint32_t _r;
960 getValue(_r);
962 }
963 else {
964 uint64_t _r;
965 getValue(_r);
967 }
968 break;
969 }
970 case SQL::typeFloat: {
971 if (nDataSize == sizeof(float)) {
972 float _r;
973 getValue(_r);
975 }
976 else {
977 double _r;
978 getValue(_r);
980 }
981 break;
982 }
983 case SQL::typeNumeric: {
984 getValue(result);
985 break;
986 }
987 case SQL::typeDate: {
989 getValue(_r);
990 result = String::format(
991 __T("%04d-%02d-%02d"),
992 _r.year,
993 _r.month,
994 _r.day
995 );
996 break;
997 }
998 case SQL::typeTime: {
1000 getValue(_r);
1001 result = String::format(
1002 __T("%02d:%02d:%02d.%03d"),
1003 _r.hour,
1004 _r.min,
1005 _r.sec,
1006 _r.frac / 1000000
1007 );
1008 break;
1009 }
1010 case SQL::typeTimeTz: {
1011 SQL::Time _r;
1012 getValue(_r);
1013 result = String::format(
1014 __T("%02d:%02d:%02d.%03d %+03d%02d"),
1015 _r.hour,
1016 _r.min,
1017 _r.sec,
1018 _r.frac / 1000000,
1019 _r.tzoff / 60,
1020 __ABS(_r.tzoff % 60)
1021 );
1022 break;
1023 }
1024 case SQL::typeTimeStamp: {
1026 getValue(_r);
1027 result = String::format(
1028 __T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),
1029 _r.year,
1030 _r.month,
1031 _r.day,
1032 _r.hour,
1033 _r.min,
1034 _r.sec,
1035 _r.frac / 1000000
1036 );
1037 break;
1038 }
1039 case SQL::typeTimeStampTz: {
1041 getValue(_r);
1042 result = String::format(
1043 __T("%04d-%02d-%02d %02d:%02d:%02d.%03d %+03d%02d"),
1044 _r.year,
1045 _r.month,
1046 _r.day,
1047 _r.hour,
1048 _r.min,
1049 _r.sec,
1050 _r.frac / 1000000,
1051 _r.tzoff / 60,
1052 __ABS(_r.tzoff % 60)
1053 );
1054 break;
1055 }
1056 case SQL::typeInterval: {
1058 getValue(_r);
1059 if (_r.years < 0 || _r.months < 0) {
1060 result = String::format(
1061 // 20,
1062 __T("-%d-%02d"),
1063 -_r.years,
1064 -_r.months
1065 );
1066 }
1067 else if (_r.years > 0 || _r.months > 0) {
1068 result = String::format(
1069 // 20,
1070 __T("+%d-%02d"),
1071 _r.years,
1072 _r.months
1073 );
1074 }
1075 else if (_r.days < 0
1076 || _r.hours < 0 || _r.mins < 0
1077 || _r.secs < 0 || _r.fracs < 0
1078 ) {
1079 result = String::format(
1080 // 30, // 24,
1081 __T("-%d %02d:%02d:%02d.%03d"),
1082 -(_r.days),
1083 -(_r.hours),
1084 -(_r.mins),
1085 -(_r.secs),
1086 -(_r.fracs / 1000000)
1087 );
1088 }
1089 else {
1090 result = String::format(
1091 // 30, // 24 = 1 + 10 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3
1092 __T("+%d %02d:%02d:%02d.%03d"),
1093 (_r.days),
1094 (_r.hours),
1095 (_r.mins),
1096 (_r.secs),
1097 (_r.fracs / 1000000)
1098 );
1099 }
1100 break;
1101 }
1102 case SQL::typeIntervalYm: {
1104 getValue(_r);
1105 if (_r.years < 0 || _r.months < 0) {
1106 result = String::format(
1107 // 20,
1108 __T("-%d-%02d"),
1109 -_r.years,
1110 -_r.months
1111 );
1112 }
1113 else {
1114 result = String::format(
1115 // 20,
1116 __T("+%d-%02d"),
1117 _r.years,
1118 _r.months
1119 );
1120 }
1121 break;
1122 }
1123 case SQL::typeIntervalDs: {
1125 getValue(_r);
1126 if (_r.days < 0
1127 || _r.hours < 0 || _r.mins < 0
1128 || _r.secs < 0 || _r.fracs < 0
1129 ) {
1130 result = String::format(
1131 // 30, // 24,
1132 __T("-%d %02d:%02d:%02d.%03d"),
1133 -(_r.days),
1134 -(_r.hours),
1135 -(_r.mins),
1136 -(_r.secs),
1137 -(_r.fracs / 1000000)
1138 );
1139 }
1140 else {
1141 result = String::format(
1142 // 30, // 24 = 1 + 10 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3
1143 __T("+%d %02d:%02d:%02d.%03d"),
1144 (_r.days),
1145 (_r.hours),
1146 (_r.mins),
1147 (_r.secs),
1148 (_r.fracs / 1000000)
1149 );
1150 }
1151 break;
1152 }
1153 case SQL::typeText :
1154 case SQL::typeLongText :
1155 case SQL::typeClob: {
1156 getValue(result);
1157 break;
1158 }
1159 case SQL::typeBinary :
1160 case SQL::typeLongBinary :
1161 case SQL::typeBlob: {
1162 ByteString _r;
1163 getValue(_r);
1164 result = String::tryString(_r, 20);
1165 break;
1166 }
1167 default: {
1168 __DCL_ASSERT(false);
1169 }
1170 }
#define __ABS(n)
Definition MyParam.cpp:143
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
_r
Definition SQLField.cpp:261
String CharsetConvertException *size_t nDataSize
Definition SQLField.cpp:942
return result
String toString() const
Definition Numeric.inl:147
String toString(unsigned _base=10) const
Definition Numeric.inl:87
String toString(unsigned _base=10) const
Definition Numeric.inl:111
@ typeBinary
Definition SQLCore.h:77
@ typeClob
Definition SQLCore.h:80
@ typeNumeric
Definition SQLCore.h:67
@ typeTime
Definition SQLCore.h:69
@ typeLongBinary
Definition SQLCore.h:79
@ typeUInteger
Definition SQLCore.h:65
@ typeTimeStamp
Definition SQLCore.h:71
@ typeBlob
Definition SQLCore.h:81
@ typeTimeStampTz
Definition SQLCore.h:72
@ typeInterval
Definition SQLCore.h:73
@ typeIntervalDs
Definition SQLCore.h:75
@ typeDate
Definition SQLCore.h:68
@ typeText
Definition SQLCore.h:76
@ typeTimeTz
Definition SQLCore.h:70
@ typeFloat
Definition SQLCore.h:66
@ typeInteger
Definition SQLCore.h:64
@ typeIntervalYm
Definition SQLCore.h:74
@ typeLongText
Definition SQLCore.h:78
String toString() const
Definition Numeric.inl:135
String toString(unsigned _base=10) const
Definition Numeric.inl:99
String toString(unsigned _base=10) const
Definition Numeric.inl:123

Variable Documentation

◆ __dataLength

buf __dataLength = n

Definition at line 260 of file SQLField.cpp.

◆ _r

_r = UTF8Decoder::decode(buf->data(), buf->__dataLength)

Definition at line 261 of file SQLField.cpp.

◆ buf

ByteBuffer* buf = ByteBuffer::create(n)

Definition at line 257 of file SQLField.cpp.

◆ n

void CharsetConvertException* size_t n = dataSize()

Definition at line 254 of file SQLField.cpp.

◆ nDataSize

String CharsetConvertException *size_t nDataSize = dataSize()

Definition at line 942 of file SQLField.cpp.

◆ result

return result

Definition at line 1171 of file SQLField.cpp.

◆ try

try
Initial value:
{
getData(buf->data(), &n, SQL::typeText)

Definition at line 258 of file SQLField.cpp.