From 57511e58b725ea25bb88b1f4406dfa5200b208ff Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Sun, 25 Aug 2019 11:54:34 +0300 Subject: [PATCH] add documentation to funcs --- include/json/impl/impl_json.h | 6 +++--- include/json/json.h | 29 ++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/json/impl/impl_json.h b/include/json/impl/impl_json.h index 57c8ff3..765dde0 100644 --- a/include/json/impl/impl_json.h +++ b/include/json/impl/impl_json.h @@ -316,7 +316,7 @@ void json_array_float(float * __restrict dest, const json_t * __restrict object, float defaultValue, - int maxLength, + int maxCount, bool sourceIsReversed) { json_array_t *arr; json_t *item; @@ -328,8 +328,8 @@ json_array_float(float * __restrict dest, count = arr->count; item = arr->base.value; - if (maxLength > 0 && count > maxLength) - count = maxLength; + if (maxCount > 0 && count > maxCount) + count = maxCount; if (sourceIsReversed) { while (item) { diff --git a/include/json/json.h b/include/json/json.h index 574aec1..edb65bf 100644 --- a/include/json/json.h +++ b/include/json/json.h @@ -73,20 +73,47 @@ JSON_INLINE json_array_t* json_array(const json_t * __restrict object); +/*! + * @brief returns count of array's items + * + * @param[in] object json object + * @return count + */ JSON_INLINE int json_count(const json_t * __restrict object); +/*! + * @brief returns true if object is array + * + * @param[in] object json object + * @return true if object is array otherwise false + */ JSON_INLINE bool json_is_array(const json_t * __restrict object); +/*! + * @brief fill float array + * + * if you know item is float array, you don't need to iterate manulally. + * with maxCount you can trim array from start, for instance if array is vec4 + * and you want to get vec3, then if you set maxCount as 3, you will only get + * first 3 items of array + * + * @param[in] dest destination float array + * @param[in] object json object + * @param[in] defaultValue defult value if item is not float + * @param[in] maxCount max count to read, 0 to read all + * @param[in] sourceIsReversed source is reversed; true if you pass true to + * json_parse's reverse parameter + */ JSON_INLINE void json_array_float(float * __restrict dest, const json_t * __restrict object, float defaultValue, - int maxLength, + int maxCount, bool sourceIsReversed); #include "impl/impl_json.h"