|
libmongo-client 0.1.4
|
Implementation of the BSON API. More...
#include <glib.h>#include <errno.h>#include <string.h>#include <stdarg.h>#include "bson.h"#include "libmongo-macros.h"#include "libmongo-private.h"
Go to the source code of this file.
Data Structures | |
| struct | bson_cursor |
| Opaque BSON cursor. More... | |
Defines | |
| #define | _bson_build_add_single(b, type, name, free_after, ap) |
| #define | BSON_CURSOR_CHECK_TYPE(c, type) |
Functions | |
| const gchar * | bson_type_as_string (bson_type type) |
| Return a type's stringified name. | |
| bson * | bson_new (void) |
| Create a new BSON object. | |
| bson * | bson_new_sized (gint32 size) |
| Create a new BSON object, preallocating a given amount of space. | |
| bson * | bson_new_from_data (const guint8 *data, gint32 size) |
| Create a BSON object from existing data. | |
| bson * | bson_build (bson_type type, const gchar *name,...) |
| Build a BSON object in one go. | |
| bson * | bson_build_full (bson_type type, const gchar *name, gboolean free_after,...) |
| Build a BSON object in one go, with full control. | |
| gboolean | bson_finish (bson *b) |
| Finish a BSON object. | |
| gint32 | bson_size (const bson *b) |
| Return the size of a finished BSON object. | |
| const guint8 * | bson_data (const bson *b) |
| Return the raw bytestream form of the BSON object. | |
| gboolean | bson_reset (bson *b) |
| Reset a BSON object. | |
| void | bson_free (bson *b) |
| Free the memory associated with a BSON object. | |
| gboolean | bson_validate_key (const gchar *key, gboolean forbid_dots, gboolean no_dollar) |
| Validate a BSON key. | |
| gboolean | bson_append_double (bson *b, const gchar *name, gdouble val) |
| Append a double to a BSON object. | |
| gboolean | bson_append_string (bson *b, const gchar *name, const gchar *val, gint32 length) |
| Append a string to a BSON object. | |
| gboolean | bson_append_document (bson *b, const gchar *name, const bson *doc) |
| Append a BSON document to a BSON object. | |
| gboolean | bson_append_array (bson *b, const gchar *name, const bson *array) |
| Append a BSON array to a BSON object. | |
| gboolean | bson_append_binary (bson *b, const gchar *name, bson_binary_subtype subtype, const guint8 *data, gint32 size) |
| Append a BSON binary blob to a BSON object. | |
| gboolean | bson_append_oid (bson *b, const gchar *name, const guint8 *oid) |
| Append an ObjectID to a BSON object. | |
| gboolean | bson_append_boolean (bson *b, const gchar *name, gboolean value) |
| Append a boolean to a BSON object. | |
| gboolean | bson_append_utc_datetime (bson *b, const gchar *name, gint64 ts) |
| Append an UTC datetime to a BSON object. | |
| gboolean | bson_append_null (bson *b, const gchar *name) |
| Append a NULL value to a BSON object. | |
| gboolean | bson_append_regex (bson *b, const gchar *name, const gchar *regexp, const gchar *options) |
| Append a regexp object to a BSON object. | |
| gboolean | bson_append_javascript (bson *b, const gchar *name, const gchar *js, gint32 len) |
| Append Javascript code to a BSON object. | |
| gboolean | bson_append_symbol (bson *b, const gchar *name, const gchar *symbol, gint32 len) |
| Append a symbol to a BSON object. | |
| gboolean | bson_append_javascript_w_scope (bson *b, const gchar *name, const gchar *js, gint32 len, const bson *scope) |
| Append Javascript code (with scope) to a BSON object. | |
| gboolean | bson_append_int32 (bson *b, const gchar *name, gint32 i) |
| Append a 32-bit integer to a BSON object. | |
| gboolean | bson_append_timestamp (bson *b, const gchar *name, gint64 ts) |
| Append a timestamp to a BSON object. | |
| gboolean | bson_append_int64 (bson *b, const gchar *name, gint64 i) |
| Append a 64-bit integer to a BSON object. | |
| bson_cursor * | bson_cursor_new (const bson *b) |
| Create a new cursor. | |
| void | bson_cursor_free (bson_cursor *c) |
| Delete a cursor, and free up all resources used by it. | |
| gboolean | bson_cursor_next (bson_cursor *c) |
| Position the cursor to the next key. | |
| gboolean | bson_cursor_find (bson_cursor *c, const gchar *name) |
| Move the cursor to a given key. | |
| gboolean | bson_cursor_find_next (bson_cursor *c, const gchar *name) |
| Move the cursor to a given key, past the current one. | |
| bson_cursor * | bson_find (const bson *b, const gchar *name) |
| Create a new cursor positioned at a given key. | |
| bson_type | bson_cursor_type (const bson_cursor *c) |
| Determine the type of the current element. | |
| const gchar * | bson_cursor_type_as_string (const bson_cursor *c) |
| Retrieve the type of the current element, as string. | |
| const gchar * | bson_cursor_key (const bson_cursor *c) |
| Determine the name of the current elements key. | |
| gboolean | bson_cursor_get_string (const bson_cursor *c, const gchar **dest) |
| Get the value stored at the cursor, as string. | |
| gboolean | bson_cursor_get_double (const bson_cursor *c, gdouble *dest) |
| Get the value stored at the cursor, as a double. | |
| gboolean | bson_cursor_get_document (const bson_cursor *c, bson **dest) |
| Get the value stored at the cursor, as a BSON document. | |
| gboolean | bson_cursor_get_array (const bson_cursor *c, bson **dest) |
| Get the value stored at the cursor, as a BSON array. | |
| gboolean | bson_cursor_get_binary (const bson_cursor *c, bson_binary_subtype *subtype, const guint8 **data, gint32 *size) |
| Get the value stored at the cursor, as binary data. | |
| gboolean | bson_cursor_get_oid (const bson_cursor *c, const guint8 **dest) |
| Get the value stored at the cursor, as an ObjectID. | |
| gboolean | bson_cursor_get_boolean (const bson_cursor *c, gboolean *dest) |
| Get the value stored at the cursor, as a boolean. | |
| gboolean | bson_cursor_get_utc_datetime (const bson_cursor *c, gint64 *dest) |
| Get the value stored at the cursor, as an UTC datetime. | |
| gboolean | bson_cursor_get_regex (const bson_cursor *c, const gchar **regex, const gchar **options) |
| Get the value stored at the cursor, as a regexp. | |
| gboolean | bson_cursor_get_javascript (const bson_cursor *c, const gchar **dest) |
| Get the value stored at the cursor, as javascript code. | |
| gboolean | bson_cursor_get_symbol (const bson_cursor *c, const gchar **dest) |
| Get the value stored at the cursor, as a symbol. | |
| gboolean | bson_cursor_get_javascript_w_scope (const bson_cursor *c, const gchar **js, bson **scope) |
| Get the value stored at the cursor, as javascript code w/ scope. | |
| gboolean | bson_cursor_get_int32 (const bson_cursor *c, gint32 *dest) |
| Get the value stored at the cursor, as a 32-bit integer. | |
| gboolean | bson_cursor_get_timestamp (const bson_cursor *c, gint64 *dest) |
| Get the value stored at the cursor, as a timestamp. | |
| gboolean | bson_cursor_get_int64 (const bson_cursor *c, gint64 *dest) |
| Get the value stored at the cursor, as a 64-bit integer. | |
Implementation of the BSON API.
Definition in file bson.c.
| #define _bson_build_add_single | ( | b, | |
| type, | |||
| name, | |||
| free_after, | |||
| ap | |||
| ) |
Add a single element of any type to a BSON object.
Used internally by bson_build() and bson_build_full(), this function adds a single element of any supported type to the target BSON object.
| b | is the target BSON object. |
| type | is the element type to add. |
| name | is the key name. |
| free_after | signals whether to free the values after adding them. |
| ap | is the list of remaining parameters. |
| #define BSON_CURSOR_CHECK_TYPE | ( | c, | |
| type | |||
| ) |
if (bson_cursor_type(c) != type) \ return FALSE;
Convenience macro to verify a cursor's type.
Verifies that the cursor's type is the same as the type requested by the caller, and returns FALSE if there is a mismatch.
1.7.4