librpc
|
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <sys/uio.h>
#include <sys/types.h>
Go to the source code of this file.
Macros | |
#define | RPC_ARRAY_APPLIER(_fn, _arg) |
#define | RPC_DICTIONARY_APPLIER(_fn, _arg) |
#define | RPC_ARRAY_CMP(_fn, _arg) |
#define | RPC_BINARY_DESTRUCTOR(_fn) |
#define | RPC_BINARY_DESTRUCTOR_ARG(_fn, _arg) |
#define | rpc_is_error(_object) (rpc_get_type(_object) == RPC_TYPE_ERROR) |
#define | rpc_release(_object) |
#define | rpc_swap(_old, _new) |
#define | rpc_auto_object_t __attribute__((cleanup(__rpc_raii_release))) rpc_object_t |
Typedefs | |
typedef struct rpc_object * | rpc_object_t |
typedef bool(^ | rpc_array_applier_t) (size_t index, _Nonnull rpc_object_t value) |
typedef _Nonnull rpc_object_t(^ | rpc_array_mapper_t) (size_t index, _Nonnull rpc_object_t value) |
typedef bool(^ | rpc_dictionary_applier_t) (const char *_Nonnull key, _Nonnull rpc_object_t value) |
typedef _Nonnull rpc_object_t(^ | rpc_dictionary_mapper_t) (const char *_Nonnull key, _Nonnull rpc_object_t value) |
typedef int(^ | rpc_array_cmp_t) (_Nonnull rpc_object_t o1, _Nonnull rpc_object_t o2) |
typedef void(^ | rpc_binary_destructor_t) (void *_Nullable) |
Functions | |
_Nonnull rpc_object_t | rpc_retain (_Nonnull rpc_object_t object) |
int | rpc_release_impl (_Nonnull rpc_object_t object) |
int | rpc_get_refcount (_Nullable rpc_object_t object) |
size_t | rpc_get_line_number (_Nonnull rpc_object_t object) |
size_t | rpc_get_column_number (_Nonnull rpc_object_t object) |
_Nonnull rpc_object_t | rpc_copy (_Nonnull rpc_object_t object) |
int | rpc_cmp (_Nullable rpc_object_t o1, _Nullable rpc_object_t o2) |
bool | rpc_equal (_Nullable rpc_object_t o1, _Nullable rpc_object_t o2) |
size_t | rpc_hash (_Nonnull rpc_object_t object) |
char *_Nonnull | rpc_copy_description (_Nonnull rpc_object_t object) |
rpc_type_t | rpc_get_type (_Nonnull rpc_object_t object) |
const char *_Nullable | rpc_get_type_name (rpc_type_t type) |
_Nullable rpc_object_t | rpc_get_last_error (void) |
_Nullable rpc_object_t | rpc_object_pack (const char *_Nonnull fmt,...) |
_Nullable rpc_object_t | rpc_object_vpack (const char *_Nonnull fmt, va_list ap) |
int | rpc_object_unpack (_Nonnull rpc_object_t, const char *_Nonnull fmt,...) |
int | rpc_object_vunpack (_Nonnull rpc_object_t, const char *_Nonnull fmt, va_list ap) |
_Nonnull rpc_object_t | rpc_null_create (void) |
_Nonnull rpc_object_t | rpc_bool_create (bool value) |
bool | rpc_bool_get_value (_Nonnull rpc_object_t xbool) |
_Nonnull rpc_object_t | rpc_int64_create (int64_t value) |
int64_t | rpc_int64_get_value (_Nonnull rpc_object_t xint) |
_Nonnull rpc_object_t | rpc_uint64_create (uint64_t value) |
uint64_t | rpc_uint64_get_value (_Nonnull rpc_object_t xuint) |
_Nonnull rpc_object_t | rpc_double_create (double value) |
double | rpc_double_get_value (_Nonnull rpc_object_t xdouble) |
_Nonnull rpc_object_t | rpc_date_create (int64_t interval) |
_Nonnull rpc_object_t | rpc_date_create_from_current (void) |
int64_t | rpc_date_get_value (_Nonnull rpc_object_t xdate) |
_Nonnull rpc_object_t | rpc_data_create (const void *_Nullable bytes, size_t length, _Nullable rpc_binary_destructor_t destructor) |
_Nonnull rpc_object_t | rpc_data_create_iov (struct iovec *_Nonnull iov, size_t niov) |
size_t | rpc_data_get_length (_Nonnull rpc_object_t xdata) |
const void *_Nullable | rpc_data_get_bytes_ptr (_Nonnull rpc_object_t xdata) |
size_t | rpc_data_get_bytes (_Nonnull rpc_object_t xdata, void *_Nonnull buffer, size_t off, size_t length) |
_Nonnull rpc_object_t | rpc_string_create (const char *_Nonnull string) |
_Nonnull rpc_object_t | rpc_string_create_len (const char *_Nonnull string, size_t length) |
_Nonnull rpc_object_t | rpc_string_create_with_format (const char *_Nonnull fmt,...) |
_Nonnull rpc_object_t | rpc_string_create_with_format_and_arguments (const char *_Nonnull fmt, va_list ap) |
size_t | rpc_string_get_length (_Nonnull rpc_object_t xstring) |
const char *_Nullable | rpc_string_get_string_ptr (_Nonnull rpc_object_t xstring) |
_Nonnull rpc_object_t | rpc_fd_create (int fd) |
int | rpc_fd_dup (_Nonnull rpc_object_t xfd) |
int | rpc_fd_get_value (_Nonnull rpc_object_t xfd) |
_Nonnull rpc_object_t | rpc_array_create (void) |
_Nonnull rpc_object_t | rpc_array_create_ex (const _Nonnull rpc_object_t *_Nonnull objects, size_t count, bool steal) |
void | rpc_array_set_value (_Nonnull rpc_object_t array, size_t index, _Nullable rpc_object_t value) |
void | rpc_array_steal_value (_Nonnull rpc_object_t array, size_t index, _Nullable rpc_object_t value) |
void | rpc_array_remove_index (_Nonnull rpc_object_t array, size_t index) |
void | rpc_array_remove_all (_Nonnull rpc_object_t array) |
void | rpc_array_append_value (_Nonnull rpc_object_t array, _Nonnull rpc_object_t value) |
void | rpc_array_append_stolen_value (_Nonnull rpc_object_t array, _Nonnull rpc_object_t value) |
_Nullable rpc_object_t | rpc_array_get_value (_Nonnull rpc_object_t array, size_t index) |
size_t | rpc_array_get_count (_Nonnull rpc_object_t array) |
bool | rpc_array_apply (_Nonnull rpc_object_t array, _Nonnull rpc_array_applier_t applier) |
void | rpc_array_map (_Nonnull rpc_object_t array, _Nonnull rpc_array_mapper_t mapper) |
bool | rpc_array_contains (_Nonnull rpc_object_t array, _Nonnull rpc_object_t value) |
bool | rpc_array_reverse_apply (_Nonnull rpc_object_t array, _Nonnull rpc_array_applier_t applier) |
void | rpc_array_sort (_Nonnull rpc_object_t array, _Nonnull rpc_array_cmp_t comparator) |
_Nonnull rpc_object_t | rpc_array_slice (_Nonnull rpc_object_t array, size_t start, ssize_t len) |
void | rpc_array_set_bool (_Nonnull rpc_object_t array, size_t index, bool value) |
void | rpc_array_set_int64 (_Nonnull rpc_object_t array, size_t index, int64_t value) |
void | rpc_array_set_uint64 (_Nonnull rpc_object_t array, size_t index, uint64_t value) |
void | rpc_array_set_double (_Nonnull rpc_object_t array, size_t index, double value) |
void | rpc_array_set_date (_Nonnull rpc_object_t array, size_t index, int64_t value) |
void | rpc_array_set_data (_Nonnull rpc_object_t array, size_t index, const void *_Nullable bytes, size_t length) |
void | rpc_array_set_string (_Nonnull rpc_object_t array, size_t index, const char *_Nonnull value) |
void | rpc_array_set_fd (_Nonnull rpc_object_t array, size_t index, int value) |
bool | rpc_array_get_bool (_Nonnull rpc_object_t array, size_t index) |
int64_t | rpc_array_get_int64 (_Nonnull rpc_object_t array, size_t index) |
uint64_t | rpc_array_get_uint64 (_Nonnull rpc_object_t array, size_t index) |
double | rpc_array_get_double (_Nonnull rpc_object_t array, size_t index) |
int64_t | rpc_array_get_date (_Nonnull rpc_object_t array, size_t index) |
const void *_Nullable | rpc_array_get_data (_Nonnull rpc_object_t array, size_t index, size_t *_Nullable length) |
const char *_Nullable | rpc_array_get_string (_Nonnull rpc_object_t array, size_t index) |
int | rpc_array_get_fd (_Nonnull rpc_object_t array, size_t index) |
int | rpc_array_dup_fd (_Nonnull rpc_object_t array, size_t index) |
_Nonnull rpc_object_t | rpc_error_create (int code, const char *_Nonnull msg, _Nullable rpc_object_t extra) |
_Nonnull rpc_object_t | rpc_error_create_with_stack (int code, const char *_Nonnull msg, _Nullable rpc_object_t extra, _Nullable rpc_object_t stack) |
int | rpc_error_get_code (_Nonnull rpc_object_t error) |
const char *_Nullable | rpc_error_get_message (_Nonnull rpc_object_t error) |
_Nullable rpc_object_t | rpc_error_get_extra (_Nonnull rpc_object_t error) |
void | rpc_error_set_extra (_Nonnull rpc_object_t error, _Nonnull rpc_object_t extra) |
_Nullable rpc_object_t | rpc_error_get_stack (_Nonnull rpc_object_t error) |
_Nonnull rpc_object_t | rpc_dictionary_create (void) |
_Nonnull rpc_object_t | rpc_dictionary_create_ex (const char *const _Nonnull *_Nullable keys, const _Nonnull rpc_object_t *_Nullable values, size_t count, bool steal) |
void | rpc_dictionary_set_value (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, _Nonnull rpc_object_t value) |
void | rpc_dictionary_steal_value (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, rpc_object_t _Nonnull value) |
void | rpc_dictionary_remove_key (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
void | rpc_dictionary_remove_all (_Nonnull rpc_object_t dictionary) |
_Nullable rpc_object_t | rpc_dictionary_detach_key (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
_Nullable rpc_object_t | rpc_dictionary_get_value (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
size_t | rpc_dictionary_get_count (_Nonnull rpc_object_t dictionary) |
bool | rpc_dictionary_apply (_Nonnull rpc_object_t dictionary, _Nonnull rpc_dictionary_applier_t applier) |
void | rpc_dictionary_map (_Nonnull rpc_object_t dictionary, _Nonnull rpc_dictionary_mapper_t mapper) |
bool | rpc_dictionary_has_key (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
void | rpc_dictionary_set_bool (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, bool value) |
void | rpc_dictionary_set_int64 (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, int64_t value) |
void | rpc_dictionary_set_uint64 (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, uint64_t value) |
void | rpc_dictionary_set_double (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, double value) |
void | rpc_dictionary_set_date (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, int64_t value) |
void | rpc_dictionary_set_data (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, const void *_Nonnull value, size_t length) |
void | rpc_dictionary_set_string (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, const char *_Nonnull value) |
void | rpc_dictionary_set_fd (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, int value) |
bool | rpc_dictionary_get_bool (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
int64_t | rpc_dictionary_get_int64 (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
uint64_t | rpc_dictionary_get_uint64 (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
double | rpc_dictionary_get_double (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
int64_t | rpc_dictionary_get_date (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
const void *_Nullable | rpc_dictionary_get_data (_Nonnull rpc_object_t dictionary, const char *_Nonnull key, size_t *_Nullable length) |
const char *_Nullable | rpc_dictionary_get_string (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
int | rpc_dictionary_get_fd (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
int | rpc_dictionary_dup_fd (_Nonnull rpc_object_t dictionary, const char *_Nonnull key) |
Object model (boxed types) API.
Definition in file object.h.
#define RPC_ARRAY_APPLIER | ( | _fn, | |
_arg | |||
) |
Converts function pointer to an rpc_array_applier_t block type.
#define RPC_ARRAY_CMP | ( | _fn, | |
_arg | |||
) |
Converts function pointer to an rpc_array_cmp_t block type.
#define rpc_auto_object_t __attribute__((cleanup(__rpc_raii_release))) rpc_object_t |
RAII version of rpc_object_t. Automatically released when goes out of scope.
#define RPC_BINARY_DESTRUCTOR | ( | _fn | ) |
#define RPC_BINARY_DESTRUCTOR_ARG | ( | _fn, | |
_arg | |||
) |
Same as RPC_BINARY_DESTRUCTOR, but accepts an auxiliary arg
.
#define RPC_DICTIONARY_APPLIER | ( | _fn, | |
_arg | |||
) |
Converts function pointer to an rpc_dictionary_applier_t block type.
#define rpc_is_error | ( | _object | ) | (rpc_get_type(_object) == RPC_TYPE_ERROR) |
#define rpc_release | ( | _object | ) |
Decrements reference count of an object.
Also sets it to NULL if as a result of the operation reference count dropped to 0 and the object was freed.
_object | Object to release. |
#define rpc_swap | ( | _old, | |
_new | |||
) |
typedef bool(^ rpc_array_applier_t) (size_t index, _Nonnull rpc_object_t value) |
Definition of array applier block type.
Body of block is being executed for each of the array's elements, until generator reaches end of the array, or until applier block returns false.
index | Currently processed index. |
value | Object stored at currently processed index. |
typedef int(^ rpc_array_cmp_t) (_Nonnull rpc_object_t o1, _Nonnull rpc_object_t o2) |
Definition of array compare block type.
Body of block is being executed for pairs of array's members during sort operation.
The block should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second.
o1 | A value. |
o2 | A value to compare with. |
typedef void(^ rpc_binary_destructor_t) (void *_Nullable) |
typedef bool(^ rpc_dictionary_applier_t) (const char *_Nonnull key, _Nonnull rpc_object_t value) |
Definition of dictionary applier block type.
Body of block is being executed for each of the dictionary's elements, until generator reaches end of the dictionary, or until applier block returns false.
key | Currently processed key. |
value | Object stored at currently processed key. |
typedef struct rpc_object* rpc_object_t |
enum rpc_type_t |
Enumerates the possible types of an rpc_object_t.
void rpc_array_append_stolen_value | ( | _Nonnull rpc_object_t | array, |
_Nonnull rpc_object_t | value | ||
) |
Appends an object at the end of a provided array.
array | Input array. |
value | Object to be appended. |
void rpc_array_append_value | ( | _Nonnull rpc_object_t | array, |
_Nonnull rpc_object_t | value | ||
) |
Appends an object at the end of a provided array and increments object's refcount.
array | Input array. |
value | Object to be appended. |
bool rpc_array_apply | ( | _Nonnull rpc_object_t | array, |
_Nonnull rpc_array_applier_t | applier | ||
) |
Iterates over a given array. For each of elements executes an applier block, providing a current index and a current value an an applier block's arguments.
If an applier returns false, iteration is terminated and the function returns true (terminated). Otherwise the function iterates to the end of an input array and returns false (finished).
array | Input array. |
applier | Block of code to be executed for each array element. |
bool rpc_array_contains | ( | _Nonnull rpc_object_t | array, |
_Nonnull rpc_object_t | value | ||
) |
Checks if an entry with the same value as provided in the second argument of the function exists in a given array.
The function returns boolean result of that check.
array | Array to be searched. |
value | RPC object representing value of a searched object. |
_Nonnull rpc_object_t rpc_array_create | ( | void | ) |
_Nonnull rpc_object_t rpc_array_create_ex | ( | const _Nonnull rpc_object_t *_Nonnull | objects, |
size_t | count, | ||
bool | steal | ||
) |
Creates a new array of objects, optionally populating it with data.
objects | Array of objects to insert. |
count | Number of items in objects . |
steal | Reference vs. reference and increment refcount of elements in objects . |
int rpc_array_dup_fd | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Duplicates a file descriptor from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_FD), then the function returns 0.
array | Input array. |
index | File descriptor's index. |
bool rpc_array_get_bool | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_BOOL), then the function returns false.
array | Input array. |
index | Index storing an output value. |
size_t rpc_array_get_count | ( | _Nonnull rpc_object_t | array | ) |
Returns a number of elements in a provided array.
array | Input array. |
const void* _Nullable rpc_array_get_data | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
size_t *_Nullable | length | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_BINARY), then the function returns NULL.
array | Input array. |
index | Output value's index. |
length | Size of an output buffer. |
int64_t rpc_array_get_date | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_DATE), then the function returns 0.
array | Input array. |
index | Index storing an output value. |
double rpc_array_get_double | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_DOUBLE), then the function returns 0.
array | Input array. |
index | Index storing an output value. |
int rpc_array_get_fd | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_FD), then the function returns 0.
array | Input array. |
index | Index storing an output value. |
int64_t rpc_array_get_int64 | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_INT64), then the function returns 0.
array | Input array. |
index | Index storing an output value. |
const char* _Nullable rpc_array_get_string | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_STRING), then the function returns NULL.
array | Input array. |
index | Index storing an output value. |
uint64_t rpc_array_get_uint64 | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns a value from a given index of an input array.
If a selected index does not exist, or object being held at a given index has a type different from expected (RPC_TYPE_UINT64), then the function returns 0.
array | Input array. |
index | Index storing an output value. |
_Nullable rpc_object_t rpc_array_get_value | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Returns an object held by a provided array at a given index.
If a given index does not exist, then the function returns NULL.
array | Input array. |
index | Index of an object to be returned. |
void rpc_array_map | ( | _Nonnull rpc_object_t | array, |
_Nonnull rpc_array_mapper_t | mapper | ||
) |
Iterates over a given array and replaces each element of said array with a result of mapper block.
array | Input array |
mapper | Block of code to be executed for each array element |
void rpc_array_remove_all | ( | _Nonnull rpc_object_t | array | ) |
Removes all objects from a provided array.
array | Input array. |
void rpc_array_remove_index | ( | _Nonnull rpc_object_t | array, |
size_t | index | ||
) |
Removes an object from a given index of a provided array.
array | Input array. |
index | Index to be removed. |
bool rpc_array_reverse_apply | ( | _Nonnull rpc_object_t | array, |
_Nonnull rpc_array_applier_t | applier | ||
) |
Iterates over a given array in reversed order (starting from its end). Besides of that the function is acting exactly the same as rpc_array_apply.
array | Input array. |
applier | Block of code to be executed for each of an array's elements. |
void rpc_array_set_bool | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
bool | value | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given boolean value.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
value | Input value (boolean). |
void rpc_array_set_data | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
const void *_Nullable | bytes, | ||
size_t | length | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given binary data of a specified length.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
bytes | Input binary data buffer. |
length | Size of an input data buffer. |
void rpc_array_set_date | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
int64_t | value | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given UNIX timestamp value represented as an integer.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
value | Input value (UNIX timestamp represented as an integer). |
void rpc_array_set_double | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
double | value | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given double value.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
value | Input value (double). |
void rpc_array_set_fd | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
int | value | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given file descriptor value.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
value | Input file descriptor (integer). |
void rpc_array_set_int64 | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
int64_t | value | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given 64-bit signed integer value.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
value | Input value (64-bit signed integer). |
void rpc_array_set_string | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
const char *_Nonnull | value | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given string value.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
value | Input string (null byte terminated constant character pointer). |
void rpc_array_set_uint64 | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
uint64_t | value | ||
) |
Sets a selected index of an input array to a newly created RPC object holding a given 64-bit unsigned integer value.
If a selected index is larger than an input array size, then a gap between a last existing index and a requested index is filled with NULL objects.
array | Input array. |
index | Index to store an input value. |
value | Input value (64-bit unsigned integer). |
void rpc_array_set_value | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
_Nullable rpc_object_t | value | ||
) |
Inserts an object to array
at index
and increments value
refcount.
If index
is bigger than the array itself, gap will be filled with null objects.
If index
is already occupied, then a new object takes place of an old object and the refcount of an old object is decremented.
If array
is NULL, then this function removes an old object from index
.
array | Input array. |
value | Value to be inserted. |
index | Target index for a newly inserted value. |
_Nonnull rpc_object_t rpc_array_slice | ( | _Nonnull rpc_object_t | array, |
size_t | start, | ||
ssize_t | len | ||
) |
Takes an input array and copies a selected number of its elements, starting from a given index, creating an output array.
If a copy size is set to -1, then an output array is being created from input array's elements from a start index to the end of an input array.
If during a copy operation, the end of an input array is reached before size requirement is satisfied, then a copy operation is terminated and the function returns an array smaller than a requested size.
array | Input array. |
start | Copy start index. |
len | Requested copy size. |
void rpc_array_sort | ( | _Nonnull rpc_object_t | array, |
_Nonnull rpc_array_cmp_t | comparator | ||
) |
Sorts contents of a given array using provided comparator code block.
The desired behavior of the comparator block is described in rpc_array_cmp_t type's documentation.
array | Array to be sorted. |
comparator | Comparator to be used during sort operation. |
void rpc_array_steal_value | ( | _Nonnull rpc_object_t | array, |
size_t | index, | ||
_Nullable rpc_object_t | value | ||
) |
Inserts an object to an input array at a given index.
If an index is bigger than an array itself, gap will be filled with null objects.
If an index is already occupied, then a new object takes place of an old object and the refcount of an old object is decremented.
If an object is NULL, then this function removes an old object from a given index.
array | Input array. |
value | Value to be inserted. |
index | Target index for a newly inserted value. |
_Nonnull rpc_object_t rpc_bool_create | ( | bool | value | ) |
Creates an rpc_object_t holding boolean value.
value | Value of the object (true or false). |
bool rpc_bool_get_value | ( | _Nonnull rpc_object_t | xbool | ) |
Returns a boolean value of an object.
If rpc_object_t passed as the first argument if not of RPC_TYPE_BOOL type, the function returns false.
xbool | Object to read the value from. |
int rpc_cmp | ( | _Nullable rpc_object_t | o1, |
_Nullable rpc_object_t | o2 | ||
) |
Compares objects provided as the function arguments and returns the comparison result.
The function returns negative value if object passed in first argument is smaller than the object passed in the second argument.
The function returns zero if object passed in first argument is equal to the object passed in the second argument.
The function returns positive value if object passed in first argument is greater than the object passed in the second argument.
o1 | Object to be compared. |
o2 | Object to be compared. |
_Nonnull rpc_object_t rpc_copy | ( | _Nonnull rpc_object_t | object | ) |
Creates and returns independent copy of an object.
object | Object to be copied. |
char* _Nonnull rpc_copy_description | ( | _Nonnull rpc_object_t | object | ) |
Creates and returns null byte terminated human readable string representation of an object.
Caller has to take care of releasing resources held by returned value when it's not needed anymore.
object | Object to be represented as a human readable string. |
_Nonnull rpc_object_t rpc_data_create | ( | const void *_Nullable | bytes, |
size_t | length, | ||
_Nullable rpc_binary_destructor_t | destructor | ||
) |
Creates an RPC object holding a binary data.
bytes | Pointer to data buffer (void pointer). |
length | Length of the data buffer. |
destructor | Block to call once reference count drops to 0 (or NULL) |
_Nonnull rpc_object_t rpc_data_create_iov | ( | struct iovec *_Nonnull | iov, |
size_t | niov | ||
) |
The same as rpc_data_create, but takes iovec list as an argument and copies it into a new continuous data buffer.
iov | List of iovec to be copied. |
niov | Number of iovec in the iovec list. |
size_t rpc_data_get_bytes | ( | _Nonnull rpc_object_t | xdata, |
void *_Nonnull | buffer, | ||
size_t | off, | ||
size_t | length | ||
) |
Creates a copy of a slice of a internal data buffer of a provided object.
xdata | Input object. |
buffer | Output buffer. |
off | Start offset for the copy operation. |
length | Requested size of a copy. |
const void* _Nullable rpc_data_get_bytes_ptr | ( | _Nonnull rpc_object_t | xdata | ) |
Returns the pointer to internal binary data buffer of a provided object.
xdata | Input object |
size_t rpc_data_get_length | ( | _Nonnull rpc_object_t | xdata | ) |
Returns the length of internal binary data buffer of a provided object.
xdata | Input object |
_Nonnull rpc_object_t rpc_date_create | ( | int64_t | interval | ) |
Creates an RPC object holding a date.
interval | Value of the object (signed 64-bit integer). |
_Nonnull rpc_object_t rpc_date_create_from_current | ( | void | ) |
Creates an RPC object holding a date from current UTC time.
int64_t rpc_date_get_value | ( | _Nonnull rpc_object_t | xdate | ) |
Returns an integer value of an object (UNIX timestamp).
If rpc_object_t passed as the first argument if not of RPC_TYPE_DATE type, the function returns 0.
xdate | Object to read the value from. |
bool rpc_dictionary_apply | ( | _Nonnull rpc_object_t | dictionary, |
_Nonnull rpc_dictionary_applier_t | applier | ||
) |
Iterates over a given dictionary. For each of elements executes an applier block, providing a current key and a current value as an applier block's arguments.
If an applier returns false, iteration is terminated and the function returns true (terminated). Otherwise the function iterates to the end of an input array and returns false (finished).
dictionary | Input dictionary. |
applier | Block to be executed for each of an dictionary's elements. |
_Nonnull rpc_object_t rpc_dictionary_create | ( | void | ) |
Creates a new, empty dictionary of objects.
_Nonnull rpc_object_t rpc_dictionary_create_ex | ( | const char *const _Nonnull *_Nullable | keys, |
const _Nonnull rpc_object_t *_Nullable | values, | ||
size_t | count, | ||
bool | steal | ||
) |
Creates a new dictionary of objects, optionally populating it with data.
keys | Array of keys associated with values to insert. |
values | Array of objects to insert. |
count | Number of items in values. |
steal | Reference vs. reference and increment refcount of elements in values. |
_Nullable rpc_object_t rpc_dictionary_detach_key | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Removes a key from dictionary and returns it.
dictionary | Input dictionary |
key | Key to be detached |
int rpc_dictionary_dup_fd | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Duplicates a file descriptor from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_FD), then the function returns 0.
dictionary | Input dictionary. |
key | File descriptor's key. |
bool rpc_dictionary_get_bool | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_BOOL), then the function returns false.
dictionary | Input dictionary. |
key | Key storing an output value. |
size_t rpc_dictionary_get_count | ( | _Nonnull rpc_object_t | dictionary | ) |
Returns a number of elements in a provided dictionary.
dictionary | Input dictionary. |
const void* _Nullable rpc_dictionary_get_data | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
size_t *_Nullable | length | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_BINARY), then the function returns NULL.
dictionary | Input dictionary. |
key | Output value's key. |
length | Size of an output buffer. |
int64_t rpc_dictionary_get_date | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_DATE), then the function returns 0.
dictionary | Input dictionary. |
key | Key storing an output value. |
double rpc_dictionary_get_double | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_DOUBLE), then the function returns 0.
dictionary | Input dictionary. |
key | Key storing an output value. |
int rpc_dictionary_get_fd | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_FD), then the function returns 0.
dictionary | Input dictionary. |
key | Key storing an output value. |
int64_t rpc_dictionary_get_int64 | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_INT64), then the function returns 0.
dictionary | Input dictionary. |
key | Key storing an output value. |
const char* _Nullable rpc_dictionary_get_string | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_STRING), then the function returns NULL.
dictionary | Input dictionary. |
key | Key storing an output value. |
uint64_t rpc_dictionary_get_uint64 | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns a value from a given key of an input dictionary.
If a selected key does not exist, or object being held at a given key has a type different from expected (RPC_TYPE_UINT64), then the function returns 0.
dictionary | Input dictionary. |
key | Key storing an output value. |
_Nullable rpc_object_t rpc_dictionary_get_value | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Returns an object held by a provided dictionary at a given key.
If a given key does not exist, then the function returns NULL.
dictionary | Input dictionary. |
key | Key of an object to be returned. |
bool rpc_dictionary_has_key | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Checks if an input dictionary does have a given key set.
dictionary | Input dictionary. |
key | Key to be tested. |
void rpc_dictionary_map | ( | _Nonnull rpc_object_t | dictionary, |
_Nonnull rpc_dictionary_mapper_t | mapper | ||
) |
dictionary | |
mapper |
void rpc_dictionary_remove_all | ( | _Nonnull rpc_object_t | dictionary | ) |
Removes all keys and their associated values from a dictionary.
dictionary | Input dictionary. |
void rpc_dictionary_remove_key | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key | ||
) |
Removes an object from a given key of a provided dictionary.
dictionary | Input dictionary. |
key | Key to be removed. |
void rpc_dictionary_set_bool | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
bool | value | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given boolean value.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input value (boolean). |
void rpc_dictionary_set_data | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
const void *_Nonnull | value, | ||
size_t | length | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given binary data of a specified length.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input binary data buffer. |
length | Size of an input data buffer. |
void rpc_dictionary_set_date | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
int64_t | value | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given UNIX timestamp value represented as an integer.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input value (UNIX timestamp represented as an integer). |
void rpc_dictionary_set_double | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
double | value | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given double value.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input value (double). |
void rpc_dictionary_set_fd | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
int | value | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given file descriptor value.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input file descriptor (integer). |
void rpc_dictionary_set_int64 | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
int64_t | value | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given 64-bit signed integer value.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input value (64-bit signed integer). |
void rpc_dictionary_set_string | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
const char *_Nonnull | value | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given string value.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input string (null byte terminated constant character pointer). |
void rpc_dictionary_set_uint64 | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
uint64_t | value | ||
) |
Sets a selected key of an input dictionary to a newly created RPC object holding a given 64-bit unsigned integer value.
dictionary | Input dictionary. |
key | Key to store an input value. |
value | Input value (64-bit unsigned integer). |
void rpc_dictionary_set_value | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
_Nonnull rpc_object_t | value | ||
) |
Inserts an object to an input dictionary at a given key and increments object's refcount.
If a key is already occupied, then a new object takes place of an old object and the refcount of an old object is decremented.
If an object is NULL, then this function removes an old object stored at a given key.
dictionary | Input dictionary. |
key | Key to store a value. |
value | Value to be inserted. |
void rpc_dictionary_steal_value | ( | _Nonnull rpc_object_t | dictionary, |
const char *_Nonnull | key, | ||
rpc_object_t _Nonnull | value | ||
) |
Inserts an object to an input dictionary at a given key.
If a key is already occupied, then a new object takes place of an old object and the refcount of an old object is decremented.
If an object is NULL, then this function removes an old object stored at a given key.
dictionary | Input dictionary. |
key | Key to store a value. |
value | Value to be inserted. |
_Nonnull rpc_object_t rpc_double_create | ( | double | value | ) |
Creates an RPC object holding a double value.
value | Value of the object (double). |
double rpc_double_get_value | ( | _Nonnull rpc_object_t | xdouble | ) |
Returns a double value of an object.
If rpc_object_t passed as the first argument if not of RPC_TYPE_DOUBLE type, the function returns 0.
xdouble | Object to read the value from. |
bool rpc_equal | ( | _Nullable rpc_object_t | o1, |
_Nullable rpc_object_t | o2 | ||
) |
Compares objects provided as the function arguments and returns true if they are equivalent, otherwise returns false.
o1 | Object to be compared. |
o2 | Object to be compared. |
_Nonnull rpc_object_t rpc_error_create | ( | int | code, |
const char *_Nonnull | msg, | ||
_Nullable rpc_object_t | extra | ||
) |
Creates an RPC object representing an error condition with automatically extracted stack trace.
It can hold data about numerical error code, string describing the actual error in human readable format and extra auxiliary data.
Extra is an optional argument and can be safely set to NULL when not needed.
code | Numerical error code. |
msg | String representing an actual error description. |
extra | Extra data (optional). |
_Nonnull rpc_object_t rpc_error_create_with_stack | ( | int | code, |
const char *_Nonnull | msg, | ||
_Nullable rpc_object_t | extra, | ||
_Nullable rpc_object_t | stack | ||
) |
Creates an RPC object representing an error condition with externally provided extracted stack trace.
It can hold data about numerical error code, string describing the actual error in human readable format and extra auxiliary data.
Extra is an optional argument and can be safely set to NULL when not needed.
code | Numerical error code. |
msg | String representing an actual error description. |
extra | Extra data (optional). |
stack | Externally provided stack trace of an error. |
int rpc_error_get_code | ( | _Nonnull rpc_object_t | error | ) |
Returns numerical error code of a provided error object.
error | Input error object. |
_Nullable rpc_object_t rpc_error_get_extra | ( | _Nonnull rpc_object_t | error | ) |
Returns an extra (auxiliary data) set during creation of a provided provided error object.
error | Input error object. |
const char* _Nullable rpc_error_get_message | ( | _Nonnull rpc_object_t | error | ) |
_Nullable rpc_object_t rpc_error_get_stack | ( | _Nonnull rpc_object_t | error | ) |
Returns a stack trace associated with an error condition of a provided error object.
error | Input error object. |
void rpc_error_set_extra | ( | _Nonnull rpc_object_t | error, |
_Nonnull rpc_object_t | extra | ||
) |
Sets an extra data attached to an error.
error | Input error object. |
extra | Extra data to be attached to an error. |
_Nonnull rpc_object_t rpc_fd_create | ( | int | fd | ) |
Creates an RPC object holding a file descriptor.
fd | Value of the object (signed integer). |
int rpc_fd_dup | ( | _Nonnull rpc_object_t | xfd | ) |
Creates a duplicate of a file descriptor held by a provided object.
xfd | Input object. |
int rpc_fd_get_value | ( | _Nonnull rpc_object_t | xfd | ) |
Returns a value of a file descriptor helf by a provided object.
xfd | Input object. |
size_t rpc_get_column_number | ( | _Nonnull rpc_object_t | object | ) |
Gets column number of object location in source file (if any).
If the object was read from a file using RPC serializer API, this function might return a column number where the object was located in the source file. Otherwise, it returns 0.
object | Object to get column number from |
_Nullable rpc_object_t rpc_get_last_error | ( | void | ) |
size_t rpc_get_line_number | ( | _Nonnull rpc_object_t | object | ) |
Gets line number of object location in source file (if any).
If the object was read from a file using RPC serializer API, this function might return a line number where the object was located in the source file. Otherwise, it returns 0.
object | Object to get line number from |
int rpc_get_refcount | ( | _Nullable rpc_object_t | object | ) |
Returns reference count of an object.
This function shall be usd only for debugging purposes.
object | Object to read reference count from |
rpc_type_t rpc_get_type | ( | _Nonnull rpc_object_t | object | ) |
Returns the type of an object.
object | Input object. |
const char* _Nullable rpc_get_type_name | ( | rpc_type_t | type | ) |
Returns the string name of a type.
type | Type |
size_t rpc_hash | ( | _Nonnull rpc_object_t | object | ) |
Returns numerical hash calculated from the value of an object.
object | Object to be hashed. |
_Nonnull rpc_object_t rpc_int64_create | ( | int64_t | value | ) |
Creates an object holding a signed 64-bit integer value.
value | Value of the object (signed 64-bit integer). |
int64_t rpc_int64_get_value | ( | _Nonnull rpc_object_t | xint | ) |
Returns an integer value of an object.
If rpc_object_t passed as the first argument if not of RPC_TYPE_INT64 type, the function returns -1.
xint | Object to read the value from. |
_Nonnull rpc_object_t rpc_null_create | ( | void | ) |
_Nullable rpc_object_t rpc_object_pack | ( | const char *_Nonnull | fmt, |
... | |||
) |
Packs provided values accordingly to a specified format string an into object compatible with library's data model.
Each set of characters of the format string represents a single creation step of an output object and may require from 0 to n arguments. Character sets are separated with ',' character.
Example: [s,s,s] represents an array containing three strings and require three char * arguments to be passed to the function after the format string. Example: {i,i,i} represents a dictionary containing three integers and require three pairs of (char *, int) arguments to be passed to the function after the format string. First of each two is representing a dictionary key, which is always a char * and second an actual integer value to be packed.
The syntax above allows easy pack of dictionaries containing dynamically generated keys and continuous arrays. There is also second format string syntax, especially handy when packing dictionaries with statically known keys and noncontinuous arrays. That syntax allows specifying array indexes and name of dictionary keys directly in the format string and separating them from the value type character with ':' character.
Example: [0:s,1:s,20:s] represents an array containing three strings and require three char * arguments to be passed to the function after the format string. Gap between index 1 and 20 is going to be filled with NULL RPC objects. Example: {example_key:i,other_key:i,yet_another_key:i} represents a dictionary containing three integers and require three int arguments to be passed to the function after the format string.
Both syntaxes are allowed to be mixed together in a single format string creating complex data structures representations. Each explicitly specified array index is resetting an internal state of the pack function, so mixing explicit and implicit indexing syntax within a single array is going to result in a following behavior:
Example: {[i,s,i],[10:b,s,1:d,u],{key:v,f,u}} Array in the middle of the example below is going to be created in the following order: indexes 0-9 are going to be padded with the NULL RPC objects, index 10 is going to contain BOOL RPC object, index 11 is going to contain a STRING RPC object, function jumps back to the index 1 and replaces NULL RPC object with the DOUBLE RPC object, function increments last index, that results in the index 2 and replaces the NULL RPC object below that index with UNSIGNED INT RPC object.
Format string can also contain single quoted inline strings for ease of packing of constant values.
Example: {inline_string:'inline_string_value'}
Format string syntax:
fmt | Format string. |
... | Variable length list of values to be packed. |
int rpc_object_unpack | ( | _Nonnull | rpc_object_t, |
const char *_Nonnull | fmt, | ||
... | |||
) |
Unpacks provided values accordingly to a specified format string from an object.
Each character set of the format string represents a single unpack step and may require from 0 to n arguments. Character sets are separated with ',' character.
Example: [s,s,s] represents an array containing three strings and require three char ** arguments to be passed to the function after the format string. Example: {i,i,i} represents a dictionary containing three integers and require three pairs of (char *, int *) arguments to be passed to the function after the format string. First of each two is representing a dictionary key, which is always a char * and second an actual integer value to be unpacked.
The syntax above allows easy unpack of dictionaries containing dynamically generated keys and continuous arrays. There is also second format string syntax, especially handy when unpacking dictionaries with statically known keys and noncontinuous reads from arrays. That syntax allows specifying array indexes and name of dictionary keys directly in the format string and separating them from the value type character with ':' character.
Example: [0:s,1:s,20:s] represents an array containing three strings and require three char ** arguments to be passed to the function after the format string. Example: {example_key:i,other_key:i,yet_another_key:i} represents a dictionary containing three integers and require three int * arguments to be passed to the function after the format string.
Both syntaxes are allowed to be mixed together in a single format string creating complex data structures representations. Each explicitly specified array index is resetting an internal state of the unpack function, so mixing explicit and implicit indexing syntax within a single array is going to result in a following behavior:
Example: {[i,s,i],[10:b,s,1:d,u],{key:v,f,u}}
The function returns the number of successfully processed format characters (excluding '{', '[', ']', '}'), or an error as a negative value.
Format string syntax:
fmt | Format string. |
... | Variable length list of values to be unpacked. |
_Nullable rpc_object_t rpc_object_vpack | ( | const char *_Nonnull | fmt, |
va_list | ap | ||
) |
Packs provided values accordingly to a specified format string an into object compatible with library's data model.
The functions acts exactly the same as the rpc_object_pack function, but takes assembled variable arguments list structure as its argument.
fmt | Format string. |
ap | Variable arguments list structure. |
int rpc_object_vunpack | ( | _Nonnull | rpc_object_t, |
const char *_Nonnull | fmt, | ||
va_list | ap | ||
) |
Unpacks provided values accordingly to a specified format string from an object.
The functions acts exactly the same as the rpc_object_unpack function, but takes assembled variable arguments list structure as its argument.
fmt | Format string. |
ap | Variable arguments list structure. |
int rpc_release_impl | ( | _Nonnull rpc_object_t | object | ) |
Decrements reference count of an object.
Function returns reference count of an object after operation.
object | Object to decrement reference count of. |
_Nonnull rpc_object_t rpc_retain | ( | _Nonnull rpc_object_t | object | ) |
Increments reference count of an object.
For convenience, the function returns reference to an object passed as the first argument.
object | Object to increment reference count of. |
_Nonnull rpc_object_t rpc_string_create | ( | const char *_Nonnull | string | ) |
Creates an RPC object holding a string.
string | Value of the object (constant character pointer). |
_Nonnull rpc_object_t rpc_string_create_len | ( | const char *_Nonnull | string, |
size_t | length | ||
) |
Creates an RPC object holding a string of a specified length.
string | Value of the object (constant character pointer). |
length | Length of an input string. |
_Nonnull rpc_object_t rpc_string_create_with_format | ( | const char *_Nonnull | fmt, |
... | |||
) |
Creates an RPC object holding a string formatted using the regular printf function format string and arguments.
fmt | Format string. |
... | Variable length list of input data arguments for formatting. |
_Nonnull rpc_object_t rpc_string_create_with_format_and_arguments | ( | const char *_Nonnull | fmt, |
va_list | ap | ||
) |
Creates an RPC object holding a string formatted using the regular printf function format string and arguments (as variable arguments list type).
fmt | Format string. |
ap | Variable arguments list. |
size_t rpc_string_get_length | ( | _Nonnull rpc_object_t | xstring | ) |
Returns the length of internal string buffer of a provided object.
xstring | Input object |
const char* _Nullable rpc_string_get_string_ptr | ( | _Nonnull rpc_object_t | xstring | ) |
Returns the pointer to internal string data buffer of a provided object.
xstring | Input object |
_Nonnull rpc_object_t rpc_uint64_create | ( | uint64_t | value | ) |
Creates an RPC object holding an unsigned 64-bit integer value.
value | Value of the object (unsigned 64-bit integer). |
uint64_t rpc_uint64_get_value | ( | _Nonnull rpc_object_t | xuint | ) |
Returns an integer value of an object.
If rpc_object_t passed as the first argument if not of RPC_TYPE_UINT64 type, the function returns 0.
xuint | Object to read the value from. |