DCL 3.7.4
Loading...
Searching...
No Matches
PqTypes.h
Go to the documentation of this file.
1#ifndef __DCL_PQ_TYPES_H__
2#define __DCL_PQ_TYPES_H__ 20260106
3
4#ifdef __WINNT__
5 #define bswap_16(_x) _byteswap_ushort(_x)
6 #define bswap_32(_x) _byteswap_ulong(_x)
7 #define bswap_64(_x) _byteswap_uint64(_x)
8#elif defined(__APPLE__)
9 #define bswap_16(_x) OSSwapInt16(_x)
10 #define bswap_32(_x) OSSwapInt32(_x)
11 #define bswap_64(_x) OSSwapInt64(_x)
12#else
13 #include <byteswap.h> // bswap
14#endif
15
16__DCL_BEGIN_NAMESPACE
17
18inline uint16_t __htons(uint16_t _x)
19{
20#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
21 return bswap_16(_x);
22#else
23 return _x
24#endif
25}
26
27inline uint32_t __htonl(uint32_t _x)
28{
29#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
30 return bswap_32(_x);
31#else
32 return _x
33#endif
34}
35
36inline uint64_t __htonll(uint64_t _x)
37{
38#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
39 return bswap_64(_x);
40#else
41 return _x
42#endif
43}
44
45#define __ntohs(_x) __htons(_x)
46#define __ntohl(_x) __htonl(_x)
47#define __ntohll(_x) __htonll(_x)
48
49inline void __copy__(void* _dst, const void* _src, size_t _size)
50{
51 unsigned char* dst = (unsigned char*)_dst;
52 const unsigned char* src = (unsigned char*)_src;
53 while (_size--) {
54 *dst++ = *src++;
55 }
56}
57
58inline void __rcopy__(void* _dst, const void* _src, size_t _size)
59{
60 unsigned char* dst = (unsigned char*)_dst;
61 const unsigned char* src = (unsigned char*)_src + _size;
62 while (_size--) {
63 *dst++ = *(--src);
64 }
65}
66
67inline uint32_t __htonf(float _x)
68{
69 uint32_t x;
70#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
71 __rcopy__(&x, &_x, sizeof(_x));
72#else
73 __copy__(&x, &_x, sizeof(_x));
74#endif
75 return x;
76}
77
78inline uint64_t __htond(double _x)
79{
80 uint64_t x;
81#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
82 __rcopy__(&x, &_x, sizeof(_x));
83#else
84 __copy__(&x, &_x, sizeof(_x));
85#endif
86 return x;
87}
88
89inline float __ntohf(uint32_t _x)
90{
91 float x;
92#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
93 __rcopy__(&x, &_x, sizeof(_x));
94#else
95 __copy__(&x, &_x, sizeof(_x));
96#endif
97 return x;
98}
99
100inline double __ntohd(uint64_t _x)
101{
102 double x;
103#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
104 __rcopy__(&x, &_x, sizeof(_x));
105#else
106 __copy__(&x, &_x, sizeof(_x));
107#endif
108 return x;
109}
110
111inline bool __is_hex_escaped(const char* _src)
112{
113 return *_src++ == '\\' && (*_src == 'x' || *_src == 'X');
114}
115
116// return false는 오류 데이터가 포함되었음을 의미한다.
117// 오류 데이터는 무시된다. _dstend는 unescape된 길이를 지시한다.
118bool __unescape_hex(
119 const char* _src, const char*& _srcend,
120 char* _dst, char*& _dstend
121);
122
123// return false는 오류 데이터가 포함되었음을 의미한다.
124// 오류 데이터는 무시된다. _dstend는 unescape된 길이를 지시한다.
125bool __unescape_oct(
126 const char* _src, const char*& _srcend,
127 char* _dst, char*& _dstend
128);
129
130// _s는 '\0' 종결문자열 이어야 한다. _endptr는 _s의 최종 위치를 반환한다.
131// return false는 오류데이터를 포함하고 있고, _r 값은 사용할 수 없다.
133 const char* _s, const char** _endptr,
135);
136
137// _s는 '\0' 종결문자열 이어야 한다. _endptr는 _s의 최종 위치를 반환한다.
138// return false는 오류데이터를 포함하고 있고, _r 값은 사용할 수 없다
140 const char* _s, const char** _endptr,
141 SQL::Interval& _r
142);
143
144const wchar_t* __dataTypeName(Oid _oid);
145
146__DCL_END_NAMESPACE
147
148#endif // __DCL_PQ_TYPES_H__
uint64_t __htond(double _x)
Definition PqTypes.h:78
void __copy__(void *_dst, const void *_src, size_t _size)
Definition PqTypes.h:49
bool __is_hex_escaped(const char *_src)
Definition PqTypes.h:111
bool __unescape_hex(const char *_src, const char *&_srcend, char *_dst, char *&_dstend)
Definition PqTypes.cpp:59
bool __unescape_oct(const char *_src, const char *&_srcend, char *_dst, char *&_dstend)
Definition PqTypes.cpp:108
bool __decode_timestamp_iso(const char *_s, const char **_endptr, SQL::TimeStamp &_r)
Definition PqTypes.cpp:176
uint32_t __htonf(float _x)
Definition PqTypes.h:67
float __ntohf(uint32_t _x)
Definition PqTypes.h:89
__DCL_BEGIN_NAMESPACE uint16_t __htons(uint16_t _x)
Definition PqTypes.h:18
uint64_t __htonll(uint64_t _x)
Definition PqTypes.h:36
void __rcopy__(void *_dst, const void *_src, size_t _size)
Definition PqTypes.h:58
uint32_t __htonl(uint32_t _x)
Definition PqTypes.h:27
bool __decode_interval_iso(const char *_s, const char **_endptr, SQL::Interval &_r)
Definition PqTypes.cpp:308
const wchar_t * __dataTypeName(Oid _oid)
Definition PqTypes.cpp:418
double __ntohd(uint64_t _x)
Definition PqTypes.h:100