全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 ページ
database.h
1 #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_DATABASE_H
2 #define BZS_DB_PROTOCOL_TDAP_CLIENT_DATABASE_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 "nsDatabase.h"
22 
23 namespace bzs
24 {
25 namespace db
26 {
27 namespace protocol
28 {
29 namespace tdap
30 {
31 namespace client
32 {
33 
34 class database;
35 class table;
36 class dbdef;
37 
38 #if (defined(__BORLANDC__) && !defined(__APPLE__) && !defined(__clang__))
39 typedef bool __stdcall (*deleteRecordFn)(database* db, table* tb, bool inkey);
40 typedef short __stdcall (*schemaMgrFn)(database* db);
41 typedef void __stdcall (*copyDataFn)(database* db, table* tb, int recordCount, int count,
42  bool& cancel);
43 #else
44 /** @cond INTERNAL */
45 /** Callback function on a record was deleted. */
46 typedef bool(__STDCALL* deleteRecordFn)(database* db, table* tb, bool inkey);
47 /** @endcond */
48 
49 /** Callback function on a database is opening by database::open operation.
50  This is use for change a table schema and table data at before database
51  */
52 typedef short(__STDCALL* schemaMgrFn)(database* db);
53 
54 /** Callback function on a record was copied by convert table operation. */
55 typedef void(__STDCALL* copyDataFn)(database* db, table* tb, int recordCount, int count,
56  bool& cancel);
57 #endif
58 
59 class DLLLIB database : public nsdatabase
60 {
61  friend struct openTablePrams;
62  struct dbimple* m_impl;
63 
64  void setDir(const _TCHAR* directory);
65  virtual table* createTableObject();
66  bool defaultImageCopy(const void* data, short& tableIndex);
67  short checkOpened();
68  table* doOpenTable(struct openTablePrams* pm, const _TCHAR* ownerName);
69  void* getExtendBufferForOpen(uint_td& size); // orverride
70  _TCHAR* getTableUri(_TCHAR* buf, short fileNum);
71  _TCHAR* getTableUri(_TCHAR* buf, const _TCHAR* filename);
72  inline void copyEachFieldData(table* dest, table* src, struct fieldChnageInfo* fci);
73 
74 
75 protected:
76  database& operator=(const database&);
77  database();
78  virtual ~database();
79  void setLockReadOnly(bool v);
80  virtual void doClose();
81  virtual void doOpen(const _TCHAR* uri, short type, short mode,
82  const _TCHAR* username);
83 
84  virtual bool onOpenAfter() { return true; };
85 
86  virtual bool onTableOpened(table* tb, short fileNum, short mode,
87  bool isCreated) {return true;}
88  virtual char* getContinuousList(int option);
89  virtual void onCopyDataInternal(table* tb, int recordCount, int count,
90  bool& cancel);
91  virtual void doConvertTable(short tableIndex, bool turbo,
92  const _TCHAR* ownerName);
93  virtual bool doReopenDatabaseSchema();
94 
95 public:
96  virtual void release();
97  dbdef* dbDef() const;
98  const _TCHAR* rootDir() const;
99  void setRootDir(const _TCHAR* directory);
100  void* optionalData() const;
101  void setOptionalData(void* v);
102  bool tableReadOnly() const;
103  void setTableReadOnly(bool value);
104  const deleteRecordFn onDeleteRecord() const;
105  void setOnDeleteRecord(const deleteRecordFn v);
106  const copyDataFn onCopyData() const;
107  void setOnCopyData(const copyDataFn v);
108  bool open(const _TCHAR* uri, short schemaType = 0, short mode = -2,
109  const _TCHAR* dir = NULL, const _TCHAR* ownerName = NULL);
110  table* openTable(short fileNum, short mode = TD_OPEN_NORMAL,
111  bool autoCreate = true, const _TCHAR* ownerName = NULL,
112  const _TCHAR* uri = NULL);
113  table* openTable(const _TCHAR* tableName, short mode = 0,
114  bool autoCreate = true, const _TCHAR* ownerName = NULL,
115  const _TCHAR* uri = NULL);
116  database* clone();
117  bool createTable(const char* utf8Sql);
118  bool createTable(short fileNum, const _TCHAR* uri = NULL);
119  char* getSqlStringForCreateTable(const _TCHAR* tableName, char* retbuf, uint_td* size);
120  void create(const _TCHAR* uri, short type = TYPE_SCHEMA_BDF);
121  void drop(const _TCHAR* uri=NULL);
122  void dropTable(const _TCHAR* tableName);
123  void close(bool withDropDefaultSchema = false);
124  short aclReload();
125  short continuous(char_td op = TD_BACKUP_START, bool inclideRepfile = false);
126  short assignSchemaData(const dbdef* src);
127  short copyTableData(table* dest, table* src, bool turbo,
128  short keyNum = -1, int maxSkip = -1);
129  void convertTable(short tableIndex, bool turbo,
130  const _TCHAR* ownerName = NULL);
131  bool existsTableFile(short tableIndex, const _TCHAR* ownerName = NULL);
132  void getBtrVersion(btrVersions* versions);
133  bool isOpened() const; // orverride
134  char_td mode() const;
135  bool autoSchemaUseNullkey() const;
136  void setAutoSchemaUseNullkey(bool v);
137  database* createAssociate();
138  virtual int defaultAutoIncSpace() const { return 0; };
139  inline bool execSql(const char* utf8Sql){return createTable(utf8Sql);}
140 
141  static database* create();
142  /* For C++ direct only. don't use by wrapper class for COM or SWIG
143  This method is ignore refarence count of nsdatabse.
144  */
145  static void destroy(database* db);
146  static void setCompatibleMode(int mode);
147  static int compatibleMode();
148  static const int CMP_MODE_OLD_NULL = 0;
149  static const int CMP_MODE_MYSQL_NULL = 1; //default
150  static const int CMP_MODE_BINFD_DEFAULT_STR = 2;
151  static const int CMP_MODE_OLD_ALL = 2;
152  static const int CMP_MODE_OLD_BIN = 3;
153 };
154 
155 
156 
158 {
159  int mode;
160 public:
162  {
163  mode = database::compatibleMode();
165  }
167  {
169  }
170 };
171 
172 } // namespace client
173 } // namespace tdap
174 } // namespace protocol
175 } // namespace db
176 } // namespace bzs
177 
178 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_DATABASE_H
データベースアクセス基本クラス (nocopyable)
Definition: nsDatabase.h:85
virtual bool onOpenAfter()
Definition: database.h:84
バージョン配列構造体
Definition: tdapSchema.h:1324
void(__STDCALL * copyDataFn)(database *db, table *tb, int recordCount, int count, bool &cancel)
Definition: database.h:55
テーブルスキーマ管理クラス (nocopyable noncreatable)
Definition: dbDef.h:46
テーブルアクセスクラス (nocopyable)
Definition: table.h:91
void dropTable(Database_Ptr db, const _TCHAR *name)
Definition: trdboostapi.h:952
グルーピング レコード数カウンター
Definition: groupQuery.h:287
table_ptr openTable(Database_Ptr db, const _TCHAR *name, short mode=TD_OPEN_NORMAL, bool autoCreate=true, const _TCHAR *ownerName=NULL, const _TCHAR *uri=NULL)
Definition: trdboostapi.h:920
virtual int defaultAutoIncSpace() const
Definition: database.h:138
bool execSql(const char *utf8Sql)
Definition: database.h:139
データベースアクセスクラス
Definition: database.h:59
void convertTable(Database_Ptr db, short tableid, copyDataFn func=NULL)
Definition: trdboostapi.h:961
typedef short(__STDCALL *schemaMgrFn)(database *db)
virtual bool onTableOpened(table *tb, short fileNum, short mode, bool isCreated)
Definition: database.h:86
overrideCompatibleMode(int v)
Definition: database.h:161

Transactd SDK 2018年07月31日(火) 19時40分20秒 doxygen