transactd 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/BUILD_UNIX-JA +174 -0
  3. data/BUILD_WIN-JA +256 -0
  4. data/CMakeLists.txt +96 -0
  5. data/COPYING +339 -0
  6. data/README +406 -0
  7. data/README-JA +424 -0
  8. data/bin/common/tdclc_32_1_0.dll +0 -0
  9. data/bin/common/tdclc_64_1_0.dll +0 -0
  10. data/build/common/check_for_link_iconv.cmake +73 -0
  11. data/build/common/copyifgreater.cmd +30 -0
  12. data/build/common/copyifgreater.js +290 -0
  13. data/build/common/get_boost_libs.cmake +106 -0
  14. data/build/common/get_ruby_path.cmake +115 -0
  15. data/build/common/options.cmake +127 -0
  16. data/build/common/smart_install.cmake +263 -0
  17. data/build/common/system.cmake +122 -0
  18. data/build/common/transactd.rc.in +52 -0
  19. data/build/common/transactd_cl_common.cmake +101 -0
  20. data/build/common/transactd_cl_output.cmake +93 -0
  21. data/build/common/transactd_common.cmake +237 -0
  22. data/build/common/transactd_required.cmake +28 -0
  23. data/build/swig/ruby/generate.cmake.in +35 -0
  24. data/build/swig/ruby/generate.cmd.in +19 -0
  25. data/build/swig/ruby/ruby.swg +101 -0
  26. data/build/swig/tdcl.i +188 -0
  27. data/build/tdclc/BUILDNUMBER.txt +1 -0
  28. data/build/tdclc/CMakeLists.txt +170 -0
  29. data/build/tdclc/tdclc_32.cbproj +181 -0
  30. data/build/tdclc/tdclc_64.cbproj +205 -0
  31. data/build/tdclcpp/BUILDNUMBER.txt +1 -0
  32. data/build/tdclcpp/CMakeLists.txt +142 -0
  33. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
  34. data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
  35. data/build/tdclrb/BUILDNUMBER.txt +1 -0
  36. data/build/tdclrb/CMakeLists.txt +258 -0
  37. data/build/tdclrb/GEM_VERSION +3 -0
  38. data/build/tdclrb/bldgem/extconf.rb +123 -0
  39. data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
  40. data/build/tdclrb/gem/Makefile.win32-VS +65 -0
  41. data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
  42. data/build/tdclrb/gem/detect.rb +31 -0
  43. data/build/tdclrb/gem/helper.rb +113 -0
  44. data/build/tdclrb/gem/transactd.rb +22 -0
  45. data/build/tdclrb/gem_output.cmake +44 -0
  46. data/source/bzs/db/IBlobBuffer.h +51 -0
  47. data/source/bzs/db/blobBuffer.h +177 -0
  48. data/source/bzs/db/blobStructs.h +85 -0
  49. data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
  50. data/source/bzs/db/engine/mysql/bookmark.h +195 -0
  51. data/source/bzs/db/engine/mysql/database.cpp +1882 -0
  52. data/source/bzs/db/engine/mysql/database.h +465 -0
  53. data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
  54. data/source/bzs/db/engine/mysql/dbManager.h +143 -0
  55. data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
  56. data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
  57. data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
  58. data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
  59. data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
  60. data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
  61. data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
  62. data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
  63. data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
  64. data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
  65. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
  66. data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
  67. data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
  68. data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
  69. data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
  70. data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
  71. data/source/bzs/db/protocol/tdap/client/client.h +292 -0
  72. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
  73. data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
  74. data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
  75. data/source/bzs/db/protocol/tdap/client/database.h +118 -0
  76. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
  77. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
  78. data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
  79. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
  80. data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
  81. data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
  82. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
  83. data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
  84. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
  85. data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
  86. data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
  87. data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
  88. data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
  89. data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
  90. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
  91. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
  92. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
  93. data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
  94. data/source/bzs/db/protocol/tdap/client/request.h +198 -0
  95. data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
  96. data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
  97. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
  98. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
  99. data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
  100. data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
  101. data/source/bzs/db/protocol/tdap/client/table.h +221 -0
  102. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
  103. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
  104. data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
  105. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
  106. data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
  107. data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
  108. data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
  109. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
  110. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
  111. data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
  112. data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
  113. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
  114. data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
  115. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
  116. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
  117. data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
  118. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
  119. data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
  120. data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
  121. data/source/bzs/db/transactd/appBuilderImple.h +55 -0
  122. data/source/bzs/db/transactd/appModule.cpp +183 -0
  123. data/source/bzs/db/transactd/appModule.h +80 -0
  124. data/source/bzs/db/transactd/connManager.cpp +201 -0
  125. data/source/bzs/db/transactd/connManager.h +60 -0
  126. data/source/bzs/db/transactd/connectionRecord.h +69 -0
  127. data/source/bzs/db/transactd/transactd.cpp +325 -0
  128. data/source/bzs/env/compiler.h +135 -0
  129. data/source/bzs/env/crosscompile.cpp +130 -0
  130. data/source/bzs/env/crosscompile.h +150 -0
  131. data/source/bzs/env/fileopen.h +36 -0
  132. data/source/bzs/env/mbcswchrLinux.cpp +40 -0
  133. data/source/bzs/env/mbcswchrLinux.h +88 -0
  134. data/source/bzs/env/tstring.h +183 -0
  135. data/source/bzs/example/changeSchema.cpp +117 -0
  136. data/source/bzs/example/changeSchema_c.cpp +78 -0
  137. data/source/bzs/example/connection_pool_c.cpp +171 -0
  138. data/source/bzs/example/createDatabase.cpp +305 -0
  139. data/source/bzs/example/createDatabase_c.cpp +202 -0
  140. data/source/bzs/example/deleteRecords.cpp +87 -0
  141. data/source/bzs/example/deleteRecords_c.cpp +57 -0
  142. data/source/bzs/example/dropDatabase.cpp +59 -0
  143. data/source/bzs/example/dropDatabase_c.cpp +34 -0
  144. data/source/bzs/example/insertRecords.cpp +212 -0
  145. data/source/bzs/example/insertRecords_c.cpp +153 -0
  146. data/source/bzs/example/readRecords.cpp +141 -0
  147. data/source/bzs/example/readRecords_c.cpp +107 -0
  148. data/source/bzs/example/updateRecords.cpp +99 -0
  149. data/source/bzs/example/updateRecords_c.cpp +71 -0
  150. data/source/bzs/example/update_with_transaction.cpp +104 -0
  151. data/source/bzs/example/update_with_transaction_c.cpp +80 -0
  152. data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
  153. data/source/bzs/netsvc/client/tcpClient.h +489 -0
  154. data/source/bzs/netsvc/server/IAppModule.h +94 -0
  155. data/source/bzs/netsvc/server/iserver.h +65 -0
  156. data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
  157. data/source/bzs/netsvc/server/serverCpt.h +88 -0
  158. data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
  159. data/source/bzs/netsvc/server/serverPipe.h +96 -0
  160. data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
  161. data/source/bzs/netsvc/server/serverTpool.h +84 -0
  162. data/source/bzs/rtl/benchmark.cpp +96 -0
  163. data/source/bzs/rtl/benchmark.h +65 -0
  164. data/source/bzs/rtl/datetime.cpp +375 -0
  165. data/source/bzs/rtl/datetime.h +53 -0
  166. data/source/bzs/rtl/debuglog.cpp +106 -0
  167. data/source/bzs/rtl/debuglog.h +97 -0
  168. data/source/bzs/rtl/exception.h +116 -0
  169. data/source/bzs/rtl/stl_uty.cpp +35 -0
  170. data/source/bzs/rtl/stl_uty.h +29 -0
  171. data/source/bzs/rtl/stringBuffers.cpp +101 -0
  172. data/source/bzs/rtl/stringBuffers.h +58 -0
  173. data/source/bzs/rtl/strtrim.cpp +135 -0
  174. data/source/bzs/rtl/strtrim.h +46 -0
  175. data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
  176. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
  177. data/source/bzs/test/tdclrb/prepare.rb +226 -0
  178. data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
  179. data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
  180. data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
  181. data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
  182. data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
  183. data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
  184. data/source/global/tdclatl/Database.cpp +503 -0
  185. data/source/global/tdclatl/Database.h +139 -0
  186. data/source/global/tdclatl/DbDef.cpp +242 -0
  187. data/source/global/tdclatl/DbDef.h +79 -0
  188. data/source/global/tdclatl/Field.cpp +92 -0
  189. data/source/global/tdclatl/Field.h +59 -0
  190. data/source/global/tdclatl/FieldDef.cpp +238 -0
  191. data/source/global/tdclatl/FieldDef.h +87 -0
  192. data/source/global/tdclatl/Flags.cpp +111 -0
  193. data/source/global/tdclatl/Flags.h +55 -0
  194. data/source/global/tdclatl/KeyDef.cpp +51 -0
  195. data/source/global/tdclatl/KeyDef.h +55 -0
  196. data/source/global/tdclatl/KeySegment.cpp +55 -0
  197. data/source/global/tdclatl/Table.cpp +600 -0
  198. data/source/global/tdclatl/Table.h +144 -0
  199. data/source/global/tdclatl/TableDef.cpp +291 -0
  200. data/source/global/tdclatl/TableDef.h +86 -0
  201. data/source/global/tdclatl/TdVersion.cpp +74 -0
  202. data/source/global/tdclatl/TdVersion.h +54 -0
  203. data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
  204. data/source/global/tdclatl/dllmain.cpp +30 -0
  205. data/source/global/tdclatl/dllmain.h +27 -0
  206. data/source/global/tdclatl/keySegment.h +57 -0
  207. data/source/global/tdclatl/resource.h +0 -0
  208. data/source/global/tdclatl/stdafx.cpp +2 -0
  209. data/source/global/tdclatl/stdafx.h +25 -0
  210. data/source/global/tdclatl/targetver.h +4 -0
  211. data/source/global/tdclatl/tdclatl.cpp +68 -0
  212. data/source/global/tdclatl/tdclatl.def +10 -0
  213. data/source/global/tdclatl/tdclatl.idl +1035 -0
  214. data/source/linux/charsetConvert.h +112 -0
  215. data/source/linux/linuxTypes.h +33 -0
  216. data/source/linux/tchar.h +428 -0
  217. data/transactd.gemspec +97 -0
  218. metadata +267 -0
