dbutils/object.h

changeset 4
1908c8b1599f
parent 3
69ea9040d896
child 6
d6981b56ab30
equal deleted inserted replaced
3:69ea9040d896 4:1908c8b1599f
35 #ifdef __cplusplus 35 #ifdef __cplusplus
36 extern "C" { 36 extern "C" {
37 #endif 37 #endif
38 38
39 typedef struct DBUFieldMapping { 39 typedef struct DBUFieldMapping {
40 DBUClass *cls;
40 DBUField *field; 41 DBUField *field;
41 DBUFieldType type; 42 DBUFieldType type;
42 int index; 43 bool is_main;
43 } DBUFieldMapping; 44 } DBUFieldMapping;
44 45
46 typedef struct DBUBuilderQuery DBUBuilderQuery;
47 struct DBUBuilderQuery {
48 DBUClass *type;
49 DBUQuery *query;
50 };
51
52 typedef struct DBUObjectBuilderResult DBUObjectBuilderResult;
53 struct DBUObjectBuilderResult {
54 void *userdata1;
55 void *userdata2;
56 int int1;
57 int int2;
58 DBUObject (*create)(DBUObjectBuilderResult *result, DBUClass *type, const CxAllocator *a);
59 int (*add)(DBUObjectBuilderResult *result, void *obj);
60 void (*free)(DBUObjectBuilderResult *result);
61 };
62
63 struct DBUObjectBuilder {
64 const CxAllocator *allocator;
65
66 DBUContext *ctx;
67
68 /*
69 * Main query, that us used for generating the result list.
70 */
71 DBUQuery *mainQuery;
72
73 /*
74 * result type
75 */
76 DBUClass *resultType;
77
78 /*
79 * key: type name
80 * value: DBUQuery*
81 *
82 * Subqueries, that should be executed for all main result rows.
83 * Before a subquery is executed, the first parameter is set to the
84 * foreign key, that is stored in the main table.
85 */
86 CxMap *subQueries;
87
88 /*
89 * value: DBUBuilderQuery
90 *
91 * Additional queries are executed before the main query and the result
92 * objects are cached and later added as children to the main result.
93 */
94 CxList *additionalQueries;
95
96 /*
97 * result builder
98 */
99 DBUObjectBuilderResult *result;
100 };
101
102 int dbuObjectBuilderGet(DBUObjectBuilder *builder, DBUObjectBuilderResult *objresult);
45 103
46 #ifdef __cplusplus 104 #ifdef __cplusplus
47 } 105 }
48 #endif 106 #endif
49 107

mercurial