1 module mongoaux.definitions; 2 3 public import mongoaux.mongoc; 4 alias ssize_t = ptrdiff_t; 5 extern (C) { 6 // TODO: Change for example ints to C ones. 7 char * bson_as_canonical_extended_json(const bson_t *bson, size_t *length); 8 void bson_init(bson_t * b); 9 bson_t * bson_new(); 10 bson_t * bson_copy(const bson_t * bson); 11 void bson_free(void * mem); 12 bool mongoc_collection_delete_one( 13 mongoc_collection_t *collection, 14 const bson_t *selector, 15 const bson_t *opts, 16 bson_t *reply, 17 bson_error_t *error 18 ); 19 bool mongoc_collection_insert_one( 20 mongoc_collection_t *collection, 21 const bson_t *document, 22 const bson_t *opts, 23 bson_t *reply, 24 bson_error_t *error 25 ); 26 bool mongoc_collection_update_one( 27 mongoc_collection_t *collection, 28 const bson_t *selector, 29 const bson_t *update, 30 const bson_t *opts, 31 bson_t *reply, 32 bson_error_t *error 33 ); 34 bool bson_init_from_json( 35 bson_t *bson, 36 const char *data, 37 ssize_t len, 38 bson_error_t *error 39 ); 40 bool bson_has_field(const bson_t *bson, const char *key); 41 bool bson_append_int32( 42 bson_t *bson, 43 const char *key, 44 int key_length, 45 int value 46 ); 47 bool bson_append_int64( 48 bson_t *bson, 49 const char *key, 50 int key_length, 51 long value 52 ); 53 bool bson_append_bool( 54 bson_t *bson, 55 const char *key, 56 int key_length, 57 bool value 58 ); 59 bool bson_append_double( 60 bson_t *bson, 61 const char *key, 62 int key_length, 63 double value 64 ); 65 bool bson_append_utf8( 66 bson_t *bson, 67 const char *key, 68 int key_length, 69 const char *value, 70 int length 71 ); 72 bool bson_append_date_time( 73 bson_t *bson, 74 const char *key, 75 int key_length, 76 long value 77 ); 78 bool bson_append_array_begin( 79 bson_t *bson, 80 const char *key, 81 int key_length, 82 bson_t *child 83 ); 84 bool bson_append_array_end( 85 bson_t *bson, 86 bson_t *child 87 ); 88 bool bson_append_document_begin( 89 bson_t *bson, 90 const char *key, 91 int key_length, 92 bson_t *child 93 ); 94 bool bson_append_document_end (bson_t *bson, bson_t *child); 95 bool bson_append_document( 96 bson_t *bson, 97 const char *key, 98 int key_length, 99 const bson_t *value 100 ); 101 bool bson_append_oid( 102 bson_t *bson, 103 const char *key, 104 int key_length, 105 const bson_oid_t *oid 106 ); 107 mongoc_bulk_operation_t * mongoc_collection_create_bulk_operation_with_opts( 108 mongoc_collection_t *collection, 109 const bson_t *opts 110 ); 111 bool mongoc_collection_insert_many( 112 mongoc_collection_t *collection, 113 const bson_t **documents, 114 size_t n_documents, 115 const bson_t *opts, 116 bson_t *reply, 117 bson_error_t *error 118 ); 119 // These 3 struct definitions are taken from mongoc.d 120 // They're marked IGN there, don't know why. 121 struct _bson_value_t { 122 bson_type_t value_type; 123 int padding; 124 125 union _Anonymous_0 126 { 127 bson_oid_t v_oid; 128 long v_int64; 129 int v_int32; 130 byte v_int8; 131 double v_double; 132 bool v_bool; 133 long v_datetime; 134 135 struct _Anonymous_1 136 { 137 uint timestamp; 138 uint increment; 139 } 140 141 _Anonymous_1 v_timestamp; 142 143 struct _Anonymous_2 144 { 145 char* str; 146 uint len; 147 } 148 149 _Anonymous_2 v_utf8; 150 151 struct _Anonymous_3 152 { 153 ubyte* data; 154 uint data_len; 155 } 156 157 _Anonymous_3 v_doc; 158 159 struct _Anonymous_4 160 { 161 ubyte* data; 162 uint data_len; 163 bson_subtype_t subtype; 164 } 165 166 _Anonymous_4 v_binary; 167 168 struct _Anonymous_5 169 { 170 char* regex; 171 char* options; 172 } 173 174 _Anonymous_5 v_regex; 175 176 struct _Anonymous_6 177 { 178 char* collection; 179 uint collection_len; 180 bson_oid_t oid; 181 } 182 183 _Anonymous_6 v_dbpointer; 184 185 struct _Anonymous_7 186 { 187 char* code; 188 uint code_len; 189 } 190 191 _Anonymous_7 v_code; 192 193 struct _Anonymous_8 194 { 195 char* code; 196 ubyte* scope_data; 197 uint code_len; 198 uint scope_len; 199 } 200 201 _Anonymous_8 v_codewscope; 202 203 struct _Anonymous_9 204 { 205 char* symbol; 206 uint len; 207 } 208 209 _Anonymous_9 v_symbol; 210 bson_decimal128_t v_decimal128; 211 } 212 213 _Anonymous_0 value; 214 } 215 216 alias bson_value_t = _bson_value_t; 217 struct bson_iter_t { 218 const(ubyte)* raw; 219 uint len; 220 uint off; 221 uint type; 222 uint key; 223 uint d1; 224 uint d2; 225 uint d3; 226 uint d4; 227 uint next_off; 228 uint err_off; 229 bson_value_t value; 230 } 231 char * bson_iter_key(const bson_iter_t *iter); 232 bson_value_t * bson_iter_value (bson_iter_t *iter); 233 bool bson_iter_next(bson_iter_t *iter); 234 bool bson_iter_init(bson_iter_t *iter, const bson_t *bson); 235 bool bson_iter_init_find 236 (bson_iter_t *iter, const bson_t *bson, const char *key); 237 bson_oid_t * bson_iter_oid (const bson_iter_t *iter); 238 void bson_oid_init_from_string(bson_oid_t *oid, const char *str); 239 bool bson_oid_is_valid (const char *str, size_t length); 240 void bson_oid_to_string (const bson_oid_t *oid, char * str); 241 bson_type_t bson_iter_type (const bson_iter_t *iter); 242 }