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,150 @@
1
+ #ifndef BZS_ENV_CROSSCOMPILE_H
2
+ #define BZS_ENV_CROSSCOMPILE_H
3
+ /*=================================================================
4
+ Copyright (C) 2012 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
+ #if (defined(__FreeBSD__) || defined(__APPLE__))
22
+ #ifndef LINUX
23
+ #define LINUX
24
+ #endif
25
+ #endif
26
+
27
+ #if __MINGW32__ && ( (defined(__GNUC__) && __GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ <= 5) )
28
+ #define sprintf_s snprintf
29
+ #define swprintf_s swprintf
30
+ #define _mbsstr strstr
31
+ #define strcpy_s(A,B,C) strcpy(A,C)
32
+ #define strncpy_s(A,B,C,D) strncpy(A,C,D)
33
+ #ifdef _UNICODE
34
+ #define _stprintf_s swprintf_s
35
+ #define _tcscpy_s wcscpy_s
36
+ typedef wchar_t _TUCHAR;
37
+ #else
38
+ #define _stprintf_s snprintf
39
+ #define _tcscpy_s strcpy_s
40
+ typedef char _TUCHAR;
41
+ #endif
42
+ #endif
43
+
44
+ #if (defined(LINUX))
45
+ #include <ctype.h>
46
+ #include <stddef.h>
47
+ #include <linuxTypes.h>
48
+ /* c c++ runtime library */
49
+ #define _strnicmp strncasecmp
50
+ #define __int64 long long int
51
+ #define _atoi64 atoll
52
+ #define _wtoi(W) wcstol(W, NULL, 10)
53
+ #define _access access
54
+ #define sprintf_s snprintf
55
+ #define swprintf_s swprintf
56
+ #define localtime_s localtime_r
57
+ #define strncpy_s(A,B,C,D) strncpy(A,C,D)
58
+ #define strcpy_s(A,B,C) strcpy(A,C)
59
+ #define strcat_s(A,B,C) strcat(A,C)
60
+ #define _strlwr_s(A,B) _strlwr(A)
61
+ #define _timezone timezone
62
+
63
+ /*if on linux that cannot use multi byte char for meta data.*/
64
+ #define _mbsstr strstr
65
+ #define _mbsupr _strupr
66
+ #define _mbsrchr strrchr
67
+ #define _wcsupr _strupr16
68
+ #define _wcslwr _strlwr16
69
+
70
+ char* _strupr(char* s);
71
+ char* _strlwr(char* s);
72
+ char* _ltoa_s(int v, char* tmp, unsigned long size, int radix);
73
+ char* _i64toa_s(__int64 v, char* tmp, unsigned long size, int radix);
74
+ char16_t* _strupr16(char16_t* s);
75
+ char16_t* _strlwr16(char16_t* s);
76
+ size_t strlen16(const char16_t* src);
77
+ int wcsnicmp16(const char16_t *sl, const char16_t *sr, size_t n);
78
+ int wcsncmp16(const char16_t *sl, const char16_t *sr, size_t n);
79
+ char16_t* wmemset16(char16_t* p , char16_t c, size_t n);
80
+ char16_t* wmemcpy(char16_t* dest, const char16_t* src, size_t count);
81
+
82
+ /* operating system */
83
+ #ifndef _TCHAR
84
+ #define _TCHAR char
85
+ #endif
86
+ #ifndef _T
87
+ #define _T(A) A
88
+ #endif
89
+
90
+ #define PSEPARATOR _T("/")
91
+ #define PSEPARATOR_A "/"
92
+ #define PSEPARATOR_C '/'
93
+ typedef int HWND;
94
+ #define MAX_PATH 266
95
+ #define MCRTOMM 1000 //for usleep(��sec) to Sleep(msec)
96
+ #define Sleep usleep
97
+ #define LoadLibrary(A) dlopen(A, RTLD_LAZY)
98
+ #define LoadLibraryA(A) dlopen(A, RTLD_LAZY)
99
+ #define GetProcAddress(A, B) dlsym(A, B)
100
+ #define FreeLibrary(A) dlclose(A)
101
+ #define OutputDebugString(A)
102
+
103
+ /* muliti byete char */
104
+ typedef char mbchar;
105
+ typedef char char_m;
106
+
107
+ #else //!defined(LINUX)
108
+
109
+ #ifdef __MINGW32__
110
+ #define _ttof atof
111
+ #endif
112
+
113
+ /* c c++ runtime library */
114
+ #include <tchar.h>
115
+ #if defined(__BORLANDC__) || defined(__MINGW32__)
116
+ #define _ltow_s(A,B,C,D) _ltow(A, B, D)
117
+ #define _ltoa_s(A,B,C,D) _ltoa(A, B, D)
118
+ #define _ltot_s(A,B,C,D) _ltot(A,B,D)
119
+ #define _i64tow_s(A,B,C,D) _i64tow(A, B, D)
120
+ #define _i64toa_s(A,B,C,D) _i64toa(A, B, D)
121
+ #define _strlwr_s(A, B) strlwr(A)
122
+ #endif
123
+ #define wcsnicmp16(A, B, C) _wcsnicmp((const wchar_t*)(A), (const wchar_t*)(B) , C)
124
+ #define wcsncmp16(A, B, C) wcsncmp((const wchar_t*)(A), (const wchar_t*)(B) , C)
125
+ #define wmemset16 wmemset
126
+ #define strlen16 wcslen
127
+
128
+ /* operating system */
129
+ #define MCRTOMM 1
130
+ #define PSEPARATOR _T("\\")
131
+ #define PSEPARATOR_A "\\"
132
+ #define PSEPARATOR_C '\\'
133
+
134
+
135
+ /* muliti byete char */
136
+ typedef unsigned char mbchar;
137
+ typedef unsigned char char_m;
138
+
139
+ #endif//defined(LINUX)
140
+
141
+
142
+ #if (defined(__BORLANDC__) || defined(LINUX))
143
+ #define localtime_x(_tm, time) localtime_s(time, _tm)
144
+ #else //!__BORLANDC__
145
+ #define localtime_x(_tm, time) (localtime_s(_tm, time)==0)
146
+ #endif//__BORLANDC__
147
+
148
+
149
+
150
+ #endif //BZS_ENV_CROSSCOMPILE_H
@@ -0,0 +1,36 @@
1
+ #ifndef BZS_ENV_FILEOPEN_H
2
+ #define BZS_ENV_FILEOPEN_H
3
+ /*=================================================================
4
+ Copyright (C) 2012 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
+ #include <stdio.h>
23
+
24
+ inline FILE* fileOpen(const char* filename, const char* flag)
25
+ {
26
+ FILE* fp;
27
+ #ifdef LINUX
28
+ fp = fopen(filename, flag);
29
+ #else
30
+ fopen_s(&fp, filename, flag);
31
+ #endif
32
+ return fp;
33
+ }
34
+
35
+
36
+ #endif //BZS_ENV_FILEOPEN_H
@@ -0,0 +1,40 @@
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 "mbcswchrLinux.h"
21
+ #include <stdio.h>
22
+
23
+
24
+
25
+ namespace bzs
26
+ {
27
+ namespace env
28
+ {
29
+ cvt mbcscvt("UTF-16LE", MBC_CHARSETNAME);
30
+ cvt wchrcvt(MBC_CHARSETNAME, "UTF-16LE");
31
+ cvt u8mbcvt(MBC_CHARSETNAME, UTF8_CHARSETNAME);
32
+ cvt mbu8cvt(UTF8_CHARSETNAME, MBC_CHARSETNAME);
33
+ cvt u8wccvt("UTF-16LE", UTF8_CHARSETNAME);
34
+ cvt wcu8cvt(UTF8_CHARSETNAME, "UTF-16LE");
35
+
36
+
37
+ }//namespace env
38
+ }//namespace bzs
39
+
40
+
@@ -0,0 +1,88 @@
1
+ #ifndef BZS_ENV_MBCSWCHRLINUX_H
2
+ #define BZS_ENV_MBCSWCHRLINUX_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
+ #include <charsetConvert.h>
23
+
24
+ #define CP_UTF8 65001
25
+ #define CP_ACP CP_UTF8
26
+ #define GetACP() CP_ACP
27
+
28
+ #define MBC_CHARSETNAME "SHIFT-JIS"// mbc charctor set
29
+ #define UTF8_CHARSETNAME "UTF-8"
30
+
31
+ namespace bzs
32
+ {
33
+ namespace env
34
+ {
35
+ extern cvt u8mbcvt;// utf8 to mbc
36
+ extern cvt mbu8cvt;// mbc to utf8
37
+ extern cvt mbcscvt;// mbc to utf16le
38
+ extern cvt wchrcvt;// utf16le to mbc
39
+ extern cvt u8wccvt;// utf8 to utf16le
40
+ extern cvt wcu8cvt;// utf16le to utf8
41
+
42
+
43
+ inline int WideCharToMultiByte(unsigned int codepage, unsigned int dwFlags
44
+ , const char16_t* lpWideCharStr,int cchWideChar
45
+ , char* lpMultiByteStr, int cchMultiByte
46
+ , const char* lpDefaultChar, int* lpUsedDefaultChar)
47
+ {
48
+ if (codepage == CP_UTF8)
49
+ return wcu8cvt.conv(lpWideCharStr, (size_t)(cchWideChar + cchWideChar), lpMultiByteStr, (size_t)cchMultiByte);
50
+ return wchrcvt.conv(lpWideCharStr, (size_t)(cchWideChar + cchWideChar), lpMultiByteStr, (size_t)cchMultiByte);
51
+ }
52
+
53
+ inline int MultiByteToWideChar(unsigned int codepage, unsigned int dwFlags, const char* lpMultiByteStr
54
+ ,int cchMultiByte, char16_t* lpWideCharStr, int cchWideChar)
55
+ {
56
+ if (codepage == CP_UTF8)
57
+ return u8wccvt.conv(lpMultiByteStr, (size_t)cchMultiByte, lpWideCharStr, (size_t)(cchWideChar + cchWideChar));
58
+ return mbcscvt.conv(lpMultiByteStr, (size_t)cchMultiByte, lpWideCharStr, (size_t)(cchWideChar + cchWideChar));
59
+ }
60
+
61
+ inline int u8tombc(const char* u8, int u8size, char* mbc, int mbcsize)
62
+ {
63
+ return u8mbcvt.conv(u8, (size_t)u8size, mbc, (size_t)mbcsize);
64
+ }
65
+
66
+ inline int mbctou8(const char* mbc, int mbcsize, char* u8, int u8size)
67
+ {
68
+ return mbu8cvt.conv(mbc, (size_t)mbcsize, u8, (size_t)u8size);
69
+ }
70
+
71
+
72
+ }//namespace env
73
+ }//namespace bzs
74
+
75
+ //Definition dummy
76
+ #define MB_PRECOMPOSED 0
77
+ #define WC_COMPOSITECHECK 0
78
+
79
+ using bzs::env::WideCharToMultiByte;
80
+ using bzs::env::MultiByteToWideChar;
81
+
82
+ // Surrogate support
83
+ #if !defined IS_HIGH_SURROGATE
84
+ #define IS_HIGH_SURROGATE(t) ((t >= 0xD800) && (t <= 0xDBEF))
85
+ #endif
86
+
87
+
88
+ #endif //BZS_ENV_MBCSWCHRLINUX_H
@@ -0,0 +1,183 @@
1
+ #ifndef BZS_ENV_TSTRING_H
2
+ #define BZS_ENV_TSTRING_H
3
+ /*=================================================================
4
+ Copyright (C) 2006 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
+ #ifndef __TSTRING_H //old tstring.h is used
23
+
24
+ #include <string.h>
25
+ #include <string>
26
+ #ifdef _WIN32
27
+ #include <mbstring.h>
28
+ #endif
29
+
30
+ #include <tchar.h>
31
+ #ifdef _WIN32
32
+ #include <windows.h>
33
+ #endif
34
+ #ifdef LINUX
35
+ #include <bzs/env/mbcswchrLinux.h>
36
+ #endif
37
+
38
+
39
+ namespace std {
40
+ #ifdef _UNICODE
41
+ typedef wstring _tstring;
42
+
43
+ #else
44
+ typedef string _tstring;
45
+
46
+ #endif
47
+ } //std
48
+
49
+
50
+ #ifdef _UNICODE
51
+ #define tPos Pos
52
+ #define tcout wcout
53
+ #else
54
+ #define tPos AnsiPos
55
+ #define tcout cout
56
+ #endif
57
+
58
+
59
+ #ifdef _UNICODE
60
+ #define _tcsmcmp _tcscmp
61
+ #define _tcsmclen _tcsclen
62
+ #define _tcsmnextc _tcsnextc
63
+ #define _tcsmrchr _tcsrchr
64
+ #define _tcsmstr _tcsstr
65
+ #define _tcsmupr _tcsupr
66
+
67
+ typedef char _NTCHAR;
68
+ #else
69
+ #define _tcsmcmp _mbscmp
70
+ #define _tcsmclen _mbslen
71
+ #define _tcsmnextc _mbsnextc
72
+ #define _tcsmrchr _mbsrchr
73
+ #define _tcsmstr _mbsstr
74
+ #define _tcsmupr _mbsupr
75
+ typedef wchar_t _NTCHAR;
76
+ #endif
77
+
78
+ #define __BEGIN_NO_TCHAR_CONVERT__
79
+ #define __END_NO_TCHAR_CONVERT__
80
+
81
+
82
+ inline const char* toChar(char* buf, const _TCHAR* w, int size)
83
+ { //If w becomes in Ansi, a pointer will be returned without doing anything.
84
+ #ifdef _UNICODE
85
+ WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, w, -1, buf, size, NULL, NULL);
86
+ return buf;
87
+ #else
88
+ return w;
89
+ #endif
90
+ }
91
+
92
+ inline const char* wtoa(char* buf, const WCHAR* w, int size)
93
+ {
94
+ WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, w, -1, buf, size, NULL, NULL);
95
+ return buf;
96
+ }
97
+
98
+ inline const WCHAR* toWChar(WCHAR* buf, const _TCHAR* w, int size)
99
+ {//If w becomes in WCHAR, a pointer will be returned without doing anything.
100
+ #ifdef _UNICODE
101
+ return w;
102
+ #else
103
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, w, -1, buf, size);
104
+ return buf;
105
+ #endif
106
+ }
107
+
108
+
109
+ #ifdef _UNICODE
110
+ inline const WCHAR* toWChar(WCHAR* buf, const char* a, int size)
111
+ {
112
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, a, -1, buf, size);
113
+ return buf;
114
+ }
115
+ #endif
116
+
117
+ inline const WCHAR* toWChar_n(WCHAR* buf, const char* a, int size)
118
+ {
119
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, a, size, buf, size);
120
+ return buf;
121
+ }
122
+
123
+ inline const _TCHAR* toTChar(_TCHAR* t, const WCHAR* w, int size)
124
+ {
125
+ #ifdef _UNICODE
126
+ return w;
127
+ #else
128
+ WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, w, -1, t, size, NULL, NULL);
129
+ return t;
130
+ #endif
131
+ }
132
+
133
+ inline const _TCHAR* toTCharCopy(_TCHAR* t, const WCHAR* w, int size)
134
+ { //It returns, after certainly copying, even if w is _TCHAR.
135
+ #ifdef _UNICODE
136
+ _tcscpy_s(t, size, w);
137
+ return t;
138
+ #else
139
+ WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, w, -1, t, size, NULL, NULL);
140
+ return t;
141
+
142
+ #endif
143
+ }
144
+
145
+ #pragma warning(disable:4996)
146
+ inline const char* toCharCpy(char* buf, const _TCHAR* w, int size)
147
+ {
148
+ #ifdef _UNICODE
149
+ WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, w, -1, buf, size, NULL, NULL);
150
+ return buf;
151
+ #else
152
+ strncpy(buf, w, size);
153
+ return buf;
154
+ #endif
155
+ }
156
+ #pragma warning(default:4996)
157
+
158
+ inline const _TCHAR* toTChar(_TCHAR* t, const char* a, int size)
159
+ {
160
+ #ifdef _UNICODE
161
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, a, -1, t, size);
162
+ return t;
163
+ #else
164
+ return a;
165
+ #endif
166
+ }
167
+
168
+ #pragma warning(disable:4996)
169
+ inline const _TCHAR* toTCharCopy(_TCHAR* t, const char* a, int size)
170
+ {
171
+ #ifdef _UNICODE
172
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, a, -1, t, size);
173
+ return t;
174
+ #else
175
+ _tcsncpy(t, a, size);
176
+ return t;
177
+ #endif
178
+ }
179
+ #pragma warning(default:4996)
180
+
181
+
182
+ #endif //__TSTRING_H
183
+ #endif //BZS_ENV_TSTRING_H
@@ -0,0 +1,117 @@
1
+ #include <stdio.h>
2
+ #include <bzs/db/protocol/tdap/client/database.h>
3
+ #include <bzs/db/protocol/tdap/client/table.h>
4
+ #include <bzs/db/protocol/tdap/client/dbdef.h>
5
+ #include <boost/bind.hpp>
6
+ using namespace bzs::db::protocol::tdap::client;
7
+ using namespace bzs::db::protocol::tdap;
8
+
9
+
10
+ /** @brief change schema and convert table example
11
+
12
+ This program change "user" table.
13
+ The "name" field is made into 64 characters from 32 characters.
14
+ And add The "tel" field.
15
+
16
+ Please execute the "create database" example before execute this example.
17
+
18
+ */
19
+
20
+ static const short tablenum_user = 1;
21
+ static const short fieldnum_name = 1;
22
+
23
+
24
+ /** show database operation error
25
+ */
26
+ void showError(const _TCHAR* caption,const _TCHAR* tableName, short statusCode)
27
+ {
28
+ _TCHAR tmp[1024]={0x00};
29
+ nstable::tdapErr(0x00, statusCode, tableName, tmp);
30
+ _tprintf(_T("%s error No.%ld %s\n"),caption, statusCode, tmp);
31
+ }
32
+
33
+ /** Change user table schema
34
+ */
35
+ bool changeUserTable(dbdef* def)
36
+ {
37
+
38
+ //change name size
39
+ tabledef* td = def->tableDefs(tablenum_user);
40
+ fielddef* fd = &td->fieldDefs[fieldnum_name];
41
+ fd->setLenByCharnum(64);
42
+
43
+ //add tel field
44
+ fd = def->insertField(td->id, td->fieldCount);
45
+ fd->setName(_T("tel"));
46
+ fd->type = ft_mychar;
47
+ fd->setCharsetIndex( CHARSET_LATIN1);
48
+ fd->setLenByCharnum(16);
49
+
50
+ //write user table schema
51
+ def->updateTableDef(td->id);
52
+ if (def->stat() != 0)
53
+ {
54
+ showError(_T("edit schema table"), NULL, def->stat());
55
+ return false;
56
+ }
57
+ return true;
58
+ }
59
+
60
+ /** Open database
61
+ */
62
+ bool openDbExclusive(database* db, const _TCHAR* uri)
63
+ {
64
+ db->open(uri, TYPE_SCHEMA_BDF, TD_OPEN_EXCLUSIVE);
65
+ if (db->stat() != 0)
66
+ {
67
+ showError(_T("open daatabase"), NULL, db->stat());
68
+ return false;
69
+ }
70
+ return true;
71
+ }
72
+
73
+ void __stdcall onCopyData(database* db, int recordCount, int count, bool &cancel)
74
+ {
75
+ if (count == 0)
76
+ _tprintf(_T("\n"));
77
+ _tprintf(_T("."));
78
+
79
+ }
80
+
81
+ #pragma argsused
82
+ int _tmain(int argc, _TCHAR* argv[])
83
+ {
84
+ int result = 0;
85
+ static const _TCHAR* uri = _T("tdap://localhost/test?dbfile=test.bdf");
86
+ database* db = database::create();
87
+
88
+ if (openDbExclusive(db, uri))
89
+ {
90
+ //backup current user table schema
91
+ db->dbDef()->pushBackup(tablenum_user);
92
+
93
+ if (changeUserTable(db->dbDef()))
94
+ {
95
+ //convert table if table exist;
96
+ if (db->existsTableFile(tablenum_user, NULL))
97
+ {
98
+ db->setOnCopyData(onCopyData);
99
+
100
+ db->convertTable(tablenum_user, false, NULL);
101
+ if (db->stat())
102
+ showError(_T("convert table"), NULL, db->stat());
103
+ }
104
+ }
105
+
106
+ if (db->stat())
107
+ {
108
+ result = db->stat();
109
+ //restore user table schema
110
+ db->dbDef()->popBackup(tablenum_user);
111
+ }else
112
+ _tprintf(_T("\nchage table success. \n"));
113
+ db->close();
114
+ }
115
+ database::destroy(db);
116
+ return result;
117
+ }
@@ -0,0 +1,78 @@
1
+ #include <bzs/db/protocol/tdap/client/trdboostapi.h>
2
+ #include <iostream>
3
+ using namespace bzs::db::protocol::tdap::client;
4
+ using namespace bzs::db::protocol::tdap;
5
+
6
+
7
+ /**
8
+ @brief change schema and convert table example
9
+
10
+ This program change "user" table.
11
+ The "name" field is made into 64 characters from 32 characters.
12
+ And add The "tel" field.
13
+
14
+ Please execute the "create database" example before execute this example.
15
+
16
+ */
17
+
18
+ static const short tablenum_user = 1;
19
+ static const short fieldnum_name = 1;
20
+
21
+
22
+
23
+ /** Change user table schema
24
+ */
25
+ void changeUserTable(dbdef* def)
26
+ {
27
+ //change name size
28
+ tabledef* td = def->tableDefs(tablenum_user);
29
+ fielddef* fd = &td->fieldDefs[fieldnum_name];
30
+ fd->setLenByCharnum(64);
31
+
32
+ //add tel field
33
+ int size = lenByCharnum(ft_mychar, CHARSET_LATIN1, 16);
34
+ fd = insertField(def, td->id, td->fieldCount, _T("tel"), ft_mychar, size);
35
+ fd->setCharsetIndex(CHARSET_LATIN1);
36
+
37
+ //write user table schema
38
+ updateTableDef(def, td->id);
39
+ }
40
+
41
+ void __stdcall onCopyData(database* db, int recordCount, int count, bool &cancel)
42
+ {
43
+ if (count == 0)
44
+ std::cout << std::endl;
45
+ std::cout << "." ;
46
+
47
+ }
48
+
49
+ #pragma argsused
50
+ int _tmain(int argc, _TCHAR* argv[])
51
+ {
52
+ database_ptr db = createDatadaseObject();
53
+ try
54
+ {
55
+ connectParams prams(_T("tdap"), _T("localhost"), _T("test"), _T("test"));
56
+ prams.setMode(TD_OPEN_EXCLUSIVE);
57
+
58
+ openDatabase(db, prams);
59
+
60
+ //backup current user table schema
61
+ db->dbDef()->pushBackup(tablenum_user);
62
+
63
+ changeUserTable(db->dbDef());
64
+
65
+ //convert table
66
+ //If an error ouccered then restore the table schema automaticaly.
67
+ convertTable(db, _T("user"), onCopyData);
68
+
69
+ std::cout << "change databse success." << std::endl;
70
+ return 0;
71
+ }
72
+
73
+ catch(bzs::rtl::exception& e)
74
+ {
75
+ std::tcout << *bzs::rtl::getMsg(e) << std::endl;
76
+ }
77
+ return 1;
78
+ }