![]() |
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 the 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 103 of file as_integer.h.
#include "as_integer.h"
Data Fields | |
int64_t | value |
![]() | |
cf_atomic32 | count |
bool | free |
enum as_val_t | type |
Private Attributes | |
as_val | _ |
Related Functions | |
(Note that these are not member functions.) | |
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_integer * | as_integer_init (as_integer *integer, int64_t value) |
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 180 of file as_integer.h.
|
related |
Convert from an as_val.
Definition at line 234 of file as_integer.h.
|
related |
Get the int64_t value.
Definition at line 202 of file as_integer.h.
|
related |
Get the int64_t value. If integer is NULL, then return the fallback value.
Definition at line 193 of file as_integer.h.
|
related |
Initialize a stack allocated as_integer
with the given integer value.
When the as_integer
is no longer needed, you should release it an it's resources:
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 212 of file as_integer.h.
|
related |
Convert to an as_val.
Definition at line 225 of file as_integer.h.
|
private |
as_boolean is a subtype of as_val. You can cast as_boolean to as_val.
Definition at line 110 of file as_integer.h.
int64_t as_integer::value |
The integer value
Definition at line 115 of file as_integer.h.