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,116 @@
1
+ #ifndef BZS_RTL_EXCEPTION_H
2
+ #define BZS_RTL_EXCEPTION_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 <exception>
23
+ #include <string>
24
+ #if (defined(__x86_32__) && defined(__BORLANDC__))
25
+ #include <bzs/env/tstring.h>
26
+ #else
27
+ #include <boost/exception/info.hpp>
28
+ #include <boost/exception/all.hpp>
29
+
30
+ #endif
31
+
32
+ namespace bzs
33
+ {
34
+ namespace rtl
35
+ {
36
+
37
+ /** C++Builder XE 32bit can not use boost exception*/
38
+ #if (defined(__x86_32__) && defined(__BORLANDC__))
39
+
40
+ class exception : public std::exception
41
+ {
42
+ int m_error;
43
+ std::_tstring m_message;
44
+
45
+
46
+ public:
47
+ exception(int error, const std::_tstring& message): std::exception()
48
+ ,m_error(error),m_message(message){};
49
+ explicit exception(int error):std::exception(),m_error(error){};
50
+ explicit exception(const std::_tstring& message): std::exception(),m_message(message){};
51
+ const std::_tstring& getMessage(){return m_message;}
52
+ const int& getErrorCode(){return m_error;}
53
+
54
+ };
55
+
56
+
57
+ #define THROW_BZS_ERROR_WITH_CODE(code) throw bzs::rtl::exception(code)
58
+ #define THROW_BZS_ERROR_WITH_MSG(msg) throw bzs::rtl::exception(msg)
59
+ #define THROW_BZS_ERROR_WITH_CODEMSG(code, msg) throw bzs::rtl::exception(code, msg)
60
+
61
+ inline const std::_tstring* getMsg(bzs::rtl::exception &e)
62
+ {
63
+ return &(e.getMessage());
64
+ }
65
+ inline const int* getCode(bzs::rtl::exception &e)
66
+ {
67
+ return &e.getErrorCode();
68
+ }
69
+
70
+
71
+
72
+
73
+ #else // not c++builder 32bit
74
+
75
+ struct exception_base: virtual std::exception, virtual boost::exception
76
+ {
77
+ };
78
+ struct exception: virtual bzs::rtl::exception_base
79
+ {
80
+
81
+ };
82
+
83
+ #ifdef _UNICODE
84
+ typedef std::wstring message_type;
85
+ #else
86
+ typedef std::string message_type;
87
+ #endif
88
+
89
+ typedef boost::error_info<struct tagCode, int> errnoCode;
90
+ typedef boost::error_info<struct tagMsg, message_type> errMessage;
91
+
92
+
93
+
94
+ #define THROW_BZS_ERROR_WITH_CODE(code) throw bzs::rtl::exception() << bzs::rtl::errnoCode(code)
95
+ #define THROW_BZS_ERROR_WITH_MSG(msg) throw bzs::rtl::exception() << bzs::rtl::errMessage(msg)
96
+ #define THROW_BZS_ERROR_WITH_CODEMSG(code, msg) throw bzs::rtl::exception() \
97
+ << bzs::rtl::errnoCode(code) << bzs::rtl::errMessage(msg)
98
+
99
+
100
+
101
+ inline const message_type* getMsg(bzs::rtl::exception &e)
102
+ {
103
+ return boost::get_error_info<bzs::rtl::errMessage>(e);
104
+ }
105
+ inline const int* getCode(bzs::rtl::exception &e)
106
+ {
107
+ return boost::get_error_info<bzs::rtl::errnoCode>(e);
108
+ }
109
+ #endif
110
+
111
+
112
+ }//namespace rtl
113
+ }//namespace bzs
114
+
115
+ #endif //BZS_RTL_EXCEPTION_H
116
+
@@ -0,0 +1,35 @@
1
+ /*=================================================================
2
+ Copyright (C) 2000 2012 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 "stl_uty.h"
21
+
22
+ void split(std::vector<std::string>& result, const std::string& input, const std::string& delim)
23
+ {
24
+ int cutAt;
25
+ size_t start = 0;
26
+ while( (cutAt = (int)input.find(delim, start)) != (int)std::string::npos )
27
+ {
28
+ if(cutAt > 0)
29
+ result.push_back(input.substr(start, cutAt-start));
30
+ start = cutAt + delim.size();
31
+ }
32
+ if(input.length() > start)
33
+ result.push_back(input.substr(start));
34
+ }
35
+
@@ -0,0 +1,29 @@
1
+ /*=================================================================
2
+ Copyright (C) 2000 2012 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
+ #ifndef BZS_RTL_STL_UTY_H
20
+ #define BZS_RTL_STL_UTY_H
21
+
22
+
23
+ #include <vector>
24
+ #include <string>
25
+ #include <stdio.h>
26
+
27
+ void split(std::vector<std::string>& result, const std::string& input, const std::string& delim);
28
+
29
+ #endif //BZS_RTL_STL_UTY_H
@@ -0,0 +1,101 @@
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
+ #include <stdlib.h>
20
+ #pragma hdrstop
21
+
22
+ #include "stringBuffers.h"
23
+ #include <assert.h>
24
+
25
+ #pragma package(smart_init)
26
+
27
+ namespace bzs
28
+ {
29
+ namespace rtl
30
+ {
31
+
32
+ static const int MEMORY_UNIT = 8192;
33
+
34
+ stringBuffer::stringBuffer(size_t size):m_ptr(NULL),m_len(0),m_pos(0)
35
+ {
36
+ alloc(size);
37
+ }
38
+
39
+ stringBuffer::~stringBuffer()
40
+ {
41
+ if (m_ptr)
42
+ free(m_ptr);
43
+ }
44
+
45
+ void stringBuffer::clear()
46
+ {
47
+ m_pos = 0;
48
+ }
49
+
50
+ size_t stringBuffer::alloc(size_t size)
51
+ {
52
+ m_ptr = (char*)malloc(size);
53
+ if (m_ptr)
54
+ m_len = size;
55
+ m_pos = 0;
56
+ return m_len;
57
+ }
58
+
59
+ size_t stringBuffer::realloc(size_t size)
60
+ {
61
+ size = ((size / MEMORY_UNIT) + ((size % MEMORY_UNIT) ? 1:0))*MEMORY_UNIT;
62
+ m_ptr = (char*)::realloc(m_ptr, size);
63
+ if (m_ptr)
64
+ m_len = size;
65
+ return m_len;
66
+ }
67
+
68
+ char* stringBuffer::getPtrA(size_t size)
69
+ {
70
+ char* p = NULL;
71
+
72
+ if (m_pos + size > m_len)
73
+ realloc(m_pos + size + 1);
74
+ if (m_pos + size <= m_len)
75
+ {
76
+ p = m_ptr + m_pos;
77
+ m_pos += size;
78
+ m_curSize = size;
79
+ }
80
+ assert(p);
81
+ return p;
82
+ }
83
+
84
+ WCHAR* stringBuffer::getPtrW(size_t size /* charnum */)
85
+ {
86
+ WCHAR* p = NULL;
87
+ size_t sizetmp = size * sizeof(WCHAR);
88
+ if (m_pos + sizetmp > m_len)
89
+ realloc(m_pos + sizetmp + sizeof(WCHAR));
90
+ if (m_pos + sizetmp <= m_len)
91
+ {
92
+ p = (WCHAR*)(m_ptr + m_pos);
93
+ m_pos += sizetmp;
94
+ m_curSize = size;
95
+ }
96
+ assert(p);
97
+ return p;
98
+ }
99
+
100
+ }//namespace rtl
101
+ }//namespace bzs
@@ -0,0 +1,58 @@
1
+ #ifndef BZS_RTL_STRINGBUFFERS_H
2
+ #define BZS_RTL_STRINGBUFFERS_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
+ #include <bzs/env/compiler.h>
22
+ #ifdef _WIN32
23
+ #include <windows.h>
24
+ #else
25
+ #include <linuxTypes.h>
26
+ #include <typeinfo>
27
+ #endif
28
+
29
+ namespace bzs
30
+ {
31
+ namespace rtl
32
+ {
33
+
34
+ class stringBuffer
35
+ {
36
+ char* m_ptr;
37
+ size_t m_len;
38
+ size_t m_pos;
39
+ size_t m_curSize;
40
+ public:
41
+ stringBuffer(size_t size);
42
+ ~stringBuffer();
43
+ void clear();
44
+ size_t alloc(size_t size);
45
+ size_t realloc(size_t size);
46
+ char* getPtrA(size_t size);
47
+ WCHAR* getPtrW(size_t size /* charnum */);
48
+ size_t size()const{return m_curSize;}
49
+ template <class T> T* getPtr(size_t size){};
50
+ };
51
+
52
+ template <> inline WCHAR* stringBuffer::getPtr<WCHAR>(size_t size){return getPtrW(size);};
53
+ template <> inline char* stringBuffer::getPtr<char>(size_t size){return getPtrA(size);};
54
+
55
+ }//namespace rtl
56
+ }//namespace bzs
57
+
58
+ #endif //BZS_RTL_STRINGBUFFERS_H
@@ -0,0 +1,135 @@
1
+ /*=================================================================
2
+ Copyright (C) 2000 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
+ #include<bzs/env/tstring.h>
20
+ #pragma hdrstop
21
+
22
+ #include "strtrim.h"
23
+
24
+ #pragma package(smart_init)
25
+
26
+ namespace bzs
27
+ {
28
+ namespace rtl
29
+ {
30
+
31
+ char* strtrimA(char* str)
32
+ { //trim right space
33
+ if (str == NULL)
34
+ return NULL;
35
+ int k = (int)strlen(str) - 1;
36
+
37
+ for(; k >= 0; --k)
38
+ {
39
+ if (str[k] == 0x20)
40
+ str[k] = 0x00;
41
+ else
42
+ break;
43
+ }
44
+ return str;
45
+ }
46
+
47
+ wchar_t* wcstrim(wchar_t* str)
48
+ {
49
+ //trim right space
50
+ if (str == NULL)
51
+ return NULL;
52
+ int k = (int)wcslen(str) - 1;
53
+
54
+ for(; k >= 0; k--)
55
+ {
56
+ if (str[k] == 0x20)
57
+ str[k] = 0x00;
58
+ else
59
+ break;
60
+ }
61
+ return str;
62
+ }
63
+
64
+ char* strltrimA(char* str)
65
+ { //trim left space
66
+ if (str == NULL)
67
+ return NULL;
68
+
69
+ size_t i;
70
+ char* point = NULL;
71
+ size_t len = strlen(str);
72
+ for(i = 0; i < len; i++)
73
+ {
74
+ if (str[i] == 0x20)
75
+ point = str + i + 1;
76
+ else
77
+ break;
78
+ }
79
+ if (point)
80
+ memmove(str, point, len - i + 1);
81
+ return str;
82
+ }
83
+
84
+ wchar_t* wcsltrim(wchar_t* str)
85
+ { //trim left space
86
+ if (str == NULL)
87
+ return NULL;
88
+
89
+ size_t i;
90
+ wchar_t* point = NULL;
91
+ size_t len = wcslen(str);
92
+ for(i = 0; i < len; i++)
93
+ {
94
+ if (str[i] == 0x20)
95
+ point = str + i + 1;
96
+ else
97
+ break;
98
+ }
99
+ if (point)
100
+ memmove(str, point, (len - i + 1)*sizeof(wchar_t));
101
+ return str;
102
+ }
103
+
104
+ #ifdef _UNICODE
105
+ int wcslen_a(wchar_t* str)
106
+ { //How meny charctors of multibyte charctor.
107
+ int retVale = 0;
108
+ size_t len = wcslen(str);
109
+ if (len)
110
+ {
111
+ LPWORD charType = new WORD[len + 1];
112
+ if (GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE3 , str, -1, charType))
113
+ {
114
+ for (size_t i=0;i<len;i++)
115
+ { //If Zenkaku_katakana or Hiragana then return not Zenkaku. Kanji is C3_IDEOGRAPH.
116
+ if (!(charType[i] & C3_HALFWIDTH)
117
+ && ( (charType[i] & C3_KATAKANA)
118
+ || (charType[i] & C3_HIRAGANA)
119
+ || (charType[i] & C3_FULLWIDTH)
120
+ || (charType[i] & C3_IDEOGRAPH)
121
+ || (charType[i] & C3_SYMBOL)))
122
+ retVale += 2;
123
+ else
124
+ retVale += 1;
125
+ }
126
+ }
127
+ delete []charType;
128
+ }
129
+ return retVale;
130
+ }
131
+ #endif
132
+
133
+ }//namespace rtl
134
+ }//namespace bzs
135
+
@@ -0,0 +1,46 @@
1
+ #ifndef BZS_RTL_STRTRIM_H
2
+ #define BZS_RTL_STRTRIM_H
3
+ /*=================================================================
4
+ Copyright (C) 2000 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/env/compiler.h>
22
+ namespace bzs
23
+ {
24
+ namespace rtl
25
+ {
26
+
27
+ PACKAGE char* strtrimA(char* str);
28
+ PACKAGE wchar_t* wcstrim(wchar_t* str);
29
+ PACKAGE char* strltrimA(char* str);
30
+ PACKAGE wchar_t* wcsltrim(wchar_t* str);
31
+ #ifdef _UNICODE
32
+ PACKAGE int wcslen_a(wchar_t* str); //half charctor length
33
+
34
+ #define strtrim wcstrim
35
+ #define strltrim wcsltrim
36
+ #else
37
+ #define strtrim strtrimA
38
+ #define strltrim strltrimA
39
+ #endif
40
+
41
+ }//namespace rtl
42
+ }//namespace bzs
43
+
44
+
45
+ #endif//BZS_RTL_STRTRIM_H
46
+