全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 ページ
serializer.h
1 #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_SERIALIZEER_H
2 #define BZS_DB_PROTOCOL_TDAP_CLIENT_SERIALIZEER_H
3 /*=================================================================
4  Copyright (C) 2014 BizStation Corp All rights reserved.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19  02111-1307, USA.
20 =================================================================*/
21 #include <bzs/db/protocol/tdap/client/activeTable.h>
22 #include <sstream>
23 
24 #ifdef LIB_TDCLSTMT
25 #define DLLLIBSTMT AGRPACK
26 #else
27 #ifdef BCB_32
28 #define DLLLIBSTMT AGRPACK
29 #else
30 #define DLLLIBSTMT // PACKAGE_IMPORT
31 #endif
32 #endif // LIB_TDCLSTMT
33 
34 #if (defined(TRDCL_AUTOLINK) && !defined(LIB_TDCLSTMT))
35 #include "trdclcppautolink.h"
36 #define TD_STMT_LIB_NAME \
37  LIB_PREFIX "tdclstmt" CPP_INTERFACE_VERSTR SHARED_LIB_EXTENTION
38 #pragma comment(lib, TD_STMT_LIB_NAME)
39 #endif // TRDCL_AUTOLINK
40 
41 namespace bzs
42 {
43 namespace db
44 {
45 namespace protocol
46 {
47 namespace tdap
48 {
49 namespace client
50 {
51 /** @cond INTERNAL */
52 #define ID_READ_STMT 0
53 #define ID_READHASMANY_STMT 1
54 #define ID_GROUPBY_STMT 2
55 #define ID_ORDERBY_STMT 3
56 #define ID_REVORDER_STMT 4
57 #define ID_MATCHBY_STMT 5
58 #define ID_MAX_STMT 6
59 
60 class DLLLIBSTMT executable
61 {
62  friend struct queryStatementsImple;
63  bool m_enabled;
64 public:
65  executable() : m_enabled(true){}
66  virtual ~executable(){};
67  virtual void execute(recordset& rs) = 0;
68  void release();
69  void setEnabled(bool v) { m_enabled = v; }
70  bool isEnabled() const { return m_enabled; }
71  virtual const int typeID() const = 0;
72 };
73 
74 class DLLLIBSTMT groupByStatement : public fieldNames, public executable
75 {
76  struct queryStatementsImple* m_parent;
77  friend class queryStatements;
78  friend struct queryStatementsImple;
79  std::vector<groupFuncBase*>* m_statements;
80 
81  template <class Archive>
82  friend void serialize(Archive& ar, groupByStatement& q,
83  const unsigned int version);
84  groupByStatement(const groupByStatement& r); // no implements
85  groupByStatement& operator=(const groupByStatement& r); // no implements
86 
87 public:
88  enum eFunc
89  {
90  fsum,
91  fcount,
92  favg,
93  fmin,
94  fmax,
95  ffirst,
96  flast
97  };
98  groupByStatement();
99  ~groupByStatement();
100 
101  groupFuncBase& addFunction(eFunc v, const fieldNames& targetNames,
102  const _TCHAR* resultName = NULL);
103  groupFuncBase& function(int index);
104  groupByStatement& reset();
105  int size() const;
106  void execute(recordset& rs);
107  const int typeID() const { return ID_GROUPBY_STMT; };
108  static groupByStatement* create();
109 };
110 
111 #define MAX_FUNCTION_SIZE (int) groupByStatement::flast + 1
112 
113 class DLLLIBSTMT matchByStatement : public recordsetQuery, public executable
114 {
115  struct queryStatementsImple* m_parent;
116  friend class queryStatements;
117  friend struct queryStatementsImple;
118 
119 public:
120  void execute(recordset& rs);
121  static matchByStatement* create();
122  const int typeID() const { return ID_MATCHBY_STMT; };
123 };
124 
125 class DLLLIBSTMT orderByStatement : public executable
126 {
127  sortFields* m_sortFields;
128  template <class Archive>
129  friend void serialize(Archive& ar, orderByStatement& q,
130  const unsigned int version);
131  orderByStatement(const orderByStatement& r); // no implements
132  orderByStatement& operator=(const orderByStatement& r); // no implements
133 public:
134  ~orderByStatement();
135  orderByStatement();
136  void execute(recordset& rs);
137  void add(const _TCHAR* name, bool asc = true);
138  orderByStatement& reset();
139  int size() const;
140  const sortField& get(int index) const;
141  const int typeID() const { return ID_ORDERBY_STMT; };
142  static orderByStatement* create();
143 };
144 
145 class DLLLIBSTMT reverseOrderStatement : public executable
146 {
147  //~reverseOrderStatement(){};
148  // reverseOrderStatement():executable(){};
149 
150 public:
151  void execute(recordset& rs);
152  const int typeID() const { return ID_REVORDER_STMT; };
153  static reverseOrderStatement* create();
154 };
155 
156 class DLLLIBSTMT readStatement : public fieldValues,
157  public query,
158  public executable
159 {
160  friend struct queryStatementsImple;
161  friend class queryStatements;
162 
163  struct queryStatementImple* m_impl;
164  queryStatementImple* internalPtr() const;
165  template <class Archive>
166  friend void serialize(Archive& ar, readStatement& q,
167  const unsigned int version);
168  readStatement(const readStatement& r); // no implements
169  readStatement& operator=(const readStatement& r); // no implements
170 public:
171  ~readStatement();
172  readStatement();
173 
174  enum eReadType
175  {
176  opRead,
177  opJoin,
178  opOuterJoin
179  };
180  int getIndex() const;
181  readStatement& index(int v);
182  int getOption() const;
183  readStatement& option(int v);
184  const _TCHAR* getDatabaseUri() const;
185  readStatement& databaseUri(const _TCHAR* v);
186  const _TCHAR* getTableName() const;
187  readStatement& tableName(const _TCHAR* v);
188  eReadType getReadType() const;
189  readStatement& readType(eReadType v);
190  readStatement& alias(const _TCHAR* src, const _TCHAR* dst);
191  readStatement& reset();
192  int aliasCount() const;
193  const _TCHAR* getAliasFirst(int index) const;
194  const _TCHAR* getAliasSecond(int index) const;
195 
196  void execute(recordset& rs);
197  const int typeID() const { return ID_READ_STMT; };
198  static readStatement* create();
199 };
200 
201 typedef std::vector<boost::shared_ptr<recordset> > recordsets;
202 
203 class DLLLIBSTMT readHasMany : public readStatement
204 {
205  struct readHasManyImple* m_readHasManyImpl;
206  readHasManyImple* internalPtr() const;
207  template <class Archive>
208  friend void serialize(Archive& ar, readHasMany& q,
209  const unsigned int version);
210  readHasMany(const readHasMany& r); // no implements
211  readHasMany& operator=(const readHasMany& r); // no implements
212 public:
213  ~readHasMany();
214  readHasMany();
215  client::recordsets& recordsets();
216  void addkeyValueColumn(const _TCHAR* name);
217  const _TCHAR* getkeyValueColumn(int index) const;
218  int keyValueColumns() const;
219  readHasMany& reset();
220  void execute(recordset& rs);
221  const int typeID() const { return ID_READHASMANY_STMT; };
222  static readHasMany* create();
223 };
224 
225 class executeListner
226 {
227 public:
228  virtual void onExecuted(const executable* e, const recordset& rs) = 0;
229 };
230 
231 class DLLLIBSTMT queryStatements
232 {
233  struct queryStatementsImple* m_impl;
234  queryStatementsImple* internalPtr() const;
235  template <class Archive>
236  friend void serialize(Archive& ar, queryStatements& q,
237  const unsigned int version);
238  queryStatements(const queryStatements& r); // no implements
239  queryStatements& operator=(const queryStatements& r); // no implements
240  void* getPtr(const executable* e) const;
241 
242 public:
243  queryStatements(idatabaseManager& dbm);
244  queryStatements(database* db);
245  ~queryStatements();
246  int getId() const;
247  queryStatements& id(int v);
248  const _TCHAR* getTitle() const;
249  queryStatements& title(const _TCHAR* v);
250  const _TCHAR* getDescription() const;
251  queryStatements& description(const _TCHAR* v);
252  executable* get(int index);
253  void pop_back();
254 
255  readStatement* addRead(readStatement::eReadType type);
256  readHasMany* addHasManyRead();
257  groupByStatement* addGroupBy();
258  orderByStatement* addOrderBy();
259  matchByStatement* addMatchBy();
260  reverseOrderStatement* addReverseOrder();
261  int statementType(int index);
262 
263  readStatement* getReadStatement(executable* e);
264  readHasMany* getReadHasMany(executable* e);
265  groupByStatement* getGroupByStatement(executable* e);
266  orderByStatement* getOrderByStatement(executable* e);
267  matchByStatement* getMatchByStatement(executable* e);
268  reverseOrderStatement* getReverseOrderStatement(executable* e);
269 
270  const readStatement* getReadStatement(const executable* e) const;
271  const readHasMany* getReadHasMany(const executable* e) const;
272  const groupByStatement* getGroupByStatement(const executable* e) const;
273  const orderByStatement* getOrderByStatement(const executable* e) const;
274  const matchByStatement* getMatchByStatement(const executable* e) const;
275  const reverseOrderStatement*
276  getReverseOrderStatement(const executable* e) const;
277 
278  void clear();
279  int size() const;
280  void move(int from, int to);
281  void save(const _TCHAR* filename);
282  void load(const _TCHAR* filename);
283  void save(std::stringstream& sf);
284  void load(std::stringstream& sf);
285  void execute(recordset& rs, const std::vector<std::_tstring>* values = NULL,
286  executeListner* listner = NULL);
287  static queryStatements* create(idatabaseManager& dbm);
288  static queryStatements* create(database* db);
289 
290  void release();
291 };
292 
293 /** @endcond */
294 
295 } // namespace client
296 } // namespace tdap
297 } // namespace protocol
298 } // namespace db
299 } // namespace bzs
300 
301 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_SERIALIZEER_H

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