1 #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_SERIALIZEER_H
2 #define BZS_DB_PROTOCOL_TDAP_CLIENT_SERIALIZEER_H
21 #include <bzs/db/protocol/tdap/client/activeTable.h>
25 #define DLLLIBSTMT AGRPACK
28 #define DLLLIBSTMT AGRPACK
30 #define DLLLIBSTMT // PACKAGE_IMPORT
32 #endif // LIB_TDCLSTMT
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
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
60 class DLLLIBSTMT executable
62 friend struct queryStatementsImple;
65 virtual ~executable(){};
66 virtual void execute(recordset& rs) = 0;
68 virtual const int typeID()
const = 0;
71 class DLLLIBSTMT groupByStatement :
public fieldNames,
public executable
73 struct queryStatementsImple* m_parent;
74 friend class queryStatements;
75 friend struct queryStatementsImple;
76 std::vector<groupFuncBase*>* m_statements;
78 template <
class Archive>
79 friend void serialize(Archive& ar, groupByStatement& q,
80 const unsigned int version);
81 groupByStatement(
const groupByStatement& r);
82 groupByStatement& operator=(
const groupByStatement& r);
98 groupFuncBase& addFunction(eFunc v,
const fieldNames& targetNames,
99 const _TCHAR* resultName = NULL);
100 groupFuncBase&
function(
int index);
101 groupByStatement& reset();
103 void execute(recordset& rs);
104 const int typeID()
const {
return ID_GROUPBY_STMT; };
105 static groupByStatement* create();
108 #define MAX_FUNCTION_SIZE (int) groupByStatement::flast + 1
110 class DLLLIBSTMT matchByStatement :
public recordsetQuery,
public executable
112 struct queryStatementsImple* m_parent;
113 friend class queryStatements;
114 friend struct queryStatementsImple;
117 void execute(recordset& rs);
118 static matchByStatement* create();
119 const int typeID()
const {
return ID_MATCHBY_STMT; };
122 class DLLLIBSTMT orderByStatement :
public executable
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);
129 orderByStatement& operator=(
const orderByStatement& r);
133 void execute(recordset& rs);
134 void add(
const _TCHAR* name,
bool asc =
true);
135 orderByStatement& reset();
137 const sortField&
get(
int index)
const;
138 const int typeID()
const {
return ID_ORDERBY_STMT; };
139 static orderByStatement* create();
142 class DLLLIBSTMT reverseOrderStatement :
public executable
148 void execute(recordset& rs);
149 const int typeID()
const {
return ID_REVORDER_STMT; };
150 static reverseOrderStatement* create();
153 class DLLLIBSTMT readStatement :
public fieldNames,
157 friend struct queryStatementsImple;
158 friend class queryStatements;
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);
166 readStatement& operator=(
const readStatement& r);
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;
193 void execute(recordset& rs);
194 const int typeID()
const {
return ID_READ_STMT; };
195 static readStatement* create();
198 typedef std::vector<boost::shared_ptr<recordset> > recordsets;
200 class DLLLIBSTMT readHasMany :
public readStatement
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);
208 readHasMany& operator=(
const readHasMany& r);
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();
225 virtual void onExecuted(
const executable* e,
const recordset& rs) = 0;
228 class DLLLIBSTMT queryStatements
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);
236 queryStatements& operator=(
const queryStatements& r);
237 void* getPtr(
const executable* e)
const;
240 queryStatements(idatabaseManager& dbm);
241 queryStatements(database* db);
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);
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);
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);
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;
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);
298 #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_SERIALIZEER_H
const _TCHAR * protocol(const _TCHAR *uri)
Definition: uri.h:42