diff options
Diffstat (limited to 'include/cn-cbor/cn-cbor.h')
-rw-r--r-- | include/cn-cbor/cn-cbor.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/cn-cbor/cn-cbor.h b/include/cn-cbor/cn-cbor.h index bf71af8..187a55c 100644 --- a/include/cn-cbor/cn-cbor.h +++ b/include/cn-cbor/cn-cbor.h @@ -1,3 +1,4 @@ + /** * \file * \brief @@ -52,6 +53,8 @@ typedef enum cn_cbor_type { CN_CBOR_SIMPLE, /** Doubles, floats, and half-floats */ CN_CBOR_DOUBLE, + /** Floats, and half-floats */ + CN_CBOR_FLOAT, /** An error has occurred */ CN_CBOR_INVALID } cn_cbor_type; @@ -91,6 +94,8 @@ typedef struct cn_cbor { unsigned long uint; /** CN_CBOR_DOUBLE */ double dbl; + /** CN_CBOR_FLOAT */ + float f; /** for use during parsing */ unsigned long count; } v; /* TBD: optimize immediate */ @@ -324,6 +329,32 @@ cn_cbor* cn_cbor_int_create(int64_t value CBOR_CONTEXT, cn_cbor_errback *errp); +#ifndef CBOR_NO_FLOAT +/** + * Create a CBOR float. + * + * @param[in] value the value of the float + * @param[in] CBOR_CONTEXT Allocation context (only if USE_CBOR_CONTEXT is defined) + * @param[out] errp Error, if NULL is returned + * @return The created object, or NULL on error + */ +cn_cbor* cn_cbor_float_create(float value + CBOR_CONTEXT, + cn_cbor_errback *errp); + +/** + * Create a CBOR double. + * + * @param[in] value the value of the double + * @param[in] CBOR_CONTEXT Allocation context (only if USE_CBOR_CONTEXT is defined) + * @param[out] errp Error, if NULL is returned + * @return The created object, or NULL on error + */ +cn_cbor* cn_cbor_double_create(double value + CBOR_CONTEXT, + cn_cbor_errback *errp); +#endif /* CBOR_NO_FLOAT */ + /** * Put a CBOR object into a map with a CBOR object key. Duplicate checks are NOT * currently performed. |