全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド ページ
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 
64 public:
65  virtual ~executable(){};
66  virtual void execute(recordset& rs) = 0;
67  void release();
68  virtual const int typeID() const = 0;
69 };
70 
71 class DLLLIBSTMT groupByStatement : public fieldNames, public executable
72 {
73  struct queryStatementsImple* m_parent;
74  friend class queryStatements;
75  friend struct queryStatementsImple;
76  std::vector<groupFuncBase*>* m_statements;
77 
78  template <class Archive>
79  friend void serialize(Archive& ar, groupByStatement& q,
80  const unsigned int version);
81  groupByStatement(const groupByStatement& r); // no implements
82  groupByStatement& operator=(const groupByStatement& r); // no implements
83 
84 public:
85  enum eFunc
86  {
87  fsum,
88  fcount,
89  favg,
90  fmin,
91  fmax,
92  ffirst,
93  flast
94  };
95  groupByStatement();
96  ~groupByStatement();
97 
98  groupFuncBase& addFunction(eFunc v, const fieldNames& targetNames,
99  const _TCHAR* resultName = NULL);
100  groupFuncBase& function(int index);
101  groupByStatement& reset();
102  int size() const;
103  void execute(recordset& rs);
104  const int typeID() const { return ID_GROUPBY_STMT; };
105  static groupByStatement* create();
106 };
107 
108 #define MAX_FUNCTION_SIZE (int) groupByStatement::flast + 1
109 
110 class DLLLIBSTMT matchByStatement : public recordsetQuery, public executable
111 {
112  struct queryStatementsImple* m_parent;
113  friend class queryStatements;
114  friend struct queryStatementsImple;
115 
116 public:
117  void execute(recordset& rs);
118  static matchByStatement* create();
119  const int typeID() const { return ID_MATCHBY_STMT; };
120 };
121 
122 class DLLLIBSTMT orderByStatement : public executable
123 {
124  sortFields* m_sortFields;
125  template <class Archive>
126  friend void serialize(Archive& ar, orderByStatement& q,
127  const unsigned int version);
128  orderByStatement(const orderByStatement& r); // no implements
129  orderByStatement& operator=(const orderByStatement& r); // no implements
130 public:
131  ~orderByStatement();
132  orderByStatement();
133  void execute(recordset& rs);
134  void add(const _TCHAR* name, bool asc = true);
135  orderByStatement& reset();
136  int size() const;
137  const sortField& get(int index) const;
138  const int typeID() const { return ID_ORDERBY_STMT; };
139  static orderByStatement* create();
140 };
141 
142 class DLLLIBSTMT reverseOrderStatement : public executable
143 {
144  //~reverseOrderStatement(){};
145  // reverseOrderStatement():executable(){};
146 
147 public:
148  void execute(recordset& rs);
149  const int typeID() const { return ID_REVORDER_STMT; };
150  static reverseOrderStatement* create();
151 };
152 
153 class DLLLIBSTMT readStatement : public fieldNames,
154  public query,
155  public executable
156 {
157  friend struct queryStatementsImple;
158  friend class queryStatements;
159 
160  struct queryStatementImple* m_impl;
161  queryStatementImple* internalPtr() const;
162  template <class Archive>
163  friend void serialize(Archive& ar, readStatement& q,
164  const unsigned int version);
165  readStatement(const readStatement& r); // no implements
166  readStatement& operator=(const readStatement& r); // no implements
167 public:
168  ~readStatement();
169  readStatement();
170 
171  enum eReadType
172  {
173  opRead,
174  opJoin,
175  opOuterJoin
176  };
177  int getIndex() const;
178  readStatement& index(int v);
179  int getOption() const;
180  readStatement& option(int v);
181  const _TCHAR* getDatabaseUri() const;
182  readStatement& databaseUri(const _TCHAR* v);
183  const _TCHAR* getTableName() const;
184  readStatement& tableName(const _TCHAR* v);
185  eReadType getReadType() const;
186  readStatement& readType(eReadType v);
187  readStatement& alias(const _TCHAR* src, const _TCHAR* dst);
188  readStatement& reset();
189  int aliasCount() const;
190  const _TCHAR* getAliasFirst(int index) const;
191  const _TCHAR* getAliasSecond(int index) const;
192 
193  void execute(recordset& rs);
194  const int typeID() const { return ID_READ_STMT; };
195  static readStatement* create();
196 };
197 
198 typedef std::vector<boost::shared_ptr<recordset> > recordsets;
199 
200 class DLLLIBSTMT readHasMany : public readStatement
201 {
202  struct readHasManyImple* m_readHasManyImpl;
203  readHasManyImple* internalPtr() const;
204  template <class Archive>
205  friend void serialize(Archive& ar, readHasMany& q,
206  const unsigned int version);
207  readHasMany(const readHasMany& r); // no implements
208  readHasMany& operator=(const readHasMany& r); // no implements
209 public:
210  ~readHasMany();
211  readHasMany();
212  client::recordsets& recordsets();
213  void addkeyValueColumn(const _TCHAR* name);
214  const _TCHAR* getkeyValueColumn(int index) const;
215  int keyValueColumns() const;
216  readHasMany& reset();
217  void execute(recordset& rs);
218  const int typeID() const { return ID_READHASMANY_STMT; };
219  static readHasMany* create();
220 };
221 
222 class executeListner
223 {
224 public:
225  virtual void onExecuted(const executable* e, const recordset& rs) = 0;
226 };
227 
228 class DLLLIBSTMT queryStatements
229 {
230  struct queryStatementsImple* m_impl;
231  queryStatementsImple* internalPtr() const;
232  template <class Archive>
233  friend void serialize(Archive& ar, queryStatements& q,
234  const unsigned int version);
235  queryStatements(const queryStatements& r); // no implements
236  queryStatements& operator=(const queryStatements& r); // no implements
237  void* getPtr(const executable* e) const;
238 
239 public:
240  queryStatements(idatabaseManager& dbm);
241  queryStatements(database* db);
242  ~queryStatements();
243  int getId() const;
244  queryStatements& id(int v);
245  const _TCHAR* getTitle() const;
246  queryStatements& title(const _TCHAR* v);
247  const _TCHAR* getDescription() const;
248  queryStatements& description(const _TCHAR* v);
249  executable* get(int index);
250  void pop_back();
251 
252  readStatement* addRead(readStatement::eReadType type);
253  readHasMany* addHasManyRead();
254  groupByStatement* addGroupBy();
255  orderByStatement* addOrderBy();
256  matchByStatement* addMatchBy();
257  reverseOrderStatement* addReverseOrder();
258  int statementType(int index);
259 
260  readStatement* getReadStatement(executable* e);
261  readHasMany* getReadHasMany(executable* e);
262  groupByStatement* getGroupByStatement(executable* e);
263  orderByStatement* getOrderByStatement(executable* e);
264  matchByStatement* getMatchByStatement(executable* e);
265  reverseOrderStatement* getReverseOrderStatement(executable* e);
266 
267  const readStatement* getReadStatement(const executable* e) const;
268  const readHasMany* getReadHasMany(const executable* e) const;
269  const groupByStatement* getGroupByStatement(const executable* e) const;
270  const orderByStatement* getOrderByStatement(const executable* e) const;
271  const matchByStatement* getMatchByStatement(const executable* e) const;
272  const reverseOrderStatement*
273  getReverseOrderStatement(const executable* e) const;
274 
275  void clear();
276  int size() const;
277  void move(int from, int to);
278  void save(const _TCHAR* filename);
279  void load(const _TCHAR* filename);
280  void save(std::stringstream& sf);
281  void load(std::stringstream& sf);
282  void execute(recordset& rs, const std::vector<std::_tstring>* values = NULL,
283  executeListner* listner = NULL);
284  static queryStatements* create(idatabaseManager& dbm);
285  static queryStatements* create(database* db);
286 
287  void release();
288 };
289 
290 /** @endcond */
291 
292 } // namespace client
293 } // namespace tdap
294 } // namespace protocol
295 } // namespace db
296 } // namespace bzs
297 
298 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_SERIALIZEER_H
const _TCHAR * protocol(const _TCHAR *uri)
Definition: uri.h:42

Transactd SDK 2015年09月08日(火) 19時13分35秒 doxygen