@@ -0,0 +1,179 @@
1
+ #ifndef trdboostapiInternalH
2
+ #define trdboostapiInternalH
3
+ /*=================================================================
4
+ Copyright (C) 2013 BizStation Corp All rights reserved.
5
+
6
+ This program is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU General Public License
8
+ as published by the Free Software Foundation; either version 2
9
+ of the License, or (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
+ 02111-1307, USA.
20
+ =================================================================*/
21
+ #include "table.h"
22
+ #include "database.h"
23
+ #include "dbDef.h"
24
+ #include <boost/bind.hpp>
25
+ #include <boost/function.hpp>
26
+ #include <boost/type_traits.hpp>
27
+
28
+ namespace bzs
29
+ {
30
+ namespace db
31
+ {
32
+ namespace protocol
33
+ {
34
+ namespace tdap
35
+ {
36
+ namespace client
37
+ {
38
+
39
+
40
+
41
+ template<int N>
42
+ struct placeholder
43
+ {
44
+ static boost::arg<N>& get()
45
+ {
46
+ static boost::arg<N>result;
47
+ return result;
48
+ }
49
+ };
50
+
51
+ static boost::arg<1>&fields_type = placeholder<1>::get();
52
+ inline static void readStatusCheck(table& tb, const _TCHAR* name)
53
+ {
54
+ if ((tb.stat() != 0) && (tb.stat() != STATUS_EOF)
55
+ && (tb.stat() != STATUS_NOT_FOUND_TI))
56
+ nstable::throwError(name, tb.stat());
57
+ }
58
+
59
+ class indexNavi
60
+ {
61
+
62
+ public:
63
+ inline static void increment(table& tb)
64
+ {
65
+ tb.seekNext();
66
+ readStatusCheck(tb, _T("Seek next"));
67
+
68
+ }
69
+ inline static void decrement(table& tb)
70
+ {
71
+ tb.seekPrev();
72
+ readStatusCheck(tb, _T("Seek prev"));
73
+ }
74
+
75
+ };
76
+
77
+ class indexRvNavi
78
+ {
79
+
80
+ public:
81
+ inline static void increment(table& tb)
82
+ {
83
+ tb.seekPrev();
84
+ readStatusCheck(tb, _T("Seek next"));
85
+
86
+ }
87
+ inline static void decrement(table& tb)
88
+ {
89
+
90
+ tb.seekNext();
91
+ readStatusCheck(tb, _T("Seek prev"));
92
+ }
93
+
94
+ };
95
+
96
+ class indexFindNavi
97
+ {
98
+
99
+ public:
100
+ inline static void increment(table& tb)
101
+ {
102
+ tb.findNext();
103
+ readStatusCheck(tb, _T("Find next"));
104
+
105
+ }
106
+ inline static void decrement(table& tb)
107
+ {
108
+ tb.findPrev();
109
+ readStatusCheck(tb, _T("Find prev"));
110
+
111
+ }
112
+
113
+ };
114
+
115
+ class indexRvFindNavi
116
+ {
117
+
118
+ public:
119
+ inline static void increment(table& tb)
120
+ {
121
+ tb.findPrev();
122
+ readStatusCheck(tb, _T("Find next"));
123
+
124
+ }
125
+ inline static void decrement(table& tb)
126
+ {
127
+ tb.findNext();
128
+ readStatusCheck(tb, _T("Find prev"));
129
+
130
+ }
131
+
132
+ };
133
+
134
+ class stepNavi
135
+ {
136
+
137
+ public:
138
+ inline static void increment(table& tb)
139
+ {
140
+ tb.stepNext();
141
+ readStatusCheck(tb, _T("Step next"));
142
+
143
+ }
144
+ inline static void decrement(table& tb)
145
+ {
146
+ tb.stepPrev();
147
+ readStatusCheck(tb, _T("Step prev"));
148
+ }
149
+
150
+ };
151
+
152
+ class stepRvNavi
153
+ {
154
+
155
+ public:
156
+ inline static void increment(table& tb)
157
+ {
158
+ tb.stepPrev();
159
+ readStatusCheck(tb, _T("Step next"));
160
+
161
+ }
162
+ inline static void decrement(table& tb)
163
+ {
164
+ tb.stepNext();
165
+ readStatusCheck(tb, _T("Step prev"));
166
+ }
167
+
168
+ };
169
+
170
+
171
+
172
+
173
+
174
+ }// namespace client
175
+ }// namespace tdap
176
+ }// namespace protocol
177
+ }// namespace db
178
+ }// namespace bzs
179
+ #endif//trdboostapiInternalH
@@ -0,0 +1,40 @@
1
+ #ifndef BZS_RTL_TRDCLCPPAUTOLINK_H
2
+ #define BZS_RTL_TRDCLCPPAUTOLINK_H
3
+ /*=================================================================
4
+ Copyright (C) 2013 BizStation Corp All rights reserved.
5
+
6
+ This program is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU General Public License
8
+ as published by the Free Software Foundation; either version 2
9
+ of the License, or (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
+ 02111-1307, USA.
20
+ =================================================================*/
21
+
22
+ /* For windows client application programs
23
+ If you need auto link then you define TRDCL_AUTOLINK and assign
24
+ library path in project option.
25
+
26
+ */
27
+
28
+ #ifdef TRDCL_AUTOLINK
29
+ # include <bzs/env/compiler.h>
30
+ # include <bzs/db/protocol/tdap/tdapcapi.h>
31
+ # if (__BCPLUSPLUS__ && __clang__)
32
+ # define LIB_EXTENTION ".a"
33
+ # else
34
+ # define LIB_EXTENTION ".lib"
35
+ # endif
36
+ # define TD_CPP_LIB_NAME TD_CPP_LIB_PRE CPP_INTERFACE_VERSTR LIB_EXTENTION
37
+ # pragma comment(lib, TD_CPP_LIB_NAME)
38
+ #endif //TRDCL_AUTOLINK
39
+
40
+ #endif //BZS_RTL_TRDCLCPPAUTOLINK_H
@@ -0,0 +1,11 @@
1
+
2
+
3
+ EXPORTS
4
+ BTRCALLID @1
5
+ BTRCALL @2
6
+ BTRVID @3
7
+ BTRV @4
8
+ BTRCALLID32 @5
9
+ BTRCALL32 @6
10
+
11
+
@@ -0,0 +1,500 @@
1
+ /*=================================================================
2
+ Copyright (C) 2013 BizStation Corp All rights reserved.
3
+
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
+ 02111-1307, USA.
18
+ =================================================================*/
19
+
20
+ #include <bzs/env/tstring.h>
21
+ #pragma hdrstop
22
+
23
+ #include <stdlib.h>
24
+ #include <stdio.h>
25
+ #include <time.h>
26
+ #include <bzs/db/protocol/tdap/btrDate.h>
27
+
28
+
29
+ namespace bzs
30
+ {
31
+ namespace db
32
+ {
33
+ namespace protocol
34
+ {
35
+ namespace tdap
36
+ {
37
+
38
+ #pragma option -a-
39
+ pragma_pack1
40
+
41
+
42
+ #ifdef _WIN32
43
+
44
+ const wchar_t wtime_format_ms[] = L"%02d:%02d:%02d.%d";
45
+ const wchar_t wtime_format[] = L"%02d:%02d:%02d";
46
+ const wchar_t wdatetime_format_ms[] = L"%04d-%02d-%02d %02d:%02d:%02d.%d";
47
+ const wchar_t wdatetime_format[] = L"%04d-%02d-%02d %02d:%02d:%02d";
48
+ const wchar_t wdatetime_format_ms_i[] = L"%04d-%02d-%02d %02d:%02d:%02d.%d";
49
+ const wchar_t wdatetime_format_i[] = L"%04d-%02d-%02d %02d:%02d:%02d";
50
+
51
+ inline size_t _ttol_(const wchar_t* v){return _wtol(v);}
52
+ inline size_t _tcslen_(const wchar_t* v){return wcslen(v);}
53
+ inline wchar_t* _tcsncpy_(wchar_t* d, const wchar_t* s, size_t n){return wcsncpy(d,s,n);}
54
+
55
+ #endif
56
+
57
+ const char time_format_ms[] = "%02d:%02d:%02d.%-*d";
58
+ const char time_format[] = "%02d:%02d:%02d";
59
+ const char datetime_format_ms[] = "%04d-%02d-%02d %02d:%02d:%02d.%d";
60
+ const char datetime_format[] = "%04d-%02d-%02d %02d:%02d:%02d";
61
+ const char datetime_format_ms_i[] = "%04d-%02d-%02d %02d:%02d:%02d.%d";
62
+ const char datetime_format_i[] = "%04d-%02d-%02d %02d:%02d:%02d";
63
+
64
+ inline size_t _ttol_(const char* v){return atol(v);}
65
+ inline size_t _tcslen_(const char* v){return strlen(v);}
66
+ inline char* _tcsncpy_(char* d, const char* s, size_t n){return strncpy(d,s,n);}
67
+
68
+
69
+ #pragma warning(disable:4996)
70
+ union myDate
71
+ {
72
+ struct
73
+ {
74
+ unsigned int dd :5;
75
+ unsigned int mm :4;
76
+ unsigned int yy :15;
77
+ unsigned int tmp:8;
78
+ };
79
+
80
+ int i;
81
+
82
+ inline void setValue(int v, bool btrvValue = false)
83
+ {
84
+ if (btrvValue)
85
+ {
86
+ btrDate btrd;
87
+ btrd.i = v;
88
+ yy = btrd.yy;
89
+ mm = btrd.mm;
90
+ dd = btrd.dd;
91
+ tmp=0;
92
+ }
93
+ else
94
+ i = v;
95
+ }
96
+
97
+ inline int getValue(bool btrvValue = false)
98
+ {
99
+ if (btrvValue)
100
+ {
101
+ btrDate btrd;
102
+ btrd.yy = yy;
103
+ btrd.mm = mm;
104
+ btrd.dd = dd;
105
+ return btrd.i;
106
+ }
107
+ return i;
108
+ }
109
+
110
+ inline char* toStr(char* p, bool btrvValue)
111
+ {
112
+ if (btrvValue)
113
+ sprintf(p, "%04d/%02d/%02d",yy, mm, dd);
114
+ else
115
+ sprintf(p, "%04d-%02d-%02d",yy, mm, dd);
116
+ return p;
117
+ }
118
+
119
+ #ifdef _WIN32
120
+ inline wchar_t* toStr(wchar_t* p, bool btrvValue)
121
+ {
122
+ if (btrvValue)
123
+ swprintf_s(p, 11, L"%04d/%02d/%02d",yy, mm, dd);
124
+ else
125
+ swprintf_s(p, 11, L"%04d-%02d-%02d",yy, mm, dd);
126
+ return p;
127
+ }
128
+ #endif
129
+
130
+ template <class T>
131
+ inline myDate& operator=(const T* p)
132
+ {
133
+ tmp = 0;
134
+ yy = _ttol_(p);
135
+ mm = _ttol_(p+5);
136
+ dd = _ttol_(p+8);
137
+ return *this;
138
+ }
139
+
140
+ };
141
+
142
+
143
+ struct myTime
144
+ {
145
+
146
+ private:
147
+ int m_dec;
148
+
149
+ public:
150
+ union
151
+ {
152
+ struct
153
+ {
154
+ unsigned __int64 ms :24;
155
+ unsigned __int64 ss :6;
156
+ unsigned __int64 nn :6;
157
+ unsigned __int64 hh :10;
158
+ unsigned __int64 unused :1;
159
+ unsigned __int64 sign :1;
160
+ unsigned __int64 tmp :16;
161
+
162
+ };
163
+ __int64 i64;
164
+ };
165
+
166
+ public:
167
+ inline myTime(int size):m_dec((size - 3)*2){};
168
+
169
+ inline void setValue(__int64 v, bool btrvValue = false)
170
+ {
171
+
172
+ if (btrvValue)
173
+ {
174
+ btrTime btrt;
175
+ btrt.i = (int)v;
176
+ hh = btrt.hh;
177
+ nn = btrt.nn;
178
+ ss = btrt.ss;
179
+ ms = btrt.uu * 10000;
180
+ tmp=0;
181
+ sign = 1;
182
+ unused = 0;
183
+ return;
184
+ }
185
+ char* p=(char*)&i64;
186
+ char* src=(char*)&v;
187
+ if (m_dec)
188
+ {
189
+ p[0] = src[5];
190
+ p[1] = src[4];
191
+ p[2] = src[3];
192
+ ms = ms >> (3-m_dec/2)*8;
193
+ }
194
+ p[3] = src[2];
195
+ p[4] = src[1];
196
+ p[5] = src[0];
197
+ }
198
+
199
+ inline __int64 getValue( bool btrvValue = false)
200
+ {
201
+ __int64 v = 0;
202
+ char* src=(char*)&i64;
203
+ char* p=(char*)&v;
204
+ p[2] = src[3];
205
+ p[1] = src[4];
206
+ p[0] = src[5];
207
+ if (m_dec)
208
+ {
209
+ ms = ms << (3-m_dec/2)*8;
210
+ p[3] = src[2];
211
+ p[4] = src[1];
212
+ p[5] = src[0];
213
+ }
214
+ if (btrvValue)
215
+ {
216
+ btrTime btrt;
217
+ btrt.hh = hh;
218
+ btrt.nn = nn;
219
+ btrt.ss = ss;
220
+ btrt.uu = (char)(ms/100000);
221
+ return btrt.i;
222
+ }
223
+ return v;
224
+ }
225
+
226
+ inline char* toStr(char* p)
227
+ {
228
+ if (m_dec)
229
+ sprintf(p, time_format_ms, hh, nn, ss, m_dec, ms);
230
+ else
231
+ sprintf(p, time_format, hh, nn, ss);
232
+ return p;
233
+ }
234
+
235
+ #ifdef _WIN32
236
+ inline wchar_t* toStr(wchar_t* p)
237
+ {
238
+ if (m_dec)
239
+ swprintf_s(p, 17, wtime_format_ms, hh, nn, ss, ms);
240
+ else
241
+ swprintf_s(p, 9, wtime_format, hh, nn, ss);
242
+ return p;
243
+ }
244
+ #endif
245
+
246
+ template <class T>
247
+ inline myTime& operator=(const T* p)
248
+ {
249
+ sign = 1;
250
+ unused = 0;
251
+ ms = 0;
252
+ hh = _ttol_(p);
253
+ nn = _ttol_(p+3);
254
+ ss = _ttol_(p+6);
255
+ if (m_dec && _tcslen_(p)>9)
256
+ {
257
+ T tmp[10]={0x00};
258
+ _tcsncpy_(tmp, p+9, (size_t)m_dec);
259
+ ms = _ttol_(tmp);
260
+ }
261
+ return *this;
262
+ }
263
+ };
264
+
265
+
266
+ struct myDateTime
267
+ {
268
+ private:
269
+ int m_dec;
270
+
271
+ public:
272
+ union
273
+ {
274
+ struct
275
+ {
276
+ unsigned __int64 ms :24;
277
+ unsigned __int64 ss :6;
278
+ unsigned __int64 nn :6;
279
+ unsigned __int64 hh :5;
280
+ unsigned __int64 dd :5;
281
+ unsigned __int64 yymm :17; //yy*13+mm (yy 0-9999, mm 0-12)
282
+ unsigned __int64 sign :1;
283
+ };
284
+ __int64 i64;
285
+ };
286
+
287
+ inline myDateTime(int size):m_dec((size - 5)*2){};
288
+
289
+ inline void setValue(__int64 v)
290
+ {
291
+ char* p=(char*)&i64;
292
+ char* src=(char*)&v;
293
+ if (m_dec)
294
+ {
295
+ p[0] = src[7];
296
+ p[1] = src[6];
297
+ p[2] = src[5];
298
+ ms = ms >> (3-m_dec/2)*8;
299
+ }
300
+ p[3] = src[4];
301
+ p[4] = src[3];
302
+ p[5] = src[2];
303
+ p[6] = src[1];
304
+ p[7] = src[0];
305
+
306
+ }
307
+
308
+ inline __int64 getValue()
309
+ {
310
+ __int64 v = 0;
311
+ char* src=(char*)&i64;
312
+ char* p=(char*)&v;
313
+ p[4] = src[3];
314
+ p[3] = src[4];
315
+ p[2] = src[5];
316
+ p[1] = src[6];
317
+ p[0] = src[7];
318
+ if (m_dec)
319
+ {
320
+ ms = ms << (3-m_dec/2)*8;
321
+ p[5] = src[2];
322
+ p[6] = src[1];
323
+ p[7] = src[0];
324
+ }
325
+ return v;
326
+ }
327
+
328
+ inline char* toStr(char* p)
329
+ {
330
+ if (m_dec)
331
+ sprintf(p, datetime_format_ms ,yymm/13,yymm%13, dd, hh, nn, ss, ms);
332
+ else
333
+ sprintf(p, datetime_format, yymm/13,yymm%13, dd, hh, nn, ss);
334
+ return p;
335
+ }
336
+
337
+ #ifdef _WIN32
338
+ inline wchar_t* toStr(wchar_t* p)
339
+ {
340
+ if (m_dec)
341
+ swprintf_s(p, 26, wdatetime_format_ms, yymm/13, yymm%13, dd, hh, nn, ss, ms);
342
+ else
343
+ swprintf_s(p, 20, wdatetime_format, yymm/13, yymm%13, dd, hh, nn, ss);
344
+ return p;
345
+ }
346
+ #endif
347
+
348
+ template <class T>
349
+ myDateTime& operator=(const T* p)
350
+ {
351
+ sign = 1;
352
+ ms = 0 ;
353
+ yymm = _ttol_(p)*13+_ttol_(p+5);
354
+ dd = _ttol_(p+8);
355
+ hh = _ttol_(p+11);
356
+ nn = _ttol_(p+14);
357
+ ss = _ttol_(p+17);
358
+ if (m_dec && _tcslen_(p)>20)
359
+ {
360
+ T tmp[10]={0x00};
361
+ _tcsncpy_(tmp, p+20, (size_t)m_dec);
362
+ ms = _ttol_(tmp);
363
+ }
364
+ return *this;
365
+ }
366
+
367
+ };
368
+
369
+ struct myTimeStamp
370
+ {
371
+ private:
372
+ int m_dec;
373
+
374
+ public:
375
+ union
376
+ {
377
+ struct
378
+ {
379
+ unsigned __int64 ms :24;
380
+ unsigned __int64 datetime:32;
381
+ unsigned __int64 tmp :8;
382
+ };
383
+ __int64 i64;
384
+ };
385
+
386
+ inline myTimeStamp(int size):m_dec((size - 4)*2){};
387
+
388
+ inline void setValue(__int64 v)
389
+ {
390
+ char* p=(char*)&i64;
391
+ char* src=(char*)&v;
392
+ if (m_dec)
393
+ {
394
+ p[0] = src[6];
395
+ p[1] = src[5];
396
+ p[2] = src[4];
397
+ ms = ms >> (3-m_dec/2)*8;
398
+ }
399
+ p[3] = src[3];
400
+ p[4] = src[2];
401
+ p[5] = src[1];
402
+ p[6] = src[0];
403
+ }
404
+
405
+ inline __int64 getValue()
406
+ {
407
+ __int64 v = 0;
408
+ char* src=(char*)&i64;
409
+ char* p=(char*)&v;
410
+
411
+ p[3] = src[3];
412
+ p[2] = src[4];
413
+ p[1] = src[5];
414
+ p[0] = src[6];
415
+ if (m_dec)
416
+ {
417
+ ms = ms << (3-m_dec/2)*8;
418
+ p[4] = src[2];
419
+ p[5] = src[1];
420
+ p[6] = src[0];
421
+ }
422
+ return v;
423
+ }
424
+
425
+ #ifdef _WIN32
426
+ inline wchar_t* toStr(wchar_t* p)
427
+ {
428
+ struct tm* st;
429
+ time_t v = (time_t)datetime;
430
+ st = localtime(&v);
431
+
432
+ if (m_dec)
433
+ swprintf_s(p, 26, wdatetime_format_ms_i
434
+ ,st->tm_year+1900, st->tm_mon+1, st->tm_mday
435
+ ,st->tm_hour, st->tm_min, st->tm_sec, (int)ms);
436
+ else
437
+ swprintf_s(p, 20, wdatetime_format_i
438
+ ,st->tm_year+1900, st->tm_mon+1, st->tm_mday
439
+ ,st->tm_hour, st->tm_min, st->tm_sec);
440
+ return p;
441
+ }
442
+ #endif
443
+
444
+ inline char* toStr(char* p)
445
+ {
446
+ struct tm* st;
447
+ time_t v = (time_t)datetime;
448
+ st = localtime(&v);
449
+
450
+ if (m_dec)
451
+ sprintf(p, datetime_format_ms_i
452
+ ,st->tm_year+1900, st->tm_mon+1, st->tm_mday
453
+ ,st->tm_hour, st->tm_min, st->tm_sec, (int)ms);
454
+ else
455
+ sprintf(p, datetime_format_i
456
+ ,st->tm_year+1900, st->tm_mon+1, st->tm_mday
457
+ ,st->tm_hour, st->tm_min, st->tm_sec);
458
+ return p;
459
+ }
460
+
461
+ };
462
+ inline int btrdateToMydate(int btrd)
463
+ {
464
+ myDate myd;
465
+ myd.setValue(btrd, true);
466
+ return myd.getValue(true);
467
+ }
468
+
469
+ inline __int64 btrtimeToMytime(int btrt)
470
+ {
471
+ myTime myt(4);
472
+ myt.setValue(btrt, true);
473
+ return myt.getValue(true);
474
+ }
475
+
476
+ inline int mydateToBtrdate(int mydate)
477
+ {
478
+ myDate myd;
479
+ myd.setValue(mydate);
480
+ return myd.getValue(true);
481
+ }
482
+
483
+ inline int mytimeToBtrtime(__int64 mytime, int size)
484
+ {
485
+ myTime myt(size);
486
+ myt.setValue(mytime);
487
+ return (int)myt.getValue(true);
488
+ }
489
+ #pragma warning(default:4996)
490
+
491
+
492
+ #pragma option -a
493
+ pragma_pop
494
+
495
+ }//namespace tdap
496
+ }//namespace protocol
497
+ }//namespace db
498
+ }//namespace bzs
499
+
500
+ //#endif //MYDATETIME_H