bson_string_t (3) - Linux Manuals
bson_string_t: String Building Abstraction
Command to display bson_string_t
manual in Linux: $ man 3 bson_string_t
NAME
bson_string_t - String Building Abstraction
SYNOPSIS
#include <bson.h>
typedef struct
{
char *str;
uint32_t len;
uint32_t alloc;
} bson_string_t;
DESCRIPTION
bson_string_t
is an abstraction for building strings. As chunks are added to the string, allocations are performed in powers of two.
This API is useful if you need to build UTF-8 encoded strings.
EXAMPLE
bson_string_t *str;
str = bson_string_new (NULL);
bson_string_append_printf (str, "%d %s %f\n", 0, "some string", 0.123);
printf ("%s\n", str->str);
bson_string_free (str, true);
NOTE
-
You can call
bson_string_free(3)
with
false
if you would like to take ownership of
str->str
\&. Some APIs that do this might call
return bson_string_free (str, false);
after building the string.
COLOPHON
This page is part of libbson.
Please report any bugs at
https://jira.mongodb.org/browse/CDRIVER.
Pages related to bson_string_t
- bson_string_truncate (3) - Truncates the string so that it is len bytes in length. This must be smaller or equal to the current length of the string.
- bson_string_append (3) - Appends the ASCII or UTF-8 encoded string str to string. This is not suitable for embedding NULLs in strings.
- bson_string_append_c (3) - Appends c to the string builder string.
- bson_string_append_printf (3) - Like bson_string_append() but formats a printf style string and then appends that to string.
- bson_string_append_unichar (3) - Appends a unicode character to string. The character will be encoded into its multi-byte UTF-8 representation.
- bson_string_free (3) - Frees the bson_string_t structure and optionally the string itself.
- bson_string_new (3) - Creates a new string builder, which uses power-of-two growth of buffers. Use the various bson_string_append*() functions to append to the string.
- bson_strdup (3) - Copies str into a new string. If str is NULL, then NULL is returned.
- bson_strdup_printf (3) - This function performs a printf style format but into a newly allocated string.
- bson_strdupv_printf (3) - This function is like bson_strdup_printf() except takes a va_list of parameters.
- bson_strerror_r (3) - This is a portability wrapper around strerror().
- bson_strfreev (3) - This will free each string in a NULL-terminated array of strings and then the array itself.