![]() |
Container for double values.
An as_double should be initialized via one of the provided function.
To initialize a stack allocated as_double, use as_double_init():
To create and initialize a heap allocated as_double, use as_double_new():
When a heap allocated as_double instance is no longer required, then you should release the resources associated with it via as_double_destroy():
There are two functions for getting the boxed value contained by as_double:
as_double_get() returns the contained value. If an error occurred, then 0 (zero) is returned. Possible errors is the as_double instance is NULL.
as_double_getorelse() allows you to return a default value if an error occurs:
as_double 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_double_fromval(). If conversion fails, then the return value is NULL.
Definition at line 99 of file as_double.h.
#include "as_double.h"
Data Fields | |
double | value |
![]() | |
uint32_t | count |
bool | free |
as_val_t | type |
Related Symbols | |
(Note that these are not member symbols.) | |
static void | as_double_destroy (as_double *value) |
static as_double * | as_double_fromval (const as_val *value) |
static double | as_double_get (const as_double *value) |
static double | as_double_getorelse (const as_double *value, double fallback) |
AS_EXTERN as_double * | as_double_init (as_double *value_ptr, double value) |
AS_EXTERN as_double * | as_double_new (double value) |
static as_val * | as_double_toval (const as_double *value) |
|
related |
Destroy the as_double
and release resources.
value | The double to destroy. |
Definition at line 173 of file as_double.h.
References as_val_destroy.
Convert from an as_val.
Definition at line 225 of file as_double.h.
References AS_DOUBLE, and as_util_fromval.
|
related |
|
related |
Get the double value. If double is NULL, then return the fallback value.
Definition at line 188 of file as_double.h.
References value.
Initialize a stack allocated as_double
with the given double value.
as_double_destroy() is not required for a stack allocated as_double.
value_ptr | The as_double to initialize. |
value | The double value. |
Creates a new heap allocated as_double.
When the as_double
is no longer needed, you should release it an it's resources:
value | The double value. |
Convert to an as_val.
Definition at line 214 of file as_double.h.
double as_double::value |
The double value
Definition at line 110 of file as_double.h.