DCL 3.7.4
Loading...
Searching...
No Matches
IFXTypes_.h File Reference

Go to the source code of this file.

Macros

#define __DCL_IFX_TYPES_H__   20050205

Functions

__DCL_BEGIN_NAMESPACE size_t __get_dec_strlen (const dec_t *p)
void __decode_intrvl (const intrvl_t *_s, SQL::Interval *_r)
int __encode_intrvl (const SQL::Interval *_s, SQL::DataType _sqlType, intrvl_t *_r)
void __decode_dtime (const dtime_t *_s, SQL::TimeStamp *_r)
void __decode_dtime (const dtime_t *_s, SQL::Date *_r)
void __decode_dtime (const dtime_t *_s, SQL::Time *_r)
int __encode_dtime (const SQL::TimeStamp *_s, dtime_t *_r)
int __encode_dtime (const SQL::Date *_s, dtime_t *_r)
int __encode_dtime (const SQL::Time *_s, dtime_t *_r)

Macro Definition Documentation

◆ __DCL_IFX_TYPES_H__

#define __DCL_IFX_TYPES_H__   20050205

Definition at line 2 of file IFXTypes_.h.

Function Documentation

◆ __decode_dtime() [1/3]

void __decode_dtime ( const dtime_t * _s,
SQL::Date * _r )

Definition at line 313 of file IFXTypes.cpp.

314{
316 __decode_dtime(_s, &t);
317 _r->year = t.year;
318 _r->month = t.month;
319 _r->day = t.day;
320}
void __decode_dtime(const dtime_t *_s, SQL::TimeStamp *_r)
Definition IFXTypes.cpp:219
int16_t year
Definition SQLCore.h:96
uint8_t month
Definition SQLCore.h:97
uint8_t day
Definition SQLCore.h:98
uint8_t day
Definition SQLCore.h:114
int16_t year
Definition SQLCore.h:112
uint8_t month
Definition SQLCore.h:113

◆ __decode_dtime() [2/3]

void __decode_dtime ( const dtime_t * _s,
SQL::Time * _r )

Definition at line 322 of file IFXTypes.cpp.

323{
325 __decode_dtime(_s, &t);
326 _r->hour = t.hour;
327 _r->min = t.min;
328 _r->sec = t.sec;
329 _r->frac = t.frac;
330 _r->tzoff = INT16_MIN;
331}
#define INT16_MIN
Definition Config.h:284
uint8_t hour
Definition SQLCore.h:103
uint8_t sec
Definition SQLCore.h:105
uint32_t frac
Definition SQLCore.h:106
uint8_t min
Definition SQLCore.h:104
int16_t tzoff
Definition SQLCore.h:107
uint32_t frac
Definition SQLCore.h:118
uint8_t min
Definition SQLCore.h:116
uint8_t sec
Definition SQLCore.h:117
uint8_t hour
Definition SQLCore.h:115

◆ __decode_dtime() [3/3]

void __decode_dtime ( const dtime_t * _s,
SQL::TimeStamp * _r )

Definition at line 219 of file IFXTypes.cpp.

