1 /*
2  * Copyright 2015-2017 MongoDB, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef PHONGO_STRUCTS_H
18 #define PHONGO_STRUCTS_H
19 
20 #include <php.h>
21 
22 #include "php_bson.h"
23 
24 typedef struct {
25 	mongoc_bulk_operation_t* bulk;
26 	size_t                   num_ops;
27 	bool                     ordered;
28 	int                      bypass;
29 	char*                    database;
30 	char*                    collection;
31 	bool                     executed;
32 	zval                     session;
33 	zend_object              std;
34 } php_phongo_bulkwrite_t;
35 
36 typedef struct {
37 	mongoc_client_encryption_t* client_encryption;
38 	zend_object                 std;
39 } php_phongo_clientencryption_t;
40 
41 typedef struct {
42 	bson_t*     bson;
43 	uint32_t    max_await_time_ms;
44 	uint32_t    batch_size;
45 	zend_object std;
46 } php_phongo_command_t;
47 
48 typedef struct {
49 	mongoc_cursor_t*      cursor;
50 	mongoc_client_t*      client;
51 	int                   created_by_pid;
52 	uint32_t              server_id;
53 	bool                  advanced;
54 	php_phongo_bson_state visitor_data;
55 	long                  current;
56 	char*                 database;
57 	char*                 collection;
58 	zval                  query;
59 	zval                  command;
60 	zval                  read_preference;
61 	zval                  session;
62 	zend_object           std;
63 } php_phongo_cursor_t;
64 
65 typedef struct {
66 	int64_t     id;
67 	zend_object std;
68 } php_phongo_cursorid_t;
69 
70 typedef struct {
71 	mongoc_client_t* client;
72 	int              created_by_pid;
73 	char*            client_hash;
74 	size_t           client_hash_len;
75 	zend_object      std;
76 } php_phongo_manager_t;
77 
78 typedef struct {
79 	bson_t*                filter;
80 	bson_t*                opts;
81 	mongoc_read_concern_t* read_concern;
82 	uint32_t               max_await_time_ms;
83 	zend_object            std;
84 } php_phongo_query_t;
85 
86 typedef struct {
87 	mongoc_read_concern_t* read_concern;
88 	HashTable*             properties;
89 	zend_object            std;
90 } php_phongo_readconcern_t;
91 
92 typedef struct {
93 	mongoc_read_prefs_t* read_preference;
94 	HashTable*           properties;
95 	zend_object          std;
96 } php_phongo_readpreference_t;
97 
98 typedef struct {
99 	mongoc_client_t* client;
100 	int              created_by_pid;
101 	uint32_t         server_id;
102 	zend_object      std;
103 } php_phongo_server_t;
104 
105 typedef struct {
106 	mongoc_client_session_t* client_session;
107 	mongoc_client_t*         client;
108 	int                      created_by_pid;
109 	zend_object              std;
110 } php_phongo_session_t;
111 
112 typedef struct {
113 	HashTable*              properties;
114 	mongoc_write_concern_t* write_concern;
115 	zend_object             std;
116 } php_phongo_writeconcern_t;
117 
118 typedef struct {
119 	int         code;
120 	char*       message;
121 	zval        info;
122 	zend_object std;
123 } php_phongo_writeconcernerror_t;
124 
125 typedef struct {
126 	int         code;
127 	char*       message;
128 	zval        info;
129 	uint32_t    index;
130 	zend_object std;
131 } php_phongo_writeerror_t;
132 
133 typedef struct {
134 	mongoc_write_concern_t* write_concern;
135 	bson_t*                 reply;
136 	mongoc_client_t*        client;
137 	uint32_t                server_id;
138 	zend_object             std;
139 } php_phongo_writeresult_t;
140 
141 typedef struct {
142 	char*       data;
143 	int         data_len;
144 	uint8_t     type;
145 	HashTable*  properties;
146 	zend_object std;
147 } php_phongo_binary_t;
148 
149 typedef struct {
150 	char*       ref;
151 	size_t      ref_len;
152 	char        id[25];
153 	HashTable*  properties;
154 	zend_object std;
155 } php_phongo_dbpointer_t;
156 
157 typedef struct {
158 	bool              initialized;
159 	bson_decimal128_t decimal;
160 	HashTable*        properties;
161 	zend_object       std;
162 } php_phongo_decimal128_t;
163 
164 typedef struct {
165 	bool        initialized;
166 	int64_t     integer;
167 	HashTable*  properties;
168 	zend_object std;
169 } php_phongo_int64_t;
170 
171 typedef struct {
172 	char*       code;
173 	size_t      code_len;
174 	bson_t*     scope;
175 	HashTable*  properties;
176 	zend_object std;
177 } php_phongo_javascript_t;
178 
179 typedef struct {
180 	zend_object std;
181 } php_phongo_maxkey_t;
182 
183 typedef struct {
184 	zend_object std;
185 } php_phongo_minkey_t;
186 
187 typedef struct {
188 	bool        initialized;
189 	char        oid[25];
190 	HashTable*  properties;
191 	zend_object std;
192 } php_phongo_objectid_t;
193 
194 typedef struct {
195 	char*       pattern;
196 	int         pattern_len;
197 	char*       flags;
198 	int         flags_len;
199 	HashTable*  properties;
200 	zend_object std;
201 } php_phongo_regex_t;
202 
203 typedef struct {
204 	char*       symbol;
205 	size_t      symbol_len;
206 	HashTable*  properties;
207 	zend_object std;
208 } php_phongo_symbol_t;
209 
210 typedef struct {
211 	bool        initialized;
212 	uint32_t    increment;
213 	uint32_t    timestamp;
214 	HashTable*  properties;
215 	zend_object std;
216 } php_phongo_timestamp_t;
217 
218 typedef struct {
219 	zend_object std;
220 } php_phongo_undefined_t;
221 
222 typedef struct {
223 	bool        initialized;
224 	int64_t     milliseconds;
225 	HashTable*  properties;
226 	zend_object std;
227 } php_phongo_utcdatetime_t;
228 
229 typedef struct {
230 	mongoc_client_t* client;
231 	char*            command_name;
232 	uint32_t         server_id;
233 	uint64_t         operation_id;
234 	uint64_t         request_id;
235 	uint64_t         duration_micros;
236 	bson_t*          reply;
237 	zval             z_error;
238 	zend_object      std;
239 } php_phongo_commandfailedevent_t;
240 
241 typedef struct {
242 	mongoc_client_t* client;
243 	char*            command_name;
244 	uint32_t         server_id;
245 	uint64_t         operation_id;
246 	uint64_t         request_id;
247 	bson_t*          command;
248 	char*            database_name;
249 	zend_object      std;
250 } php_phongo_commandstartedevent_t;
251 
252 typedef struct {
253 	mongoc_client_t* client;
254 	char*            command_name;
255 	uint32_t         server_id;
256 	uint64_t         operation_id;
257 	uint64_t         request_id;
258 	uint64_t         duration_micros;
259 	bson_t*          reply;
260 	zend_object      std;
261 } php_phongo_commandsucceededevent_t;
262 
263 #endif /* PHONGO_STRUCTS */
264 
265 /*
266  * Local variables:
267  * tab-width: 4
268  * c-basic-offset: 4
269  * End:
270  * vim600: noet sw=4 ts=4 fdm=marker
271  * vim<600: noet sw=4 ts=4
272  */
273