DCL 4.0
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 861 of file SQLField.cpp.

862{
863 return n < 0 ? -n : n;
864}
void CharsetConvertException *size_t n
Definition SQLField.cpp:253

◆ __DCL_ASSERT()

__DCL_ASSERT ( n<= INT32_MAX)

◆ catch()

catch ( Exception * e)

Definition at line 263 of file SQLField.cpp.

263 {
264 buf->release();
265 throw e;
266 }
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 938 of file SQLField.cpp.

938 {
939 case SQL::typeInteger: {
940 if (nDataSize <= sizeof(int32_t)) {
941 int32_t _r;
942 getValue(_r);
944 }
945 else {
946 int64_t _r;
947 getValue(_r);
949 }
950 break;
951 }
952 case SQL::typeUInteger: {
953 if (nDataSize <= sizeof(int32_t)) {
954 uint32_t _r;
955 getValue(_r);
957 }
958 else {
959 uint64_t _r;
960 getValue(_r);
962 }
963 break;
964 }
965 case SQL::typeFloat: {
966 if (nDataSize == sizeof(float)) {
967 float _r;
968 getValue(_r);
970 }
971 else {
972 double _r;
973 getValue(_r);
975 }
976 break;
977 }
978 case SQL::typeNumeric: {
979 getValue(result);
980 break;
981 }
982 case SQL::typeDate: {
984 getValue(_r);
985 result = String::format(
986 __T("%04d-%02d-%02d"),
987 _r.nYear,
988 _r.nMonth,
989 _r.nDay
990 );
991 break;
992 }
993 case SQL::typeTime: {
995 getValue(_r);
996 result = String::format(
997 __T("%02d:%02d:%02d.%03d"),
998 _r.nHour,
999 _r.nMin,
1000 _r.nSec,
1001 _r.nFrac / 1000000
1002 );
1003 break;
1004 }
1005 case SQL::typeTimeStamp: {
1007 getValue(_r);
1008 result = String::format(
1009 __T("%04d-%02d-%02d %02d:%02d:%02d.%03d"),
1010 _r.nYear,
1011 _r.nMonth,
1012 _r.nDay,
1013 _r.nHour,
1014 _r.nMin,
1015 _r.nSec,
1016 _r.nFrac / 1000000
1017 );
1018 break;
1019 }
1020 case SQL::typeTimeStampTz: {
1022 getValue(_r);
1023 result = String::format(
1024 __T("%04d-%02d-%02d %02d:%02d:%02d.%03d %+03d%02d"),
1025 _r.nYear,
1026 _r.nMonth,
1027 _r.nDay,
1028 _r.nHour,
1029 _r.nMin,
1030 _r.nSec,
1031 _r.nFrac / 1000000,
1032 _r.nTzMin / 60,
1033 __ABS(_r.nTzMin % 60)
1034 );
1035 break;
1036 }
1037 case SQL::typeIntervalYm: {
1039 getValue(_r);
1040 if (_r.nYears < 0 || _r.nMonths < 0) {
1041 result = String::format(
1042 // 20,
1043 __T("-%d-%02d"),
1044 -_r.nYears,
1045 -_r.nMonths
1046 );
1047 }
1048 else {
1049 result = String::format(
1050 // 20,
1051 __T("+%d-%02d"),
1052 _r.nYears,
1053 _r.nMonths
1054 );
1055 }
1056 break;
1057 }
1058 case SQL::typeIntervalDs: {
1060 getValue(_r);
1061 if (_r.nDays < 0
1062 || _r.nHours < 0 || _r.nMins < 0
1063 || _r.nSecs < 0 || _r.nFracs < 0
1064 ) {
1065 result = String::format(
1066 // 30, // 24,
1067 __T("-%d %02d:%02d:%02d.%03d"),
1068 -(_r.nDays),
1069 -(_r.nHours),
1070 -(_r.nMins),
1071 -(_r.nSecs),
1072 -(_r.nFracs / 1000000)
1073 );
1074 }
1075 else {
1076 result = String::format(
1077 // 30, // 24 = 1 + 10 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3
1078 __T("+%d %02d:%02d:%02d.%03d"),
1079 (_r.nDays),
1080 (_r.nHours),
1081 (_r.nMins),
1082 (_r.nSecs),
1083 (_r.nFracs / 1000000)
1084 );
1085 }
1086 break;
1087 }
1088 case SQL::typeInterval: {
1090 getValue(_r);
1091 if (_r.nYears < 0 || _r.nMonths < 0) {
1092 result = String::format(
1093 // 20,
1094 __T("-%d-%02d"),
1095 -_r.nYears,
1096 -_r.nMonths
1097 );
1098 }
1099 else if (_r.nYears > 0 || _r.nMonths > 0) {
1100 result = String::format(
1101 // 20,
1102 __T("+%d-%02d"),
1103 _r.nYears,
1104 _r.nMonths
1105 );
1106 }
1107 else if (_r.nDays < 0
1108 || _r.nHours < 0 || _r.nMins < 0
1109 || _r.nSecs < 0 || _r.nFracs < 0
1110 ) {
1111 result = String::format(
1112 // 30, // 24,
1113 __T("-%d %02d:%02d:%02d.%03d"),
1114 -(_r.nDays),
1115 -(_r.nHours),
1116 -(_r.nMins),
1117 -(_r.nSecs),
1118 -(_r.nFracs / 1000000)
1119 );
1120 }
1121 else {
1122 result = String::format(
1123 // 30, // 24 = 1 + 10 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3
1124 __T("+%d %02d:%02d:%02d.%03d"),
1125 (_r.nDays),
1126 (_r.nHours),
1127 (_r.nMins),
1128 (_r.nSecs),
1129 (_r.nFracs / 1000000)
1130 );
1131 }
1132 break;
1133 }
1134 case SQL::typeText :
1135 case SQL::typeLongText :
1136 case SQL::typeClob: {
1137 getValue(result);
1138 break;
1139 }
1140 case SQL::typeBinary :
1141 case SQL::typeLongBinary :
1142 case SQL::typeBlob: {
1143 ByteString _r;
1144 getValue(_r);
1145 result = String::tryString(_r, 20);
1146 break;
1147 }
1148 default: {
1149 __DCL_ASSERT(false);
1150 }
1151 }
#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:260
String CharsetConvertException *size_t nDataSize
Definition SQLField.cpp:937
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:76
@ typeClob
Definition SQLCore.h:79
@ typeNumeric
Definition SQLCore.h:67
@ typeTime
Definition SQLCore.h:69
@ typeLongBinary
Definition SQLCore.h:78
@ typeUInteger
Definition SQLCore.h:65
@ typeTimeStamp
Definition SQLCore.h:70
@ typeBlob
Definition SQLCore.h:80
@ typeTimeStampTz
Definition SQLCore.h:71
@ typeInterval
Definition SQLCore.h:72
@ typeIntervalDs
Definition SQLCore.h:74
@ typeDate
Definition SQLCore.h:68
@ typeText
Definition SQLCore.h:75
@ typeFloat
Definition SQLCore.h:66
@ typeInteger
Definition SQLCore.h:64
@ typeIntervalYm
Definition SQLCore.h:73
@ typeLongText
Definition SQLCore.h:77
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 259 of file SQLField.cpp.

◆ _r

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

Definition at line 260 of file SQLField.cpp.

◆ buf

ByteBuffer* buf = ByteBuffer::create(n)

Definition at line 256 of file SQLField.cpp.

◆ n

void CharsetConvertException* size_t n = dataSize()

Definition at line 253 of file SQLField.cpp.

◆ nDataSize

String CharsetConvertException *size_t nDataSize = dataSize()

Definition at line 937 of file SQLField.cpp.

◆ result

return result

Definition at line 1152 of file SQLField.cpp.

◆ try

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

Definition at line 257 of file SQLField.cpp.