transactd 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,1096 @@
1
+ #ifndef trdboostapiH
2
+ #define trdboostapiH
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 <bzs/db/protocol/tdap/client/trdboostapiInternal.h>
22
+ #include <boost/shared_ptr.hpp>
23
+ #include <stdio.h>
24
+
25
+ #if defined(__GNUC__)
26
+ #if !__GNUC_PREREQ(4, 3)
27
+ #error "GCC Version is too small. 4.3 or above GCC versions are required."
28
+ #endif
29
+ #endif
30
+
31
+
32
+ namespace bzs
33
+ {
34
+ namespace db
35
+ {
36
+ namespace protocol
37
+ {
38
+ namespace tdap
39
+ {
40
+ namespace client
41
+ {
42
+
43
+ enum eIndexOpType {
44
+ eSeekEqual, eSeekFirst, eSeekLast, eSeekGreaterOrEqual, eSeekGreater, eSeekLessThanOrEqual,
45
+ eSeekLessThan};
46
+
47
+ enum eStepOpType {
48
+ eStepFirst, eStepLast};
49
+
50
+ enum eFindCurrntType{
51
+ ePosNeedNext = 1, ePosNeedNone = 0, ePosNeedPrev = -1};
52
+
53
+ typedef boost::shared_ptr<database>database_ptr;
54
+ typedef boost::shared_ptr<table>table_ptr;
55
+
56
+
57
+
58
+
59
+ class field
60
+ {
61
+ short m_index;
62
+ table& m_tb;
63
+
64
+ public:
65
+ inline field(table& tb, short index) : m_tb(tb), m_index(index) {};
66
+
67
+ inline const _TCHAR* c_str() const {return m_tb.getFVstr(m_index);}
68
+
69
+ inline const char* a_str() const {return m_tb.getFVAstr(m_index);}
70
+
71
+ inline int i() const {return m_tb.getFVint(m_index);}
72
+
73
+ inline short i16() const {return m_tb.getFVsht(m_index);}
74
+
75
+ inline __int64 i64() const {return m_tb.getFV64(m_index);}
76
+
77
+ inline float f() const {return m_tb.getFVflt(m_index);}
78
+
79
+ inline double d() const {return m_tb.getFVdbl(m_index);}
80
+ inline field& operator = (const _TCHAR* p) {
81
+ m_tb.setFV(m_index, p);
82
+ return *this;
83
+ } inline field& operator = (int v) {
84
+ m_tb.setFV(m_index, v);
85
+ return *this;
86
+ } inline field& operator = (__int64 v) {
87
+ m_tb.setFV(m_index, v);
88
+ return *this;
89
+ } inline field& operator = (float v) {
90
+ m_tb.setFV(m_index, v);
91
+ return *this;
92
+ } inline field& operator = (double v) {
93
+ m_tb.setFV(m_index, v);
94
+ return *this;
95
+ }
96
+ inline bool operator != (const _TCHAR* p) {return (_tcscmp(p, c_str()) != 0);};
97
+ inline bool operator == (const _TCHAR* p) {return (_tcscmp(p, c_str())==0);};
98
+
99
+ inline bool operator != (int v) {return (v != i());};
100
+ inline bool operator == (int v) {return (v == i());};
101
+
102
+ inline bool operator != (short v) {return (v != i16());};
103
+ inline bool operator == (short v) {return (v == i16());};
104
+
105
+ inline bool operator != (__int64 v) {return (v != i64());};
106
+ inline bool operator == (__int64 v) {return (v == i64());};
107
+
108
+ inline bool operator != (float v) {return (v != f());};
109
+ inline bool operator == (float v) {return (v == f());};
110
+
111
+ inline bool operator != (double v) {return (v != d());};
112
+ inline bool operator == (double v) {return (v == d());};
113
+
114
+ inline void setBin(const void* data, uint_td size){ m_tb.setFV(m_index, data, size);}
115
+ inline void* getBin(uint_td& size){return m_tb.getFVbin(m_index, size);};
116
+ };
117
+
118
+ class fields
119
+ {
120
+ table& m_tb;
121
+
122
+ public:
123
+ inline explicit fields(table& tb) : m_tb(tb) {};
124
+ inline explicit fields(table_ptr tb) : m_tb(*tb) {};
125
+ inline void clearValues(){m_tb.clearBuffer();};
126
+ inline field operator[](size_t index) const {return field(m_tb, (short)index);}
127
+
128
+ inline field operator()(const _TCHAR* name) const {
129
+ return field(m_tb, m_tb.fieldNumByName(name));}
130
+ inline table& tb() const {return m_tb;}
131
+
132
+ inline size_t size() {return m_tb.tableDef()->fieldCount;}
133
+
134
+ inline field fd(size_t index) const {return field(m_tb, (short)index);}
135
+
136
+ inline field fd(const _TCHAR* name) const {return field(m_tb, m_tb.fieldNumByName(name));}
137
+ };
138
+
139
+ class filterParams
140
+ {
141
+ std::_tstring m_str;
142
+ int m_rejectCount;
143
+ int m_maxRecords;
144
+ public:
145
+ inline filterParams(const _TCHAR* filter, int rejectCount, int maxRecords)
146
+ :m_str(filter),m_rejectCount(rejectCount),m_maxRecords(maxRecords)
147
+ {
148
+
149
+ }
150
+ inline const _TCHAR* filter() const {return m_str.c_str();}
151
+ inline int rejectCount() const {return m_rejectCount;}
152
+ inline int maxRecords() const {return m_maxRecords;}
153
+
154
+
155
+ };
156
+
157
+ template <class T>
158
+ class tableIterator
159
+ {
160
+
161
+ table& m_tb;
162
+ fields m_fds;
163
+
164
+ inline tableIterator() : m_tb(*((table*)0)), m_fds(*((table*)0)) {};
165
+
166
+ public:
167
+ static const tableIterator eos;
168
+
169
+ inline tableIterator(table& tb) : m_tb(tb), m_fds(tb) {};
170
+
171
+ table& tb() const {return m_tb;};
172
+
173
+ inline fields& operator*() {return m_fds;}
174
+
175
+ inline fields* operator->() {return &m_fds;}
176
+
177
+ inline tableIterator& operator++() {
178
+ T::increment(m_tb);
179
+ return *this;
180
+ }
181
+
182
+ inline tableIterator& operator--() {
183
+ T::decrement(m_tb);
184
+ return *this;
185
+ }
186
+
187
+ inline bool operator == (const tableIterator& v) {return m_tb.stat() != 0;}
188
+
189
+ inline bool operator != (const tableIterator& v) {return m_tb.stat() == 0;}
190
+
191
+ };
192
+ typedef tableIterator<indexNavi> indexIterator;
193
+ typedef tableIterator<indexFindNavi> findIterator;
194
+ typedef tableIterator<stepNavi> stepIterator;
195
+
196
+
197
+ template <> const indexIterator indexIterator::eos;
198
+ template <> const findIterator findIterator::eos;
199
+ template <> const stepIterator stepIterator::eos;
200
+
201
+
202
+
203
+ typedef tableIterator<indexRvNavi> indexRvIterator;
204
+ typedef tableIterator<indexRvFindNavi> findRvIterator;
205
+ typedef tableIterator<stepRvNavi> stepRvIterator;
206
+
207
+
208
+ template <> const indexRvIterator indexRvIterator::eos;
209
+ template <> const findRvIterator findRvIterator::eos;
210
+ template <> const stepRvIterator stepRvIterator::eos;
211
+
212
+
213
+
214
+ static const int filter_validate_value = 0;
215
+ static const int filter_validate_block = 1;
216
+ static const int filter_invalidate_value = 2;
217
+
218
+ typedef boost::function < int(const fields&) > validationFunc;
219
+
220
+ #define VALIDATION_FUNC(FUNC_PTR, PTR) boost::bind(FUNC_PTR, PTR, fields_type)
221
+
222
+ template<class T>
223
+ class filterdIterator
224
+ {
225
+ T& m_it;
226
+ validationFunc m_func;
227
+ inline int callFunc()
228
+ {
229
+ int v = m_func(*m_it);
230
+ if (v == filter_invalidate_value)
231
+ m_it.tb().setStat(STATUS_EOF);
232
+ return v;
233
+
234
+ }
235
+
236
+ public:
237
+ static const filterdIterator<T> eos;
238
+
239
+ filterdIterator() : m_it(*((T*)0)), m_func(NULL) {}
240
+
241
+ filterdIterator(T& it, validationFunc func) : m_it(it), m_func(func)
242
+ {
243
+ int v = callFunc();
244
+ if (v == filter_validate_block)
245
+ operator++();
246
+ }
247
+
248
+
249
+ inline fields operator*() {return m_it.operator*();}
250
+
251
+ inline fields* operator->() {return m_it.operator->();}
252
+
253
+ T& operator++()
254
+ {
255
+ int v;
256
+ do {
257
+ ++m_it;
258
+ v = callFunc();
259
+ }
260
+ while (v == filter_validate_block);
261
+ return m_it;
262
+ }
263
+
264
+
265
+ inline bool operator == (const filterdIterator& v) {return m_it.operator == (v.m_it);}
266
+
267
+ inline bool operator != (const filterdIterator& v) {return m_it.operator != (v.m_it);}
268
+
269
+ };
270
+
271
+ typedef filterdIterator<indexIterator> filterdIndexIterator;
272
+ typedef filterdIterator<stepIterator> filterdStepIterator;
273
+ typedef filterdIterator<findIterator> filterdFindIterator;
274
+
275
+ typedef filterdIterator<indexRvIterator> filterdIndexRvIterator;
276
+ typedef filterdIterator<stepRvIterator> filterdStepRvIterator;
277
+ typedef filterdIterator<findRvIterator> filterdFindRvIterator;
278
+
279
+
280
+
281
+ template<>
282
+ const filterdIndexIterator filterdIndexIterator::eos;
283
+
284
+ template<>
285
+ const filterdStepIterator filterdStepIterator::eos;
286
+
287
+ template<>
288
+ const filterdFindIterator filterdFindIterator::eos;
289
+
290
+
291
+
292
+ inline indexIterator readIndex(table_ptr tb, eIndexOpType op)
293
+ {
294
+
295
+ switch (op)
296
+ {
297
+ case eSeekEqual: tb->seek();
298
+ break;
299
+ case eSeekFirst: tb->seekFirst();
300
+ break;
301
+ case eSeekGreaterOrEqual: tb->seekGreater(true);
302
+ break;
303
+ case eSeekGreater: tb->seekGreater(false);
304
+ break;
305
+ default:
306
+ assert(0);
307
+ readStatusCheck(*tb, _T("readIndex"));
308
+ }
309
+ return indexIterator(*tb);
310
+ }
311
+
312
+ inline indexRvIterator readIndexRv(table_ptr tb, eIndexOpType op)
313
+ {
314
+
315
+ switch (op)
316
+ {
317
+ case eSeekEqual: tb->seek();
318
+ break;
319
+ case eSeekLast: tb->seekLast();
320
+ break;
321
+ case eSeekLessThanOrEqual: tb->seekLessThan(true);
322
+ break;
323
+ case eSeekLessThan: tb->seekLessThan(false);
324
+ break;
325
+ default:
326
+ assert(0);
327
+ readStatusCheck(*tb, _T("readIndexRv"));
328
+ }
329
+ return indexRvIterator(*tb);
330
+ }
331
+
332
+ template<class T>
333
+ inline indexIterator readIndex(table_ptr tb, eIndexOpType op, char_td keynum, T func)
334
+ {
335
+ tb->setKeyNum(keynum);
336
+ if (&func)
337
+ {
338
+ fields fds(*tb);
339
+ func(fds);
340
+ }
341
+ return readIndex(tb, op);
342
+
343
+ }
344
+
345
+ template<class T>
346
+ inline indexRvIterator readIndexRv(table_ptr tb, eIndexOpType op, char_td keynum, T func)
347
+ {
348
+ tb->setKeyNum(keynum);
349
+ if (&func)
350
+ {
351
+ fields fds(*tb);
352
+ func(fds);
353
+ }
354
+ return readIndexRv(tb, op);
355
+
356
+ }
357
+
358
+
359
+ template <class T0 = _TCHAR*, class T1 = _TCHAR*, class T2 = _TCHAR*, class T3 = _TCHAR*
360
+ , class T4 = _TCHAR*, class T5 = _TCHAR*, class T6 = _TCHAR*, class T7 = _TCHAR*>
361
+ class keyValue
362
+ {
363
+
364
+ public:
365
+ inline static void set(table_ptr tb, const char_td keynum
366
+ ,const T0 kv0, const T1 kv1=NULL
367
+ ,const T2 kv2=NULL, const T3 kv3=NULL
368
+ ,const T4 kv4=NULL, const T5 kv5=NULL
369
+ ,const T6 kv6=NULL, const T7 kv7=NULL)
370
+ {
371
+ const tabledef& td = *tb->tableDef();
372
+ if (keynum < td.keyCount)
373
+ {
374
+ const keydef kd = td.keyDefs[keynum];
375
+ if (kd.segmentCount > 0)
376
+ tb->setFV(kd.segments[0].fieldNum, kv0);
377
+ if (kd.segmentCount > 1)
378
+ tb->setFV(kd.segments[1].fieldNum, kv1);
379
+ if (kd.segmentCount > 2)
380
+ tb->setFV(kd.segments[2].fieldNum, kv2);
381
+ if (kd.segmentCount > 3)
382
+ tb->setFV(kd.segments[3].fieldNum, kv3);
383
+ if (kd.segmentCount > 4)
384
+ tb->setFV(kd.segments[4].fieldNum, kv4);
385
+ if (kd.segmentCount > 5)
386
+ tb->setFV(kd.segments[5].fieldNum, kv5);
387
+ if (kd.segmentCount > 6)
388
+ tb->setFV(kd.segments[6].fieldNum, kv6);
389
+ if (kd.segmentCount > 7)
390
+ tb->setFV(kd.segments[7].fieldNum, kv7);
391
+ }
392
+ tb->setKeyNum(keynum);
393
+
394
+ }
395
+ };
396
+
397
+ template <class T0, class T1, class T2, class T3
398
+ , class T4, class T5, class T6, class T7>
399
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
400
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3
401
+ ,const T4 kv4, const T5 kv5, const T6 kv6, const T7 kv7)
402
+ {
403
+ keyValue<T0, T1, T2, T3, T4, T5, T6, T7>::
404
+ set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6, kv7);
405
+ return readIndex(tb, op);
406
+ }
407
+
408
+ template <class T0, class T1, class T2, class T3
409
+ , class T4, class T5, class T6>
410
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
411
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3
412
+ ,const T4 kv4, const T5 kv5, const T6 kv6)
413
+ {
414
+ keyValue<T0, T1, T2, T3, T4, T5, T6>::
415
+ set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6);
416
+ return readIndex(tb, op);
417
+ }
418
+
419
+ template <class T0, class T1, class T2, class T3
420
+ , class T4, class T5>
421
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
422
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3
423
+ ,const T4 kv4, const T5 kv5)
424
+ {
425
+ keyValue<T0, T1, T2, T3, T4, T5>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5);
426
+ return readIndex(tb, op);
427
+ }
428
+
429
+ template <class T0, class T1, class T2, class T3, class T4>
430
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
431
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3, const T4 kv4)
432
+ {
433
+ keyValue<T0, T1, T2, T3, T4>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4);
434
+ return readIndex(tb, op);
435
+ }
436
+
437
+ template <class T0, class T1, class T2, class T3>
438
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
439
+ ,const T0 kv0, const T1 kv1 ,const T2 kv2, const T3 kv3)
440
+ {
441
+ keyValue<T0, T1, T2, T3>::set(tb, keynum, kv0, kv1, kv2, kv3);
442
+ return readIndex(tb, op);
443
+ }
444
+
445
+ template <class T0, class T1, class T2>
446
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
447
+ ,const T0 kv0, const T1 kv1 ,const T2 kv2)
448
+ {
449
+ keyValue<T0, T1, T2>::set(tb, keynum, kv0, kv1, kv2);
450
+ return readIndex(tb, op);
451
+ }
452
+
453
+ template <class T0, class T1>
454
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
455
+ ,const T0 kv0, const T1 kv1)
456
+ {
457
+ keyValue<T0, T1>::set(tb, keynum, kv0, kv1);
458
+ return readIndex(tb, op);
459
+ }
460
+
461
+ template <class T0>
462
+ indexIterator readIndex_v(table_ptr tb, eIndexOpType op, const char_td keynum
463
+ ,const T0 kv0)
464
+ {
465
+ keyValue<T0>::set(tb, keynum, kv0);
466
+ return readIndex(tb, op);
467
+ }
468
+
469
+
470
+ template <class T0, class T1, class T2, class T3
471
+ , class T4, class T5, class T6, class T7>
472
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
473
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3
474
+ ,const T4 kv4, const T5 kv5, const T6 kv6, const T7 kv7)
475
+ {
476
+ keyValue<T0, T1, T2, T3, T4, T5, T6, T7>::
477
+ set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6, kv7);
478
+ return readIndexRv(tb, op);
479
+ }
480
+
481
+ template <class T0, class T1, class T2, class T3
482
+ , class T4, class T5, class T6>
483
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
484
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3
485
+ ,const T4 kv4, const T5 kv5, const T6 kv6)
486
+ {
487
+ keyValue<T0, T1, T2, T3, T4, T5, T6>::
488
+ set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6);
489
+ return readIndexRv(tb, op);
490
+ }
491
+
492
+ template <class T0, class T1, class T2, class T3
493
+ , class T4, class T5>
494
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
495
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3
496
+ ,const T4 kv4, const T5 kv5)
497
+ {
498
+ keyValue<T0, T1, T2, T3, T4, T5>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5);
499
+ return readIndexRv(tb, op);
500
+ }
501
+
502
+ template <class T0, class T1, class T2, class T3, class T4>
503
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
504
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3, const T4 kv4)
505
+ {
506
+ keyValue<T0, T1, T2, T3, T4>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4);
507
+ return readIndexRv(tb, op);
508
+ }
509
+
510
+ template <class T0, class T1, class T2, class T3>
511
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
512
+ ,const T0 kv0, const T1 kv1 ,const T2 kv2, const T3 kv3)
513
+ {
514
+ keyValue<T0, T1, T2, T3>::set(tb, keynum, kv0, kv1, kv2, kv3);
515
+ return readIndexRv(tb, op);
516
+ }
517
+
518
+ template <class T0, class T1, class T2>
519
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
520
+ ,const T0 kv0, const T1 kv1 ,const T2 kv2)
521
+ {
522
+ keyValue<T0, T1, T2>::set(tb, keynum, kv0, kv1, kv2);
523
+ return readIndexRv(tb, op);
524
+ }
525
+
526
+ template <class T0, class T1>
527
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
528
+ ,const T0 kv0, const T1 kv1)
529
+ {
530
+ keyValue<T0, T1>::set(tb, keynum, kv0, kv1);
531
+ return readIndexRv(tb, op);
532
+ }
533
+
534
+ template <class T0>
535
+ indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op, const char_td keynum
536
+ ,const T0 kv0)
537
+ {
538
+ keyValue<T0>::set(tb, keynum, kv0);
539
+ return readIndexRv(tb, op);
540
+ }
541
+
542
+
543
+
544
+ inline stepIterator readStep(table_ptr tb)
545
+ {
546
+ tb->stepFirst();
547
+ return stepIterator(*tb);
548
+ }
549
+
550
+ inline stepRvIterator readStepRv(table_ptr tb)
551
+ {
552
+ tb->stepLast();
553
+ return stepRvIterator(*tb);
554
+ }
555
+
556
+
557
+ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7>
558
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
559
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5, const T6 kv6, const T7 kv7)
560
+ {
561
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
562
+ keyValue<T0, T1, T2, T3, T4, T5, T6, T7>::
563
+ set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6, kv7);
564
+ tb->find(table::findForword);
565
+ return findIterator(*tb);
566
+ }
567
+
568
+ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6>
569
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
570
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5, const T6 kv6)
571
+ {
572
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
573
+ keyValue<T0, T1, T2, T3, T4, T5, T6>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6);
574
+ tb->find(table::findForword);
575
+ return findIterator(*tb);
576
+ }
577
+
578
+ template <class T0, class T1, class T2, class T3, class T4, class T5>
579
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
580
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5)
581
+ {
582
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
583
+ keyValue<T0, T1, T2, T3, T4, T5>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5);
584
+ tb->find(table::findForword);
585
+ return findIterator(*tb);
586
+ }
587
+
588
+ template <class T0, class T1, class T2, class T3, class T4>
589
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
590
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4)
591
+ {
592
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
593
+ keyValue<T0, T1, T2, T3, T4>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4);
594
+ tb->find(table::findForword);
595
+ return findIterator(*tb);
596
+ }
597
+
598
+ template <class T0, class T1, class T2, class T3>
599
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
600
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3)
601
+ {
602
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
603
+ keyValue<T0, T1, T2, T3>::set(tb, keynum, kv0, kv1, kv2, kv3);
604
+ tb->find(table::findForword);
605
+ return findIterator(*tb);
606
+ }
607
+
608
+ template <class T0, class T1, class T2>
609
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
610
+ ,const T0 kv0, const T1 kv1, const T2 kv2)
611
+ {
612
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
613
+ keyValue<T0, T1, T2>::set(tb, keynum, kv0, kv1, kv2);
614
+ tb->find(table::findForword);
615
+ return findIterator(*tb);
616
+ }
617
+
618
+ template <class T0, class T1>
619
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
620
+ ,const T0 kv0, const T1 kv1)
621
+ {
622
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
623
+ keyValue<T0, T1>::set(tb, keynum, kv0, kv1);
624
+ tb->find(table::findForword);
625
+ return findIterator(*tb);
626
+ }
627
+
628
+ template <class T0>
629
+ findIterator find(table_ptr tb, const char_td keynum, const filterParams& fp
630
+ ,const T0 kv0)
631
+ {
632
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
633
+ keyValue<T0>::set(tb, keynum, kv0);
634
+ tb->find(table::findForword);
635
+ return findIterator(*tb);
636
+ }
637
+
638
+ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7>
639
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
640
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5, const T6 kv6, const T7 kv7)
641
+ {
642
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
643
+ keyValue<T0, T1, T2, T3, T4, T5, T6, T7>::
644
+ set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6, kv7);
645
+ tb->find(table::findBackForword);
646
+ return findRvIterator(*tb);
647
+ }
648
+
649
+ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6>
650
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
651
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5, const T6 kv6)
652
+ {
653
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
654
+ keyValue<T0, T1, T2, T3, T4, T5, T6>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6);
655
+ tb->find(table::findBackForword);
656
+ return findRvIterator(*tb);
657
+ }
658
+
659
+ template <class T0, class T1, class T2, class T3, class T4, class T5>
660
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
661
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5)
662
+ {
663
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
664
+ keyValue<T0, T1, T2, T3, T4, T5>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5);
665
+ tb->find(table::findBackForword);
666
+ return findRvIterator(*tb);
667
+ }
668
+
669
+ template <class T0, class T1, class T2, class T3, class T4>
670
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
671
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4)
672
+ {
673
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
674
+ keyValue<T0, T1, T2, T3, T4>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4);
675
+ tb->find(table::findBackForword);
676
+ return findRvIterator(*tb);
677
+ }
678
+
679
+ template <class T0, class T1, class T2, class T3>
680
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
681
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3)
682
+ {
683
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
684
+ keyValue<T0, T1, T2, T3>::set(tb, keynum, kv0, kv1, kv2, kv3);
685
+ tb->find(table::findBackForword);
686
+ return findRvIterator(*tb);
687
+ }
688
+
689
+ template <class T0, class T1, class T2>
690
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
691
+ ,const T0 kv0, const T1 kv1, const T2 kv2)
692
+ {
693
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
694
+ keyValue<T0, T1, T2>::set(tb, keynum, kv0, kv1, kv2);
695
+ tb->find(table::findBackForword);
696
+ return findRvIterator(*tb);
697
+ }
698
+
699
+ template <class T0, class T1>
700
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
701
+ ,const T0 kv0, const T1 kv1)
702
+ {
703
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
704
+ keyValue<T0, T1>::set(tb, keynum, kv0, kv1);
705
+ tb->find(table::findBackForword);
706
+ return findRvIterator(*tb);
707
+ }
708
+
709
+ template <class T0>
710
+ findRvIterator findRv(table_ptr tb, const char_td keynum, const filterParams& fp
711
+ ,const T0 kv0)
712
+ {
713
+ tb->setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
714
+ keyValue<T0>::set(tb, keynum, kv0);
715
+ tb->find(table::findBackForword);
716
+ return findRvIterator(*tb);
717
+ }
718
+
719
+
720
+
721
+ inline findIterator getFindIterator(indexIterator it, const filterParams& fp
722
+ ,bool isCurrentValid)
723
+
724
+ {
725
+ if (it != indexIterator::eos)
726
+ {
727
+ it.tb().setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
728
+ if (!isCurrentValid)
729
+ it.tb().findNext(false);
730
+ }
731
+ return findIterator(it.tb());
732
+ }
733
+
734
+ inline findRvIterator getFindIterator(indexRvIterator it, const filterParams& fp
735
+ ,bool isCurrentValid)
736
+ {
737
+ if (it != indexRvIterator::eos)
738
+ it.tb().setFilter(fp.filter(), fp.rejectCount(), fp.maxRecords());
739
+ if (!isCurrentValid)
740
+ it.tb().findPrev(false);
741
+ return findRvIterator(it.tb());
742
+ }
743
+
744
+
745
+ class connectParams
746
+ {
747
+ _TCHAR m_buf[MAX_PATH];
748
+ short m_mode;
749
+ short m_type;
750
+
751
+ public:
752
+ inline connectParams(const _TCHAR* protocol, const _TCHAR* hostOrIp, const _TCHAR* dbname,
753
+ const _TCHAR* schemaTable) : m_mode(TD_OPEN_READONLY), m_type(TYPE_SCHEMA_BDF)
754
+ {
755
+ _stprintf_s(m_buf, MAX_PATH, _T("%s://%s/%s?dbfile=%s.bdf")
756
+ , protocol, hostOrIp, dbname, schemaTable);
757
+
758
+ }
759
+ inline explicit connectParams(const _TCHAR* uri) : m_mode(TD_OPEN_READONLY), m_type(TYPE_SCHEMA_BDF)
760
+ {
761
+ _tcscpy_s(m_buf, MAX_PATH, uri);
762
+
763
+ }
764
+ inline void setMode(short v){m_mode = v;}
765
+
766
+ inline void setType(short v){m_type = v;}
767
+
768
+ inline const _TCHAR* uri() const {return m_buf;}
769
+
770
+ inline short mode() const {return m_mode;};
771
+
772
+ inline short type() const {return m_type;};
773
+
774
+ };
775
+
776
+ inline void releaseDatabase(database* db) {database::destroy(db);}
777
+
778
+ inline void releaseTable(table* p) {if (p) p->release();}
779
+
780
+ inline database_ptr createDatadaseObject()
781
+ {
782
+ database_ptr p(database::create(), releaseDatabase);
783
+ return p;
784
+ }
785
+
786
+ inline void connect(database_ptr db, const connectParams& connPrams, bool newConnection)
787
+ {
788
+ db->connect(connPrams.uri(), newConnection);
789
+ if (db->stat())
790
+ nstable::throwError((std::_tstring(_T("Connect database ")) + connPrams.uri()).c_str(), db->stat());
791
+
792
+ }
793
+
794
+ inline void disconnect(database_ptr db, const connectParams& connPrams)
795
+ {
796
+ db->disconnect(connPrams.uri());
797
+ if (db->stat())
798
+ nstable::throwError((std::_tstring(_T("Disconnect database ")) + connPrams.uri()).c_str(), db->stat());
799
+
800
+ }
801
+
802
+ inline void disconnect(database_ptr db)
803
+ {
804
+ db->disconnect();
805
+ if (db->stat())
806
+ nstable::throwError(_T("Disconnect database "), db->stat());
807
+
808
+ }
809
+
810
+ inline void createDatabase(database_ptr db, const connectParams& connPrams)
811
+ {
812
+ db->create(connPrams.uri());
813
+ if (db->stat())
814
+ nstable::throwError((std::_tstring(_T("Create database ")) + connPrams.uri()).c_str(), db->stat());
815
+ }
816
+
817
+ inline void createDatabase(database_ptr db, const _TCHAR* uri)
818
+ {
819
+ db->create(uri);
820
+ if (db->stat())
821
+ nstable::throwError((std::_tstring(_T("Create database "))+ uri).c_str() , db->stat());
822
+ }
823
+
824
+
825
+ inline void openDatabase(database_ptr db, const connectParams& connPrams)
826
+ {
827
+ db->open(connPrams.uri(), connPrams.type(), connPrams.mode());
828
+ if (db->stat())
829
+ nstable::throwError((std::_tstring(_T("Open database ")) + connPrams.uri()).c_str(), db->stat());
830
+
831
+ }
832
+
833
+ inline void openDatabase(database_ptr db, const _TCHAR* uri, short schemaType = 0, short mode = -2, const _TCHAR* dir = NULL,
834
+ const _TCHAR* ownername = NULL)
835
+ {
836
+ db->open(uri, schemaType, mode, dir, ownername);
837
+ if (db->stat())
838
+ nstable::throwError((std::_tstring(_T("Open database ")) + std::_tstring(uri)).c_str(), db->stat());
839
+
840
+ }
841
+
842
+ inline void dropDatabase(database_ptr db)
843
+ {
844
+ db->drop();
845
+ if (db->stat())
846
+ nstable::throwError(std::_tstring(_T("Drop database ")).c_str(), db->stat());
847
+
848
+ }
849
+
850
+ inline table_ptr openTable(database_ptr db, const _TCHAR* name)
851
+ {
852
+ table_ptr p(db->openTable(name), releaseTable);
853
+ if (db->stat())
854
+ nstable::throwError((std::_tstring(_T("Open table ")) + name).c_str(), db->stat());
855
+ return p;
856
+
857
+ }
858
+ inline void convertTable(database_ptr db, short tableid, copyDataFn func=NULL)
859
+ {
860
+
861
+ if (db->existsTableFile(tableid, NULL))
862
+ {
863
+ db->setOnCopyData(func);
864
+ db->convertTable(tableid, false, NULL);
865
+ db->setOnCopyData(NULL);
866
+ if (db->stat())
867
+ {
868
+ assert(db->dbDef());
869
+ db->dbDef()->popBackup(tableid);
870
+ nstable::throwError(std::_tstring(_T("Convert table ")).c_str(), db->stat());
871
+ }
872
+ }
873
+ }
874
+
875
+ inline void convertTable(database_ptr db, const _TCHAR* name, copyDataFn func=NULL)
876
+ {
877
+ assert(db->dbDef());
878
+ short tablenum = db->dbDef()->tableNumByName(name);
879
+ convertTable(db, tablenum, func);
880
+ }
881
+
882
+ inline void insertTable(dbdef* def, short id, const _TCHAR* name, unsigned short charsetIndex)
883
+ {
884
+ tabledef td;
885
+ td.setTableName(name);
886
+ td.setFileName(name);
887
+ td.id =id;
888
+ td.charsetIndex = (uchar_td)charsetIndex;
889
+ def->insertTable(&td);
890
+ if (def->stat() != 0)
891
+ nstable::throwError((std::_tstring(_T("Insert tabledef ")) + name).c_str(), def->stat());
892
+ }
893
+
894
+ inline fielddef* insertField(dbdef* def, short tableid, short fieldNum
895
+ , const _TCHAR* name, uchar_td type, ushort_td len )
896
+ {
897
+
898
+ fielddef* fd = def->insertField(tableid, fieldNum);
899
+ if (def->stat() != 0)
900
+ nstable::throwError((std::_tstring(_T("Insert fielddef ")) + name).c_str(), def->stat());
901
+
902
+ fd->setName(name);
903
+ fd->type = type;
904
+ fd->len = len;
905
+ return fd;
906
+ }
907
+
908
+ inline keydef* insertKey(dbdef* def, short tableid, short insertIndex)
909
+ {
910
+ keydef* kd = def->insertKey(tableid, insertIndex);
911
+ if (def->stat() != 0)
912
+ nstable::throwError(std::_tstring(_T("Insert keydef ")).c_str(), def->stat());
913
+ return kd;
914
+ }
915
+
916
+ inline void updateTableDef(dbdef* def, short tableid)
917
+ {
918
+ def->updateTableDef(tableid);
919
+ if (def->stat() != 0)
920
+ {
921
+ std::_tstring s;
922
+ if (def->tableDefs(tableid))
923
+ s = def->tableDefs(tableid)->tableName();
924
+ nstable::throwError((std::_tstring(_T("Update tabledef ")) + s).c_str(), def->stat());
925
+ }
926
+ }
927
+
928
+ template <class T>
929
+ inline void insertRecord(const T& it, bool ncc = true)
930
+ {
931
+ it.tb().insert(ncc);
932
+ if (it.tb().stat() != 0)
933
+ nstable::throwError(std::_tstring(_T("Insert record")).c_str(), it.tb().stat());
934
+
935
+ }
936
+
937
+ template <class T>
938
+ inline void updateRecord(const T& it, bool ncc = true)
939
+ {
940
+ it.tb().update((nstable::eUpdateType)ncc);
941
+ if (it.tb().stat() != 0)
942
+ nstable::throwError(std::_tstring(_T("Update record")).c_str(), it.tb().stat());
943
+
944
+ }
945
+
946
+ inline void updateRecord(fields& fd, char_td keynum)
947
+ {
948
+ fd.tb().setKeyNum(keynum);
949
+ fd.tb().update(nstable::changeInKey);
950
+ if (fd.tb().stat() != 0)
951
+ nstable::throwError(std::_tstring(_T("Update record")).c_str(), fd.tb().stat());
952
+ }
953
+
954
+ inline void deleteRecord(fields& fd, const char_td keynum)
955
+ {
956
+ fd.tb().setKeyNum(keynum);
957
+ fd.tb().del(true/*inKey*/);
958
+ if (fd.tb().stat() != 0)
959
+ nstable::throwError(std::_tstring(_T("Update record")).c_str(), fd.tb().stat());
960
+ }
961
+
962
+ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7>
963
+ void deleteRecord(table_ptr tb, const char_td keynum
964
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5, const T6 kv6, const T7 kv7)
965
+ {
966
+ keyValue<T0, T1, T2, T3, T4, T5, T6, T7>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6, kv7);
967
+ fields fd(tb);
968
+ deleteRecord(fd, keynum);
969
+ }
970
+
971
+ template <class T0, class T1, class T2, class T3, class T4, class T5, class T6>
972
+ void deleteRecord(table_ptr tb, const char_td keynum
973
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5, const T6 kv6)
974
+ {
975
+ keyValue<T0, T1, T2, T3, T4, T5, T6>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5, kv6);
976
+ fields fd(tb);
977
+ deleteRecord(fd, keynum);
978
+ }
979
+
980
+ template <class T0, class T1, class T2, class T3, class T4, class T5>
981
+ void deleteRecord(table_ptr tb, const char_td keynum
982
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4, const T5 kv5)
983
+ {
984
+ keyValue<T0, T1, T2, T3, T4, T5>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4, kv5);
985
+ fields fd(tb);
986
+ deleteRecord(fd, keynum);
987
+ }
988
+
989
+ template <class T0, class T1, class T2, class T3, class T4>
990
+ void deleteRecord(table_ptr tb, const char_td keynum
991
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3,const T4 kv4)
992
+ {
993
+ keyValue<T0, T1, T2, T3, T4>::set(tb, keynum, kv0, kv1, kv2, kv3, kv4);
994
+ fields fd(tb);
995
+ deleteRecord(fd, keynum);
996
+ }
997
+
998
+ template <class T0, class T1, class T2, class T3>
999
+ void deleteRecord(table_ptr tb, const char_td keynum
1000
+ ,const T0 kv0, const T1 kv1, const T2 kv2, const T3 kv3)
1001
+ {
1002
+ keyValue<T0, T1, T2, T3>::set(tb, keynum, kv0, kv1, kv2, kv3);
1003
+ fields fd(tb);
1004
+ deleteRecord(fd, keynum);
1005
+ }
1006
+
1007
+ template <class T0, class T1, class T2>
1008
+ void deleteRecord(table_ptr tb, const char_td keynum
1009
+ ,const T0 kv0, const T1 kv1, const T2 kv2)
1010
+ {
1011
+ keyValue<T0, T1, T2>::set(tb, keynum, kv0, kv1, kv2);
1012
+ fields fd(tb);
1013
+ deleteRecord(fd, keynum);
1014
+ }
1015
+
1016
+ template <class T0, class T1>
1017
+ void deleteRecord(table_ptr tb, const char_td keynum
1018
+ ,const T0 kv0, const T1 kv1)
1019
+ {
1020
+ keyValue<T0, T1>::set(tb, keynum, kv0, kv1);
1021
+ fields fd(tb);
1022
+ deleteRecord(fd, keynum);
1023
+ }
1024
+
1025
+ template <class T0>
1026
+ void deleteRecord(table_ptr tb, const char_td keynum
1027
+ ,const T0 kv0)
1028
+ {
1029
+ keyValue<T0>::set(tb, keynum, kv0);
1030
+ fields fd(tb);
1031
+ deleteRecord(fd, keynum);
1032
+ }
1033
+
1034
+ template <class T>
1035
+ inline void deleteRecord(const T& it)
1036
+ {
1037
+ it.tb().del(false/*inKey*/);
1038
+ if (it.tb().stat() != 0)
1039
+ nstable::throwError(std::_tstring(_T("Delete record")).c_str(), it.tb().stat());
1040
+ }
1041
+
1042
+
1043
+ template<class T, class F>
1044
+ void for_each(T iterator, F func) {std::for_each(iterator, T::eos, func);}
1045
+
1046
+ class transaction
1047
+ {
1048
+ database_ptr m_db;
1049
+ short m_bias;
1050
+ public:
1051
+ transaction(database_ptr db, short bias=LOCK_SINGLE_NOWAIT + PARALLEL_TRN + NOWAIT_WRITE)
1052
+ :m_db(db),m_bias(bias){};
1053
+ ~transaction(){if (m_db->enableTrn()) m_db->abortTrn();};
1054
+ void begin(){m_db->beginTrn(m_bias);}
1055
+ void end(){m_db->endTrn();}
1056
+ void abort(){m_db->abortTrn();}
1057
+
1058
+ };
1059
+
1060
+ class autoSnapshot
1061
+ {
1062
+ database_ptr m_db;
1063
+ public:
1064
+ autoSnapshot(database_ptr db):m_db(db)
1065
+ {
1066
+ m_db->beginSnapshot();
1067
+ }
1068
+
1069
+ ~autoSnapshot()
1070
+ {
1071
+ m_db->endSnapshot();
1072
+ }
1073
+ };
1074
+
1075
+
1076
+ class autoBulkinsert
1077
+ {
1078
+ table_ptr m_tb;
1079
+ public:
1080
+ autoBulkinsert(table_ptr tb, int bufsize = BULKBUFSIZE):m_tb(tb)
1081
+ {
1082
+ m_tb->beginBulkInsert(bufsize);
1083
+ }
1084
+ ~autoBulkinsert(){m_tb->commitBulkInsert();}
1085
+
1086
+ };
1087
+
1088
+ }// namespace client
1089
+ }// namespace tdap
1090
+ }// namespace protocol
1091
+ }// namespace db
1092
+ }// namespace bzs
1093
+
1094
+
1095
+
1096
+ #endif