220{
221 /*
222 // 2025-12-10 dec_exp[-64] dec_ndgts[0] 인 경우가 발견되었다!
223 if (!(0 <= _s->dt_dec.dec_exp && _s->dt_dec.dec_exp <= 7)
224 || !(_s->dt_dec.dec_ndgts > 0)) {
225 __DCL_TRACE2(L"dec_exp[%d] dec_ndgts[%d]\n", _s->dt_dec.dec_exp, _s->dt_dec.dec_ndgts);
226 }
227 __DCL_ASSERT(0 <= _s->dt_dec.dec_exp && _s->dt_dec.dec_exp <= 7);
228 __DCL_ASSERT(_s->dt_dec.dec_ndgts > 0);
229 */
230
231 int nYear, nMonth, nDay, nHour, nMin, nSec, nFSec;
232 nYear = nMonth = nDay = nHour = nMin = nSec = nFSec = 0;
233
234 const char* p = _s->dt_dec.dec_dgts;
235 int ndgts = _s->dt_dec.dec_ndgts;
236 switch (TU_START(_s->dt_qual)) {
237 case TU_YEAR: {
238 if (_s->dt_dec.dec_exp >= 7) {
239 nYear = (*p++) * 100;
240 if (--ndgts == 0)
241 break;
242 }
243 if (_s->dt_dec.dec_exp >= 6) {
244 nYear += (*p++);
245 if (--ndgts == 0)
246 break;
247 }
248 }
249 case TU_MONTH: {
250 if (_s->dt_dec.dec_exp >= 5) {
251 nMonth = *p++;
252 if (--ndgts == 0)
253 break;
254 }
255 }
256 case TU_DAY: {
257 if (_s->dt_dec.dec_exp >= 4) {
258 nDay = *p++;
259 if (--ndgts == 0)
260 break;
261 }
262 }
263 case TU_HOUR: {
264 if (_s->dt_dec.dec_exp >= 3) {
265 nHour = *p++;
266 if (--ndgts == 0)
267 break;
268 }
269 }
270 case TU_MINUTE: {
271 if (_s->dt_dec.dec_exp >= 2) {
272 nMin = *p++;
273 if (--ndgts == 0)
274 break;
275 }
276 }
277 case TU_SECOND: {
278 if (_s->dt_dec.dec_exp >= 1) {
279 nSec = *p++;
280 if (--ndgts == 0)
281 break;
282 }
283 }
284 case TU_FRAC: {
285 // TU_F1, TU_F2
286 if (_s->dt_dec.dec_exp >= 0) {
287 nFSec = *p++ * 10000;
288 if (--ndgts == 0)
289 break;
290 }
291 // TU_F3, TU_F4
292 if (_s->dt_dec.dec_exp >= -1) {
293 nFSec += *p * 100;
294 if (--ndgts == 0)
295 break;
296 }
297 // TU_F5
298 if (_s->dt_dec.dec_exp >= -2)
299 nFSec += *p;
300 }
301 }
302
303 _r->year = nYear;
304 _r->month = nMonth;
305 _r->day = nDay;
306 _r->hour = nHour;
307 _r->min = nMin;
308 _r->sec = nSec;
309 _r->frac = nFSec * 1000;
310 _r->tzoff = INT16_MIN;
311}
int16_t tzoff
Definition SQLCore.h:119

◆ __decode_intrvl()

void __decode_intrvl ( const intrvl_t * _s,
SQL::Interval * _r )

Definition at line 107 of file IFXTypes.cpp.

