Skip to content

Commit 91bf087

Browse files
authored
C Docs Migration: format edits (#1)
* Libbson and libmongoc * More format edits * rest of libbson files * libmongoc formatting * directive issues * more libbson fixes * add example folder
1 parent 3f8ee56 commit 91bf087

File tree

1,042 files changed

+42128
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,042 files changed

+42128
-0
lines changed

source/docs-libbson/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.7
2+
*.pyc
3+
.doctrees
4+
objects.inv
5+
html/*.html
6+
html/*.css
7+
html/*.js
8+
html/*.png
9+
html/_sources
10+
html/_static
11+
html/.buildinfo
12+
html/.nojekyll
13+
man/*.3
14+
man/.buildinfo

source/docs-libbson/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include (SphinxBuild)
2+
3+
if (ENABLE_HTML_DOCS)
4+
sphinx_build_html (bson-html libbson)
5+
endif ()
6+
7+
if (ENABLE_MAN_PAGES)
8+
sphinx_build_man (bson-man)
9+
endif ()

source/docs-libbson/api.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=============
2+
API Reference
3+
=============
4+
5+
.. toctree::
6+
:titlesonly:
7+
:maxdepth: 2
8+
9+
bson_t
10+
bson_array_builder_t
11+
bson_context_t
12+
bson_decimal128_t
13+
bson_error_t
14+
bson_iter_t
15+
bson_json_reader_t
16+
bson_oid_t
17+
bson_reader_t
18+
character_and_string_routines
19+
bson_string_t
20+
bson_subtype_t
21+
bson_type_t
22+
bson_unichar_t
23+
bson_value_t
24+
bson_visitor_t
25+
bson_writer_t
26+
bson_get_monotonic_time
27+
bson_memory
28+
version
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. _bson_aligned_alloc:
2+
3+
====================
4+
bson_aligned_alloc()
5+
====================
6+
7+
Synopsis
8+
--------
9+
10+
.. code-block:: c
11+
12+
void *
13+
bson_aligned_alloc (size_t alignment, size_t num_bytes);
14+
15+
Parameters
16+
----------
17+
18+
- ``alignment``: The alignment of the allocated bytes of memory. Must be a power of 2 and a multiple
19+
of ``sizeof (void *)``.
20+
- ``num_bytes``: The number of bytes to allocate. Must be a multiple of ``alignment``.
21+
22+
Description
23+
-----------
24+
25+
This is a portable ``aligned_alloc()`` wrapper.
26+
27+
In general, this function will return an allocation at least ``sizeof(void*)`` bytes or bigger with an
28+
alignment of at least ``alignment``.
29+
30+
If there was a failure to allocate ``num_bytes`` bytes aligned to ``alignment``, the process will be aborted.
31+
32+
.. warning::
33+
34+
This function will abort on failure to allocate memory.
35+
36+
Returns
37+
-------
38+
39+
A pointer to a memory region which *HAS NOT* been zeroed.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. _bson_aligned_alloc0:
2+
3+
=====================
4+
bson_aligned_alloc0()
5+
=====================
6+
7+
Synopsis
8+
--------
9+
10+
.. code-block:: c
11+
12+
void *
13+
bson_aligned_alloc0 (size_t alignment, size_t num_bytes);
14+
15+
Parameters
16+
----------
17+
18+
- ``alignment``: The alignment of the allocated bytes of memory. Must be a power of 2 and
19+
a multiple of ``sizeof (void *)``.
20+
- ``num_bytes``: The number of bytes to allocate. Must be a multiple of ``alignment``.
21+
22+
Description
23+
-----------
24+
25+
This is a portable ``aligned_alloc()`` wrapper that also sets the memory to zero.
26+
27+
In general, this function will return an allocation at least ``sizeof(void*)`` bytes or bigger with
28+
an alignment of at least ``alignment``.
29+
30+
If there was a failure to allocate ``num_bytes`` bytes aligned to ``alignment``, the process will
31+
be aborted.
32+
33+
.. warning::
34+
35+
This function will abort on failure to allocate memory.
36+
37+
Returns
38+
-------
39+
40+
A pointer to a memory region which *HAS* been zeroed.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.. _bson_append_array:
2+
3+
===================
4+
bson_append_array()
5+
===================
6+
7+
Synopsis
8+
--------
9+
10+
.. code-block:: c
11+
12+
#define BSON_APPEND_ARRAY(b, key, val) \
13+
bson_append_array (b, key, (int) strlen (key), val)
14+
15+
bool
16+
bson_append_array (bson_t *bson,
17+
const char *key,
18+
int key_length,
19+
const bson_t *array);
20+
21+
Parameters
22+
----------
23+
24+
- ``bson``: A :ref:`bson_t`.
25+
- ``key``: An ASCII C string containing the name of the field.
26+
- ``key_length``: The length of ``key`` in bytes, or -1 to determine the length with ``strlen()``.
27+
- ``array``: A :ref:`bson_t`.
28+
29+
Description
30+
-----------
31+
32+
The :ref:`bson_append_array()` function shall append ``array`` to ``bson`` using the specified
33+
key. The type of the field will be an array, but it is the responsibility of the caller to ensure
34+
that the keys of ``array`` are properly formatted with string keys such as "0", "1", "2" and so forth.
35+
36+
Returns
37+
-------
38+
39+
Returns ``true`` if the operation was applied successfully. The function fails if appending the array
40+
grows ``bson`` larger than INT32_MAX.
41+
42+
.. seealso::
43+
44+
| :ref:`bson_array_builder_t`
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. _bson_append_array_begin:
2+
3+
=========================
4+
bson_append_array_begin()
5+
=========================
6+
7+
Synopsis
8+
--------
9+
10+
.. code-block:: c
11+
12+
#define BSON_APPEND_ARRAY_BEGIN(b, key, child) \
13+
bson_append_array_begin (b, key, (int) strlen (key), child)
14+
15+
bool
16+
bson_append_array_begin (bson_t *bson,
17+
const char *key,
18+
int key_length,
19+
bson_t *child);
20+
21+
Parameters
22+
----------
23+
24+
- ``bson``: A :ref:`bson_t`.
25+
- ``key``: A string containing the name for the key.
26+
- ``key_length``: The length of ``key`` or -1 to call ``strlen()``.
27+
- ``child``: A :ref:`bson_t`.
28+
29+
Description
30+
-----------
31+
32+
The :ref:`bson_append_array_begin` function shall begin appending an array field to
33+
``bson``. This allows for incrementally building a sub-array. Doing so will generally yield
34+
better performance as you will serialize to a single buffer. When done building the sub-array,
35+
the caller *MUST* call :ref:`bson_append_array_end`.
36+
37+
For generating array element keys, see :ref:`bson_uint32_to_string`.
38+
39+
Consider using :ref:`bson_array_builder_t` to append an array without needing to generate
40+
array element keys.
41+
42+
Returns
43+
-------
44+
45+
Returns ``true`` if the operation was applied successfully. The function will fail if appending
46+
the array grows ``bson`` larger than INT32_MAX.
47+
48+
.. seealso::
49+
50+
| :ref:`bson_array_builder_t`
51+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.. _bson_append_array_end:
2+
3+
=======================
4+
bson_append_array_end()
5+
=======================
6+
7+
Synopsis
8+
--------
9+
10+
.. code-block:: c
11+
12+
bool
13+
bson_append_array_end (bson_t *bson, bson_t *child);
14+
15+
Parameters
16+
----------
17+
18+
- ``bson``: A :ref:`bson_t`.
19+
- ``child``: The :ref:`bson_t` initialized in a call to :ref:`bson_append_array_begin()`.
20+
21+
Description
22+
-----------
23+
24+
The :ref:`bson_append_array_end()` function shall complete the appending of an array field
25+
started with :ref:`bson_append_array_begin()`. ``child`` is invalid after calling this function.
26+
27+
Returns
28+
-------
29+
30+
Returns ``true`` if successful.
31+
32+
.. seealso::
33+
34+
| :ref:`bson_array_builder_t`
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.. _bson_append_binary:
2+
3+
====================
4+
bson_append_binary()
5+
====================
6+
7+
Synopsis
8+
--------
9+
10+
.. code-block:: c
11+
12+
#define BSON_APPEND_BINARY(b, key, subtype, val, len) \
13+
bson_append_binary (b, key, (int) strlen (key), subtype, val, len)
14+
15+
bool
16+
bson_append_binary (bson_t *bson,
17+
const char *key,
18+
int key_length,
19+
bson_subtype_t subtype,
20+
const uint8_t *binary,
21+
uint32_t length);
22+
23+
Parameters
24+
----------
25+
26+
- ``bson``: A :ref:`bson_t`.
27+
- ``key``: The key name.
28+
- ``key_length``: The length of ``key`` in bytes or -1 to use strlen().
29+
- ``subtype``: A bson_subtype_t indicating the binary subtype.
30+
- ``binary``: A buffer to embed as binary data. May be ``NULL`` for an empty binary value.
31+
- ``length``: The length of ``buffer`` in bytes. Must be ``0`` if ``binary`` is NULL.
32+
33+
Description
34+
-----------
35+
36+
The :ref:`bson_append_binary()` function shall append a new element to ``bson`` containing
37+
the binary data provided.
38+
39+
Returns
40+
-------
41+
42+
Returns ``true`` if the operation was applied successfully. The function will fail if appending
43+
``binary`` grows ``bson`` larger than INT32_MAX.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _bson_append_bool:
2+
3+
==================
4+
bson_append_bool()
5+
==================
6+
7+
Synopsis
8+
--------
9+
10+
.. code-block:: c
11+
12+
#define BSON_APPEND_BOOL(b, key, val) \
13+
bson_append_bool (b, key, (int) strlen (key), val)
14+
15+
bool
16+
bson_append_bool (bson_t *bson, const char *key, int key_length, bool value);
17+
18+
Parameters
19+
----------
20+
21+
- ``bson``: A :ref:`bson_t`.
22+
- ``key``: The name of the field.
23+
- ``key_length``: The length of ``key`` or -1 to use strlen().
24+
- ``value``: true or false.
25+
26+
Description
27+
-----------
28+
29+
The :ref:`bson_append_bool` function shall append a new element to ``bson`` containing the
30+
boolean provided.
31+
32+
Returns
33+
-------
34+
35+
Returns ``true`` if the operation was applied successfully. The function will fail if appending
36+
the value grows ``bson`` larger than INT32_MAX.

0 commit comments

Comments
 (0)