BSON-XS
view release on metacpan or search on metacpan
bson/bson.c view on Meta::CPAN
/*
*--------------------------------------------------------------------------
*
* bson_append_document --
*
* Append a new field to @bson containing a BSON document.
*
* In general, using bson_append_document_begin() results in faster
* code and less memory fragmentation.
*
* Returns:
* true if successful; otherwise false.
*
* Side effects:
* None.
*
* See also:
* bson_append_document_begin().
*
bson/bson.h view on Meta::CPAN
size_t length);
/**
* bson_init:
* @b: A pointer to a bson_t.
*
* Initializes a bson_t for use. This function is useful to those that want a
* stack allocated bson_t. The usefulness of a stack allocated bson_t is
* marginal as the target buffer for content will still require heap
* allocations. It can help reduce heap fragmentation on allocators that do
* not employ SLAB/magazine semantics.
*
* You must call bson_destroy() with @b to release resources when you are done
* using @b.
*/
void
bson_init (bson_t *b);
/**
bson/bson.h view on Meta::CPAN
* @key: The key for the field.
* @key_length: The length of @key in bytes not including NUL or -1
* if @key_length is NUL terminated.
* @child: A location to an uninitialized bson_t.
*
* Appends a new field named @key to @bson. The field is, however,
* incomplete. @child will be initialized so that you may add fields to the
* child document. Child will use a memory buffer owned by @bson and
* therefore grow the parent buffer as additional space is used. This allows
* a single malloc'd buffer to be used when building documents which can help
* reduce memory fragmentation.
*
* Returns: true if successful; false if append would overflow max size.
*/
bool
bson_append_document_begin (bson_t *bson,
const char *key,
int key_length,
bson_t *child);
bson/bson.h view on Meta::CPAN
* @key: The key for the field.
* @key_length: The length of @key in bytes not including NUL or -1
* if @key_length is NUL terminated.
* @child: A location to an uninitialized bson_t.
*
* Appends a new field named @key to @bson. The field is, however,
* incomplete. @child will be initialized so that you may add fields to the
* child array. Child will use a memory buffer owned by @bson and
* therefore grow the parent buffer as additional space is used. This allows
* a single malloc'd buffer to be used when building arrays which can help
* reduce memory fragmentation.
*
* The type of @child will be BSON_TYPE_ARRAY and therefore the keys inside
* of it MUST be "0", "1", etc.
*
* Returns: true if successful; false if append would overflow max size.
*/
bool
bson_append_array_begin (bson_t *bson,
const char *key,
int key_length,
/* BSON decoding
*
* Public function _decode_bson is the entry point. It calls
* bson_doc_to_hashref, which construct a container and fills it using
* bson_elem_to_sv. That may call bson_doc_to_hashref or
* bson_doc_to_arrayref to decode sub-containers.
*
* The bson_oid_to_sv function manually constructs a BSON::OID object to
* avoid the overhead of calling its constructor. This optimization is
* fragile and might need to be reconsidered.
*
*/
static SV * bson_doc_to_hashref(bson_iter_t * iter, HV *opts, int depth, bool top);
static SV * bson_doc_to_tiedhash(bson_iter_t * iter, HV *opts, int depth, bool top);
static SV * bson_array_to_arrayref(bson_iter_t * iter, HV *opts, int depth);
static SV * bson_elem_to_sv(const bson_iter_t * iter, const char *key, HV *opts, int depth);
static SV * bson_oid_to_sv(const bson_iter_t * iter);
/********************************************************************
( run in 0.867 second using v1.01-cache-2.11-cpan-364913b4093 )