![]() |
Container for integer values.
An as_integer should be initialized via one of the provided function.
To initialize a stack allocated as_integer, use as_integer_init():
To create and initialize a heap allocated as_integer, use as_integer_new():
When a heap allocated as_integer instance is no longer required, then you should release the resources associated with it via as_integer_destroy():
There are two functions for getting the boxed value contained by as_integer:
as_integer_get() returns the contained value. If an error occurred, then 0 (zero) is returned. Possible errors is the as_integer instance is NULL.
as_integer_getorelse() allows you to return a default value if an error occurs:
as_integer is derived from as_val, so it is generally safe to down cast:
However, upcasting is more error prone. When doing so, you should use as_integer_fromval(). If conversion fails, then the return value is NULL.
Definition at line 100 of file as_integer.h.
#include "as_integer.h"
Data Fields | |
int64_t | value |
![]() | |
uint32_t | count |
bool | free |
as_val_t | type |
Related Symbols | |
(Note that these are not member symbols.) | |
static void | as_integer_destroy (as_integer *integer) |
static as_integer * | as_integer_fromval (const as_val *v) |
static int64_t | as_integer_get (const as_integer *integer) |
static int64_t | as_integer_getorelse (const as_integer *integer, int64_t fallback) |
AS_EXTERN as_integer * | as_integer_init (as_integer *integer, int64_t value) |
AS_EXTERN as_integer * | as_integer_new (int64_t value) |
static int64_t | as_integer_toint (const as_integer *integer) |
static as_val * | as_integer_toval (const as_integer *i) |
|
related |
Destroy the as_integer
and release resources.
integer | The integer to destroy. |
Definition at line 172 of file as_integer.h.
References as_val_destroy.
|
related |
Convert from an as_val.
Definition at line 226 of file as_integer.h.
References AS_INTEGER, and as_util_fromval.
|
related |
Get the int64_t value.
Definition at line 194 of file as_integer.h.
References as_integer_getorelse().
|
related |
Get the int64_t value. If integer is NULL, then return the fallback value.
Definition at line 185 of file as_integer.h.
References value.
|
related |
Initialize a stack allocated as_integer
with the given integer value.
as_integer_destroy() is not required for a stack allocated as_integer.
integer | The as_integer to initialize. |
value | The integer value. |
|
related |
Creates a new heap allocated as_integer.
When the as_integer
is no longer needed, you should release it an it's resources:
value | The integer value. |
|
related |
Get the int64_t value.
Definition at line 204 of file as_integer.h.
References as_integer_getorelse().
|
related |
Convert to an as_val.
Definition at line 217 of file as_integer.h.
int64_t as_integer::value |
The integer value
Definition at line 112 of file as_integer.h.