libmongo-client  0.1.9
Functions
Appending
BSON

Functions to append various kinds of elements to existing BSON objects. More...

Collaboration diagram for Appending:

Functions

gboolean bson_append_string (bson *b, const gchar *name, const gchar *val, gint32 length)
 Append a string to a BSON object.
gboolean bson_append_double (bson *b, const gchar *name, gdouble d)
 Append a double 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.

Detailed Description

Functions to append various kinds of elements to existing BSON objects.

Every such function expects the BSON object to be open, and will return FALSE immediately if it finds that the object has had bson_finish() called on it before.

The only way to append to a finished BSON object is to clone it with bson_new_from_data(), and append to the newly created object.


Function Documentation

gboolean bson_append_array ( bson *  b,
const gchar *  name,
const bson *  array 
)

Append a BSON array to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
arrayis the BSON array to append.
Note:
array MUST be a finished BSON document.
The difference between plain documents and arrays - as far as this library is concerned, and apart from the type - is that array keys must be numbers in increasing order. However, no extra care is taken to verify that: it is the responsibility of the caller to set the array up appropriately.
Returns:
TRUE on success, FALSE otherwise.
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.

Parameters:
bis the BSON object to append to.
nameis the key name.
subtypeis the BSON binary subtype to use.
datais a pointer to the blob data.
sizeis the size of the blob.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_boolean ( bson *  b,
const gchar *  name,
gboolean  value 
)

Append a boolean to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
valueis the boolean value to append.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_document ( bson *  b,
const gchar *  name,
const bson *  doc 
)

Append a BSON document to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
docis the BSON document to append.
Note:
doc MUST be a finished BSON document.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_double ( bson *  b,
const gchar *  name,
gdouble  d 
)

Append a double to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
dis the double value to append.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_int32 ( bson *  b,
const gchar *  name,
gint32  i 
)

Append a 32-bit integer to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
iis the integer to append.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_int64 ( bson *  b,
const gchar *  name,
gint64  i 
)

Append a 64-bit integer to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
iis the integer to append.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_javascript ( bson *  b,
const gchar *  name,
const gchar *  js,
gint32  len 
)

Append Javascript code to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
jsis the javascript code as a C string.
lenis the length of the code, use -1 to use the full length of the string supplised in js.
Returns:
TRUE on success, FALSE otherwise.
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.

Parameters:
bis the BSON object to append to.
nameis the key name.
jsis the javascript code as a C string.
lenis the length of the code, use -1 to use the full length of the string supplied in js.
scopeis scope to evaluate the javascript code in.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_null ( bson *  b,
const gchar *  name 
)

Append a NULL value to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_oid ( bson *  b,
const gchar *  name,
const guint8 *  oid 
)

Append an ObjectID to a BSON object.

ObjectIDs are 12 byte values, the first four being a timestamp in big endian byte order, the next three a machine ID, then two bytes for the PID, and finally three bytes of sequence number, in big endian byte order again.

Parameters:
bis the BSON object to append to.
nameis the key name.
oidis the ObjectID to append.
Note:
The OID must be 12 bytes long, and formatting it appropriately is the responsiblity of the caller.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_regex ( bson *  b,
const gchar *  name,
const gchar *  regexp,
const gchar *  options 
)

Append a regexp object to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
regexpis the regexp string itself.
optionsrepresents the regexp options, serialised to a string.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_string ( bson *  b,
const gchar *  name,
const gchar *  val,
gint32  length 
)

Append a string to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
valis the value to append.
lengthis the length of value. Use -1 to use the full string supplied as name.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_symbol ( bson *  b,
const gchar *  name,
const gchar *  symbol,
gint32  len 
)

Append a symbol to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
symbolis the symbol to append.
lenis the length of the code, use -1 to use the full length of the string supplised in symbol.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_timestamp ( bson *  b,
const gchar *  name,
gint64  ts 
)

Append a timestamp to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
tsis the timestamp to append.
Note:
The ts param should consists of 4 bytes of increment, followed by 4 bytes of timestamp. It is the responsibility of the caller to set the variable up appropriately.
Returns:
TRUE on success, FALSE otherwise.
gboolean bson_append_utc_datetime ( bson *  b,
const gchar *  name,
gint64  ts 
)

Append an UTC datetime to a BSON object.

Parameters:
bis the BSON object to append to.
nameis the key name.
tsis the UTC timestamp: the number of milliseconds since the Unix epoch.
Returns:
TRUE on success, FALSE otherwise.
 All Data Structures Variables