108{
109 __DCL_ASSERT(_s->in_dec.dec_pos >= 0);
110
111 int nYears, nMonths, nDays, nHours, nMins, nSecs, nFSecs;
112 nYears = nMonths = nDays = nHours = nMins = nSecs = nFSecs = 0;
113
114 const char* p = _s->in_dec.dec_dgts;
115 int ndgts = _s->in_dec.dec_ndgts;
116
117 switch(TU_START(_s->in_qual)) {
118 case TU_YEAR: {
119 __GET_UNIT_VALUE(nYears, TU_YEAR, 6)
120 }
121 case TU_MONTH: {
122 __GET_UNIT_VALUE(nMonths, TU_MONTH, 5)
123 }
124 case TU_DAY: {
125 __GET_UNIT_VALUE(nDays, TU_DAY, 4)
126 }
127 case TU_HOUR: {
128 __GET_UNIT_VALUE(nHours, TU_HOUR, 3)
129 }
130 case TU_MINUTE: {
131 __GET_UNIT_VALUE(nMins, TU_MINUTE, 2)
132 }
133 case TU_SECOND: {
134 __GET_UNIT_VALUE(nSecs, TU_SECOND, 1)
135 }
136 case TU_FRAC: {
137 // TU_F1, TU_F2
138 if (_s->in_dec.dec_exp >= 0) {
139 nFSecs += *p++ * 10000;
140 ndgts--;
141 }
142 if (ndgts == 0)
143 break;
144 // TU_F3, TU_F4
145 if (_s->in_dec.dec_exp >= -1) {
146 nFSecs += *p * 100;
147 ndgts--;
148 }
149 if (ndgts == 0)
150 break;
151 // TU_F5
152 if (_s->in_dec.dec_exp >= -2)
153 nFSecs += *p;
154 }
155 }
156
157#define MIN_PER_DAY 1440
158#define SEC_PER_DAY 86400
159#define SEC_PER_HOUR 3600
160
161 switch(TU_START(_s->in_qual)) {
162 case TU_YEAR: {
163 break;
164 }
165 case TU_MONTH: {
166 nYears = nMonths / 12;
167 nMonths = nMonths % 12;
168 break;
169 }
170 case TU_DAY: {
171 break;
172 }
173 case TU_HOUR: {
174 nDays = nHours / 24;
175 nHours = nHours % 24;
176 break;
177 }
178 case TU_MINUTE: {
179 nDays = nMins / MIN_PER_DAY;
180 nHours = (nMins % MIN_PER_DAY) / 60;
181 nMins = nMins % 60;
182 break;
183 }
184 case TU_SECOND: {
185 nDays = nSecs / SEC_PER_DAY;
186 nHours = (nSecs % SEC_PER_DAY) / SEC_PER_HOUR;
187 nMins = (nSecs % SEC_PER_HOUR) / 60;
188 nSecs = nSecs % 60;
189 break;
190 }
191 case TU_FRAC: {
192 break;
193 }
194 default: {
195 __DCL_ASSERT(false);
196 }
197 }
198
199 if (_s->in_dec.dec_pos == 1) {
200 _r->years = nYears;
201 _r->months = nMonths;
202 _r->days = nDays;
203 _r->hours = nHours;
204 _r->mins = nMins;
205 _r->secs = nSecs;
206 _r->fracs = nFSecs * 1000;
207 }
208 else {
209 _r->years = -nYears;
210 _r->months = -nMonths;
211 _r->days = -nDays;
212 _r->hours = -nHours;
213 _r->mins = -nMins;
214 _r->secs = -nSecs;
215 _r->fracs = -(nFSecs * 1000);
216 }
217}
#define SEC_PER_HOUR
Definition DateTime.cpp:397
#define SEC_PER_DAY
Definition DateTime.cpp:395
#define __GET_UNIT_VALUE(TU_VAR, TU_NAME, TU_EXP)
Definition IFXTypes.cpp:87
#define MIN_PER_DAY
#define __DCL_ASSERT(expr)
Definition Object.h:394
int32_t years
Definition SQLCore.h:126
int32_t days
Definition SQLCore.h:128
int8_t hours
Definition SQLCore.h:129
int8_t mins
Definition SQLCore.h:130
int32_t fracs
Definition SQLCore.h:132
int8_t months
Definition SQLCore.h:127
int8_t secs
Definition SQLCore.h:131

◆ __encode_dtime() [1/3]

int __encode_dtime ( const SQL::Date * _s,
dtime_t * _r )

Definition at line 359 of file IFXTypes.cpp.

360{
361 char sz[30]; // YYYY-MM-DD 10
362 int n = snprintf(
363 sz,
364 sizeof(sz),
365 "%04d-%02d-%02d",
366 _s->year, _s->month, _s->day
367 );
368 if (n < 0)
369 return -1263;
370 else
371 sz[n] = '\0';
372
373 _r->dt_qual = TU_DTENCODE(TU_YEAR, TU_DAY);
374 return dtcvasc(sz, _r);
375}

◆ __encode_dtime() [2/3]

int __encode_dtime ( const SQL::Time * _s,
dtime_t * _r )

Definition at line 377 of file IFXTypes.cpp.

378{
379 char sz[30]; // HH:MM:SS.FFF 12
380 int n = snprintf(
381 sz,
382 sizeof(sz),
383 "%02u:%02u:%02u.%05u",
384 _s->hour, _s->min, _s->sec, _s->frac / 10000
385 );
386 if (n < 0)
387 return -1263;
388 else
389 sz[n] = '\0';
390
391 _r->dt_qual = TU_DTENCODE(TU_HOUR, TU_F5);
392 return dtcvasc(sz, _r);
393}

◆ __encode_dtime() [3/3]

int __encode_dtime ( const SQL::TimeStamp * _s,
dtime_t * _r )

Definition at line 337 of file IFXTypes.cpp.

338{
339 char sz[40]; // YYYY-MM-DD HH:MM:SS.FFF 23
340 int n = snprintf(
341 sz,
342 sizeof(sz),
343 "%04d-%02u-%02u %02u:%02u:%02u.%05u",
344 _s->year, _s->month, _s->day,
345 _s->hour, _s->min, _s->sec, _s->frac / 10000
346 );
347
348 // -1263 A field in a datetime or interval value
349 // is out of range or incorrect.
350 if (n < 0)
351 return -1263;
352 else
353 sz[n] = '\0';
354
355 _r->dt_qual = TU_DTENCODE(TU_YEAR, TU_F5);
356 return dtcvasc(sz, _r);
357}

