![]() |
#include <aerospike/as_util.h>
#include <aerospike/as_val.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | as_bytes |
Macros | |
#define | as_bytes_inita(__bytes, __capacity) |
Enumerations | |
enum | as_bytes_type { AS_BYTES_UNDEF = 0, AS_BYTES_INTEGER = 1, AS_BYTES_FLOAT = 1, AS_BYTES_STRING = 3, AS_BYTES_BLOB = 4, AS_BYTES_JAVA = 7, AS_BYTES_CSHARP = 8, AS_BYTES_PYTHON = 9, AS_BYTES_RUBY = 10, AS_BYTES_PHP = 11, AS_BYTES_ERLANG = 12, AS_BYTES_MAP = 19, AS_BYTES_LIST = 20, AS_BYTES_LDT = 21, AS_BYTES_TYPE_MAX = 22, AS_BYTES_UNDEF = 0, AS_BYTES_INTEGER = 1, AS_BYTES_FLOAT = 1, AS_BYTES_STRING = 3, AS_BYTES_BLOB = 4, AS_BYTES_JAVA = 7, AS_BYTES_CSHARP = 8, AS_BYTES_PYTHON = 9, AS_BYTES_RUBY = 10, AS_BYTES_PHP = 11, AS_BYTES_ERLANG = 12, AS_BYTES_MAP = 19, AS_BYTES_LIST = 20, AS_BYTES_LDT = 21, AS_BYTES_TYPE_MAX = 22, AS_BYTES_UNDEF = 0, AS_BYTES_INTEGER = 1, AS_BYTES_FLOAT = 1, AS_BYTES_STRING = 3, AS_BYTES_BLOB = 4, AS_BYTES_JAVA = 7, AS_BYTES_CSHARP = 8, AS_BYTES_PYTHON = 9, AS_BYTES_RUBY = 10, AS_BYTES_PHP = 11, AS_BYTES_ERLANG = 12, AS_BYTES_MAP = 19, AS_BYTES_LIST = 20, AS_BYTES_LDT = 21, AS_BYTES_TYPE_MAX = 22 } |
Functions | |
bool | as_bytes_append (as_bytes *bytes, const uint8_t *value, uint32_t size) |
bool | as_bytes_append_byte (as_bytes *bytes, uint8_t value) |
bool | as_bytes_append_int16 (as_bytes *bytes, int16_t value) |
bool | as_bytes_append_int32 (as_bytes *bytes, int32_t value) |
bool | as_bytes_append_int64 (as_bytes *bytes, int64_t value) |
uint32_t | as_bytes_capacity (const as_bytes *bytes) |
uint32_t | as_bytes_copy (const as_bytes *bytes, uint32_t index, uint8_t *value, uint32_t size) |
void | as_bytes_destroy (as_bytes *bytes) |
bool | as_bytes_ensure (as_bytes *bytes, uint32_t n, bool resize) |
as_bytes * | as_bytes_fromval (const as_val *v) |
uint8_t * | as_bytes_get (const as_bytes *bytes) |
uint32_t | as_bytes_get_byte (const as_bytes *bytes, uint32_t index, uint8_t *value) |
uint32_t | as_bytes_get_int16 (const as_bytes *bytes, uint32_t index, int16_t *value) |
uint32_t | as_bytes_get_int32 (const as_bytes *bytes, uint32_t index, int32_t *value) |
uint32_t | as_bytes_get_int64 (const as_bytes *bytes, uint32_t index, int64_t *value) |
as_bytes_type | as_bytes_get_type (const as_bytes *bytes) |
uint8_t * | as_bytes_getorelse (const as_bytes *bytes, uint8_t *fallback) |
as_bytes * | as_bytes_init (as_bytes *bytes, uint32_t capacity) |
as_bytes * | as_bytes_init_wrap (as_bytes *bytes, uint8_t *value, uint32_t size, bool free) |
as_bytes * | as_bytes_new (uint32_t capacity) |
as_bytes * | as_bytes_new_wrap (uint8_t *value, uint32_t size, bool free) |
bool | as_bytes_set (as_bytes *bytes, uint32_t index, const uint8_t *value, uint32_t size) |
bool | as_bytes_set_byte (as_bytes *bytes, uint32_t index, uint8_t value) |
bool | as_bytes_set_int16 (as_bytes *bytes, uint32_t index, int16_t value) |
bool | as_bytes_set_int32 (as_bytes *bytes, uint32_t index, int32_t value) |
bool | as_bytes_set_int64 (as_bytes *bytes, uint32_t index, int64_t value) |
void | as_bytes_set_type (as_bytes *bytes, as_bytes_type type) |
uint32_t | as_bytes_size (const as_bytes *bytes) |
uint8_t * | as_bytes_tobytes (const as_bytes *bytes, uint32_t *size) |
as_val * | as_bytes_toval (const as_bytes *b) |
bool | as_bytes_truncate (as_bytes *bytes, uint32_t n) |
void | as_bytes_val_destroy (as_val *v) |
uint32_t | as_bytes_val_hashcode (const as_val *v) |
char * | as_bytes_val_tostring (const as_val *v) |
#define as_bytes_inita | ( | __bytes, | |
__capacity | |||
) |
Initializes a stack allocated as_bytes
. Allocates an internal buffer on the stack of specified capacity using alloca()
.
__bytes | The bytes to initialize. |
__capacity | The number of bytes to allocate on the heap. |
Definition at line 292 of file target/Darwin-i386/include/aerospike/as_bytes.h.
enum as_bytes_type |
Types for as_bytes.type
Definition at line 39 of file target/Darwin-i386/include/aerospike/as_bytes.h.
bool as_bytes_append | ( | as_bytes * | bytes, |
const uint8_t * | value, | ||
uint32_t | size | ||
) |
Append raw bytes of given size.
bytes | The bytes to append to. |
value | The buffer to read from. |
size | The number of bytes to read from the value. |
|
inline |
Append a uint8_t (byte).
Definition at line 734 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_append().
|
inline |
Append an int16_t value.
Definition at line 750 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_append().
|
inline |
Append an int32_t value.
Definition at line 766 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_append().
|
inline |
Append an int64_t value.
Definition at line 782 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_append().
|
inline |
Get the number of bytes allocated.
bytes | The bytes to get the capacity of. |
Definition at line 423 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::capacity.
uint32_t as_bytes_copy | ( | const as_bytes * | bytes, |
uint32_t | index, | ||
uint8_t * | value, | ||
uint32_t | size | ||
) |
Copy into value up to size bytes from the given as_bytes
, returning the number of bytes copied.
bytes | The bytes to read from. |
index | The positing in bytes to read from. |
value | The byte buffer to copy into. |
size | The number of bytes to copy into the buffer. |
|
inline |
Destroy the as_bytes
and release associated resources.
bytes | The bytes to destroy. |
Definition at line 390 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_val_destroy.
bool as_bytes_ensure | ( | as_bytes * | bytes, |
uint32_t | n, | ||
bool | resize | ||
) |
Ensure the bytes buffer can handle n
additional bytes.
Using the current size, we see if size + n
is within the capacity of the bytes' buffer. If so, then return true.
If resize
is true and size + n
exceeds the capacity of the bytes's buffer, then resize the capacity of the buffer by n
bytes. If the buffer was heap allocated, then cf_realloc()
will be used to resize. If the buffer was stack allocated, it will be converted to a heap allocated buffer using cf_malloc() and then its contents will be copied into the new heap allocated buffer.
If resize
is false, and if the capacity is not sufficient, then return false.
bytes | The bytes to ensure the capacity of. |
n | The number of additional bytes to ensure bytes can handle. |
resize | If true and capacity is not sufficient, then resize the buffer. |
Convert from an as_val.
Definition at line 881 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References AS_BYTES, and as_util_fromval.
|
inline |
Get the raw value of this instance.
bytes | The bytes to get the raw value from. |
Definition at line 492 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_getorelse().
|
inline |
Read a single byte from the given bytes.
Definition at line 544 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_copy().
|
inline |
Read an int16_t from the given bytes.
Definition at line 565 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_copy().
|
inline |
Read an int32_t from the given bytes.
Definition at line 586 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_copy().
|
inline |
Read an int64_t from the given bytes.
Definition at line 607 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_copy().
|
inline |
Get the type of bytes.
bytes | The bytes to get the type of. |
Definition at line 438 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References AS_BYTES_UNDEF, and as_bytes::type.
|
inline |
Get the raw value of this instance. If the instance is NULL, then return the fallback value.
bytes | The bytes to get the raw value from. |
fallback | The value to return if bytes is NULL. |
Definition at line 474 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::value.
Initializes a stack allocated as_bytes
. Allocates an internal buffer on the heap of specified capacity using cf_malloc()
.
bytes | The bytes to initialize. |
capacity | The number of bytes to allocate on the heap. |
Initializes a stack allocated as_bytes
, wrapping the given buffer.
bytes | The bytes to initialize. |
value | The initial value. |
size | The number of bytes of the initial value. |
free | If true, then as_bytes_destroy() will free the value. |
as_bytes* as_bytes_new | ( | uint32_t | capacity | ) |
Create and initialize a new heap allocated as_bytes
. Allocates an internal buffer on the heap of specified capacity using cf_malloc()
.
capacity | The number of bytes to allocate. |
as_bytes* as_bytes_new_wrap | ( | uint8_t * | value, |
uint32_t | size, | ||
bool | free | ||
) |
Creates a new heap allocated as_bytes
, wrapping the given buffer.
value | The initial value. |
size | The number of bytes of the initial value. |
free | If true, then as_bytes_destroy() will free the value. |
bool as_bytes_set | ( | as_bytes * | bytes, |
uint32_t | index, | ||
const uint8_t * | value, | ||
uint32_t | size | ||
) |
Copy raw bytes of given size into the given as_bytes
starting at specified index.
bytes | The bytes to write to. |
index | The position to write to. |
value | The buffer to read from. |
size | The number of bytes to read from the value. |
|
inline |
Set a byte at given index.
Definition at line 646 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_set().
|
inline |
Set a byte at given index.
Definition at line 662 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_set().
|
inline |
Set a byte at given index.
Definition at line 678 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_set().
|
inline |
Set a byte at given index.
Definition at line 694 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::as_bytes_set().
|
inline |
Set the type of bytes.
bytes | The bytes to set the type of. |
type | The type for the bytes. |
Definition at line 452 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References type, and as_bytes::type.
|
inline |
Get the number of bytes used.
bytes | The bytes to get the size of. |
Definition at line 408 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::size.
|
inline |
Get the bytes value.
Definition at line 851 of file target/Darwin-i386/include/aerospike/as_bytes.h.
References as_bytes::size, and as_bytes::value.
Convert to an as_val.
Definition at line 871 of file target/Darwin-i386/include/aerospike/as_bytes.h.
bool as_bytes_truncate | ( | as_bytes * | bytes, |
uint32_t | n | ||
) |
Truncate the bytes' buffer. The size specifies the number of bytes to remove from the end of the buffer.
This means, if the buffer has size of 100, and we truncate 10, then the remaining size is 90.
Truncation does not modify the capacity of the buffer.
bytes | The bytes to truncate. |
n | The number of bytes to remove from the end. |
|
private |
Internal helper function for getting the hashcode of an as_val.