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.
- checksums.yaml +7 -0
- data/BUILD_UNIX-JA +174 -0
- data/BUILD_WIN-JA +256 -0
- data/CMakeLists.txt +96 -0
- data/COPYING +339 -0
- data/README +406 -0
- data/README-JA +424 -0
- data/bin/common/tdclc_32_1_0.dll +0 -0
- data/bin/common/tdclc_64_1_0.dll +0 -0
- data/build/common/check_for_link_iconv.cmake +73 -0
- data/build/common/copyifgreater.cmd +30 -0
- data/build/common/copyifgreater.js +290 -0
- data/build/common/get_boost_libs.cmake +106 -0
- data/build/common/get_ruby_path.cmake +115 -0
- data/build/common/options.cmake +127 -0
- data/build/common/smart_install.cmake +263 -0
- data/build/common/system.cmake +122 -0
- data/build/common/transactd.rc.in +52 -0
- data/build/common/transactd_cl_common.cmake +101 -0
- data/build/common/transactd_cl_output.cmake +93 -0
- data/build/common/transactd_common.cmake +237 -0
- data/build/common/transactd_required.cmake +28 -0
- data/build/swig/ruby/generate.cmake.in +35 -0
- data/build/swig/ruby/generate.cmd.in +19 -0
- data/build/swig/ruby/ruby.swg +101 -0
- data/build/swig/tdcl.i +188 -0
- data/build/tdclc/BUILDNUMBER.txt +1 -0
- data/build/tdclc/CMakeLists.txt +170 -0
- data/build/tdclc/tdclc_32.cbproj +181 -0
- data/build/tdclc/tdclc_64.cbproj +205 -0
- data/build/tdclcpp/BUILDNUMBER.txt +1 -0
- data/build/tdclcpp/CMakeLists.txt +142 -0
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
- data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
- data/build/tdclrb/BUILDNUMBER.txt +1 -0
- data/build/tdclrb/CMakeLists.txt +258 -0
- data/build/tdclrb/GEM_VERSION +3 -0
- data/build/tdclrb/bldgem/extconf.rb +123 -0
- data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
- data/build/tdclrb/gem/Makefile.win32-VS +65 -0
- data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
- data/build/tdclrb/gem/detect.rb +31 -0
- data/build/tdclrb/gem/helper.rb +113 -0
- data/build/tdclrb/gem/transactd.rb +22 -0
- data/build/tdclrb/gem_output.cmake +44 -0
- data/source/bzs/db/IBlobBuffer.h +51 -0
- data/source/bzs/db/blobBuffer.h +177 -0
- data/source/bzs/db/blobStructs.h +85 -0
- data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
- data/source/bzs/db/engine/mysql/bookmark.h +195 -0
- data/source/bzs/db/engine/mysql/database.cpp +1882 -0
- data/source/bzs/db/engine/mysql/database.h +465 -0
- data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
- data/source/bzs/db/engine/mysql/dbManager.h +143 -0
- data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
- data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
- data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
- data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
- data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
- data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
- data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
- data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
- data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
- data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
- data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
- data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
- data/source/bzs/db/protocol/tdap/client/client.h +292 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
- data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
- data/source/bzs/db/protocol/tdap/client/database.h +118 -0
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
- data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
- data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
- data/source/bzs/db/protocol/tdap/client/request.h +198 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
- data/source/bzs/db/protocol/tdap/client/table.h +221 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
- data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
- data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
- data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
- data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
- data/source/bzs/db/transactd/appBuilderImple.h +55 -0
- data/source/bzs/db/transactd/appModule.cpp +183 -0
- data/source/bzs/db/transactd/appModule.h +80 -0
- data/source/bzs/db/transactd/connManager.cpp +201 -0
- data/source/bzs/db/transactd/connManager.h +60 -0
- data/source/bzs/db/transactd/connectionRecord.h +69 -0
- data/source/bzs/db/transactd/transactd.cpp +325 -0
- data/source/bzs/env/compiler.h +135 -0
- data/source/bzs/env/crosscompile.cpp +130 -0
- data/source/bzs/env/crosscompile.h +150 -0
- data/source/bzs/env/fileopen.h +36 -0
- data/source/bzs/env/mbcswchrLinux.cpp +40 -0
- data/source/bzs/env/mbcswchrLinux.h +88 -0
- data/source/bzs/env/tstring.h +183 -0
- data/source/bzs/example/changeSchema.cpp +117 -0
- data/source/bzs/example/changeSchema_c.cpp +78 -0
- data/source/bzs/example/connection_pool_c.cpp +171 -0
- data/source/bzs/example/createDatabase.cpp +305 -0
- data/source/bzs/example/createDatabase_c.cpp +202 -0
- data/source/bzs/example/deleteRecords.cpp +87 -0
- data/source/bzs/example/deleteRecords_c.cpp +57 -0
- data/source/bzs/example/dropDatabase.cpp +59 -0
- data/source/bzs/example/dropDatabase_c.cpp +34 -0
- data/source/bzs/example/insertRecords.cpp +212 -0
- data/source/bzs/example/insertRecords_c.cpp +153 -0
- data/source/bzs/example/readRecords.cpp +141 -0
- data/source/bzs/example/readRecords_c.cpp +107 -0
- data/source/bzs/example/updateRecords.cpp +99 -0
- data/source/bzs/example/updateRecords_c.cpp +71 -0
- data/source/bzs/example/update_with_transaction.cpp +104 -0
- data/source/bzs/example/update_with_transaction_c.cpp +80 -0
- data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
- data/source/bzs/netsvc/client/tcpClient.h +489 -0
- data/source/bzs/netsvc/server/IAppModule.h +94 -0
- data/source/bzs/netsvc/server/iserver.h +65 -0
- data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
- data/source/bzs/netsvc/server/serverCpt.h +88 -0
- data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
- data/source/bzs/netsvc/server/serverPipe.h +96 -0
- data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
- data/source/bzs/netsvc/server/serverTpool.h +84 -0
- data/source/bzs/rtl/benchmark.cpp +96 -0
- data/source/bzs/rtl/benchmark.h +65 -0
- data/source/bzs/rtl/datetime.cpp +375 -0
- data/source/bzs/rtl/datetime.h +53 -0
- data/source/bzs/rtl/debuglog.cpp +106 -0
- data/source/bzs/rtl/debuglog.h +97 -0
- data/source/bzs/rtl/exception.h +116 -0
- data/source/bzs/rtl/stl_uty.cpp +35 -0
- data/source/bzs/rtl/stl_uty.h +29 -0
- data/source/bzs/rtl/stringBuffers.cpp +101 -0
- data/source/bzs/rtl/stringBuffers.h +58 -0
- data/source/bzs/rtl/strtrim.cpp +135 -0
- data/source/bzs/rtl/strtrim.h +46 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
- data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
- data/source/bzs/test/tdclrb/prepare.rb +226 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
- data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
- data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
- data/source/global/tdclatl/Database.cpp +503 -0
- data/source/global/tdclatl/Database.h +139 -0
- data/source/global/tdclatl/DbDef.cpp +242 -0
- data/source/global/tdclatl/DbDef.h +79 -0
- data/source/global/tdclatl/Field.cpp +92 -0
- data/source/global/tdclatl/Field.h +59 -0
- data/source/global/tdclatl/FieldDef.cpp +238 -0
- data/source/global/tdclatl/FieldDef.h +87 -0
- data/source/global/tdclatl/Flags.cpp +111 -0
- data/source/global/tdclatl/Flags.h +55 -0
- data/source/global/tdclatl/KeyDef.cpp +51 -0
- data/source/global/tdclatl/KeyDef.h +55 -0
- data/source/global/tdclatl/KeySegment.cpp +55 -0
- data/source/global/tdclatl/Table.cpp +600 -0
- data/source/global/tdclatl/Table.h +144 -0
- data/source/global/tdclatl/TableDef.cpp +291 -0
- data/source/global/tdclatl/TableDef.h +86 -0
- data/source/global/tdclatl/TdVersion.cpp +74 -0
- data/source/global/tdclatl/TdVersion.h +54 -0
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
- data/source/global/tdclatl/dllmain.cpp +30 -0
- data/source/global/tdclatl/dllmain.h +27 -0
- data/source/global/tdclatl/keySegment.h +57 -0
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/stdafx.cpp +2 -0
- data/source/global/tdclatl/stdafx.h +25 -0
- data/source/global/tdclatl/targetver.h +4 -0
- data/source/global/tdclatl/tdclatl.cpp +68 -0
- data/source/global/tdclatl/tdclatl.def +10 -0
- data/source/global/tdclatl/tdclatl.idl +1035 -0
- data/source/linux/charsetConvert.h +112 -0
- data/source/linux/linuxTypes.h +33 -0
- data/source/linux/tchar.h +428 -0
- data/transactd.gemspec +97 -0
- 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
|
+
}
|