◆ __encode_intrvl()

int __encode_intrvl ( const SQL::Interval * _s,
SQL::DataType _sqlType,
intrvl_t * _r )

Definition at line 400 of file IFXTypes.cpp.

405{
406 if (_sqlType == SQL::typeIntervalYm) {
407 int fn = 1;
408 int d = 10;
409 for( ; _s->years / d; fn++)
410 d *= 10;
411
412 const char* fmt = "%d-%d";
413 if (_s->years < 0 || _s->months < 0)
414 fmt = "-%d-%d";
415
416 char sz[30]; // YYYYYYYYY-MM
417 int n = snprintf(
418 sz,
419 sizeof(sz),
420 fmt,
421 __ABS(_s->years),
422 __ABS(_s->months)
423 );
424 if (n < 0)
425 return -1263;
426 else
427 sz[n] = '\0';
428
429 _r->in_qual = TU_IENCODE(fn, TU_YEAR, TU_MONTH);
430 return incvasc(sz, _r);
431 }
432 else {
434
435 int fn = 1; // FIRST LENGTH
436 int d = 10;
437 for( ; _s->days / d; fn++)
438 d *= 10;
439
440 const char* fmt = "%d %02d:%02d:%02d.%05d";
441 if (_s->days < 0 || _s->hours < 0 || _s->mins < 0
442 || _s->secs < 0 || _s->fracs < 0)
443 fmt = "-%d %02d:%02d:%02d.%05d";
444
445 char sz[40]; // DDDDDDDDDD HH:MM:SS.FFF + sign = 24
446 int n = snprintf(
447 sz,
448 sizeof(sz),
449 fmt,
450 __ABS(_s->days),
451 __ABS(_s->hours),
452 __ABS(_s->mins),
453 __ABS(_s->secs),
454 __ABS(_s->fracs / 10000)
455 );
456 if (n < 0)
457 return -1263;
458 else
459 sz[n] = '\0';
460
461 _r->in_qual = TU_IENCODE(fn, TU_DAY, TU_F5);
462 return incvasc(sz, _r);
463 }
464}
#define __ABS(n)
Definition MyParam.cpp:145
@ typeIntervalDs
Definition SQLCore.h:72
@ typeIntervalYm
Definition SQLCore.h:71

◆ __get_dec_strlen()

__DCL_BEGIN_NAMESPACE size_t __get_dec_strlen ( const dec_t * p)

Definition at line 26 of file IFXTypes.cpp.

27{
28 // assert(_p->dec_pos != -1);
29 // assert(_p->dec_ndgts >= 0);
30 __DCL_ASSERT(_p->dec_pos != -1);
31 __DCL_ASSERT(_p->dec_ndgts >= 0);
32
33 if (_p->dec_ndgts == 0)
34 return 1; // "0"
35
36 size_t n = _p->dec_pos == 0 ? 1 : 0;
37 int __n = _p->dec_exp - _p->dec_ndgts;
38 if (__n < 0) {
39 // 소숫점 아래 포함
40 if (_p->dec_exp > 0) {
41 // 소숫점 위 포함
42 // 소숫점 아래와 소숫점 위 모두 포함
43
44 n += _p->dec_ndgts * 2;
45
46 // 첫번째가 10보다 작으면
47 if (_p->dec_dgts[0] < 10)
48 n--;
49
50 // 소숫점아래 마지막이 0이면
51 if ((_p->dec_dgts[_p->dec_ndgts - 1] % 10) == 0)
52 n--;
53
54 n++; // 소숫점
55 }
56 else {
57 // 소숫점 아래만 있음
58 n += 2; // "0."
59 n += (-__n) * 2;
60
61 // 소숫점아래 마지막이 0이면
62 if ((_p->dec_dgts[_p->dec_ndgts - 1] % 10) == 0)
63 n--;
64 }
65 }
66 else {
67 // 소숫점을 포함하지 않음
68
69 if (__n > 0)
70 n += (_p->dec_ndgts + __n) * 2;
71 else
72 n += _p->dec_ndgts * 2;
73
74 // 첫번째가 10보다 작으면
75 if (_p->dec_dgts[0] < 10)
76 n--;
77
78 // dectoasc 에서 소숫점 없는 수는 ".0"을 추가함
79 n += 2;
80 }
81
82 return n;
83}