27
27
/* External libs */
28
28
#include <bson.h>
29
29
#include <mongoc.h>
30
+ #include "mongoc-write-concern-private.h"
30
31
31
32
/* PHP Core stuff */
32
33
#include <php.h>
@@ -98,6 +99,93 @@ PHP_METHOD(WriteConcern, __construct)
98
99
}
99
100
/* }}} */
100
101
102
+ /* {{{ proto string|integer WriteConcern::getW()
103
+ Returns the WriteConcern "w" option */
104
+ PHP_METHOD (WriteConcern , getW )
105
+ {
106
+ php_phongo_writeconcern_t * intern ;
107
+ const char * wtag ;
108
+ (void )return_value_ptr ; (void )return_value_used ;
109
+
110
+ intern = (php_phongo_writeconcern_t * )zend_object_store_get_object (getThis () TSRMLS_CC );
111
+
112
+ if (zend_parse_parameters_none () == FAILURE ) {
113
+ return ;
114
+ }
115
+
116
+ wtag = mongoc_write_concern_get_wtag (intern -> write_concern );
117
+
118
+ if (wtag ) {
119
+ RETURN_STRING (wtag , 1 );
120
+ }
121
+
122
+ if (mongoc_write_concern_get_wmajority (intern -> write_concern )) {
123
+ RETURN_STRING (PHONGO_WRITE_CONCERN_W_MAJORITY , 1 );
124
+ }
125
+
126
+ RETURN_LONG (intern -> write_concern -> w );
127
+ }
128
+ /* }}} */
129
+
130
+ /* {{{ proto string|integer WriteConcern::getWtimeout()
131
+ Returns the WriteConcern "wtimeout" option */
132
+ PHP_METHOD (WriteConcern , getWtimeout )
133
+ {
134
+ php_phongo_writeconcern_t * intern ;
135
+ (void )return_value_ptr ; (void )return_value_used ;
136
+
137
+ intern = (php_phongo_writeconcern_t * )zend_object_store_get_object (getThis () TSRMLS_CC );
138
+
139
+ if (zend_parse_parameters_none () == FAILURE ) {
140
+ return ;
141
+ }
142
+
143
+ RETURN_LONG (mongoc_write_concern_get_wtimeout (intern -> write_concern ));
144
+ }
145
+ /* }}} */
146
+
147
+ /* {{{ proto null|boolean WriteConcern::getJournal()
148
+ Returns the WriteConcern "journal" option */
149
+ PHP_METHOD (WriteConcern , getJournal )
150
+ {
151
+ php_phongo_writeconcern_t * intern ;
152
+ (void )return_value_ptr ; (void )return_value_used ;
153
+
154
+ intern = (php_phongo_writeconcern_t * )zend_object_store_get_object (getThis () TSRMLS_CC );
155
+
156
+ if (zend_parse_parameters_none () == FAILURE ) {
157
+ return ;
158
+ }
159
+
160
+ if (intern -> write_concern -> journal != MONGOC_WRITE_CONCERN_JOURNAL_DEFAULT ) {
161
+ RETURN_BOOL (mongoc_write_concern_get_journal (intern -> write_concern ));
162
+ }
163
+
164
+ RETURN_NULL ();
165
+ }
166
+ /* }}} */
167
+
168
+ /* {{{ proto null|boolean WriteConcern::getFsync()
169
+ Returns the WriteConcern "fsync" option */
170
+ PHP_METHOD (WriteConcern , getFsync )
171
+ {
172
+ php_phongo_writeconcern_t * intern ;
173
+ (void )return_value_ptr ; (void )return_value_used ;
174
+
175
+ intern = (php_phongo_writeconcern_t * )zend_object_store_get_object (getThis () TSRMLS_CC );
176
+
177
+ if (zend_parse_parameters_none () == FAILURE ) {
178
+ return ;
179
+ }
180
+
181
+ if (intern -> write_concern -> fsync_ != MONGOC_WRITE_CONCERN_FSYNC_DEFAULT ) {
182
+ RETURN_BOOL (mongoc_write_concern_get_fsync (intern -> write_concern ));
183
+ }
184
+
185
+ RETURN_NULL ();
186
+ }
187
+ /* }}} */
188
+
101
189
/**
102
190
* Value object for write concern used in issuing write operations.
103
191
*/
@@ -110,9 +198,24 @@ ZEND_BEGIN_ARG_INFO_EX(ai_WriteConcern___construct, 0, 0, 1)
110
198
ZEND_ARG_INFO (0 , fsync )
111
199
ZEND_END_ARG_INFO ();
112
200
201
+ ZEND_BEGIN_ARG_INFO_EX (ai_WriteConcern_getW , 0 , 0 , 0 )
202
+ ZEND_END_ARG_INFO ();
203
+
204
+ ZEND_BEGIN_ARG_INFO_EX (ai_WriteConcern_getWtimeout , 0 , 0 , 0 )
205
+ ZEND_END_ARG_INFO ();
206
+
207
+ ZEND_BEGIN_ARG_INFO_EX (ai_WriteConcern_getJournal , 0 , 0 , 0 )
208
+ ZEND_END_ARG_INFO ();
209
+
210
+ ZEND_BEGIN_ARG_INFO_EX (ai_WriteConcern_getFsync , 0 , 0 , 0 )
211
+ ZEND_END_ARG_INFO ();
113
212
114
213
static zend_function_entry php_phongo_writeconcern_me [] = {
115
214
PHP_ME (WriteConcern , __construct , ai_WriteConcern___construct , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
215
+ PHP_ME (WriteConcern , getW , ai_WriteConcern_getW , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
216
+ PHP_ME (WriteConcern , getWtimeout , ai_WriteConcern_getWtimeout , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
217
+ PHP_ME (WriteConcern , getJournal , ai_WriteConcern_getJournal , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
218
+ PHP_ME (WriteConcern , getFsync , ai_WriteConcern_getFsync , ZEND_ACC_PUBLIC |ZEND_ACC_FINAL )
116
219
PHP_FE_END
117
220
};
118
221
0 commit comments