|
| 1 | +/* |
| 2 | + * Copyright 2009-2010 10gen, 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 | +#include <Python.h> |
| 18 | + |
| 19 | +/* A buffer representing some data being encoded to BSON. */ |
| 20 | +typedef struct { |
| 21 | + char* buffer; |
| 22 | + int size; |
| 23 | + int position; |
| 24 | +} bson_buffer; |
| 25 | + |
| 26 | +bson_buffer* buffer_new(void); |
| 27 | + |
| 28 | +int buffer_save_bytes(bson_buffer* buffer, int size); |
| 29 | + |
| 30 | +int buffer_write_bytes(bson_buffer* buffer, const char* bytes, int size); |
| 31 | + |
| 32 | +void buffer_free(bson_buffer* buffer); |
| 33 | + |
| 34 | +int write_dict(bson_buffer* buffer, PyObject* dict, |
| 35 | + unsigned char check_keys, unsigned char top_level); |
| 36 | + |
| 37 | +PyObject* elements_to_dict(const char* string, int max, |
| 38 | + PyObject* as_class, unsigned char tz_aware); |
| 39 | + |
| 40 | +int write_pair(bson_buffer* buffer, const char* name, |
| 41 | + Py_ssize_t name_length, PyObject* value, |
| 42 | + unsigned char check_keys, unsigned char allow_id); |
| 43 | + |
| 44 | +int decode_and_write_pair(bson_buffer* buffer, |
| 45 | + PyObject* key, PyObject* value, |
| 46 | + unsigned char check_keys, unsigned char top_level); |
0 commit comments