Deleted Added
full compact
141c141,142
< UCL_PARSER_ZEROCOPY = 0x2 /**< Parse input in zero-copy mode if possible */
---
> UCL_PARSER_ZEROCOPY = 0x2, /**< Parse input in zero-copy mode if possible */
> UCL_PARSER_NO_TIME = 0x4 /**< Do not parse time and treat time values as strings */
153c154,155
< UCL_STRING_PARSE_NUMBER = UCL_STRING_PARSE_INT|UCL_STRING_PARSE_DOUBLE , /**<
---
> UCL_STRING_PARSE_TIME = 0x20, /**< Parse time strings */
> UCL_STRING_PARSE_NUMBER = UCL_STRING_PARSE_INT|UCL_STRING_PARSE_DOUBLE|UCL_STRING_PARSE_TIME, /**<
157c159
< UCL_STRING_PARSE_BYTES = 0x20 /**< Treat numbers as bytes */
---
> UCL_STRING_PARSE_BYTES = 0x40 /**< Treat numbers as bytes */
222,234c224
< static inline ucl_object_t* ucl_object_new (void) UCL_WARN_UNUSED_RESULT;
< static inline ucl_object_t *
< ucl_object_new (void)
< {
< ucl_object_t *new;
< new = malloc (sizeof (ucl_object_t));
< if (new != NULL) {
< memset (new, 0, sizeof (ucl_object_t));
< new->ref = 1;
< new->type = UCL_NULL;
< }
< return new;
< }
---
> UCL_EXTERN ucl_object_t* ucl_object_new (void) UCL_WARN_UNUSED_RESULT;
241,253c231
< static inline ucl_object_t* ucl_object_typed_new (unsigned int type) UCL_WARN_UNUSED_RESULT;
< static inline ucl_object_t *
< ucl_object_typed_new (unsigned int type)
< {
< ucl_object_t *new;
< new = malloc (sizeof (ucl_object_t));
< if (new != NULL) {
< memset (new, 0, sizeof (ucl_object_t));
< new->ref = 1;
< new->type = (type <= UCL_NULL ? type : UCL_NULL);
< }
< return new;
< }
---
> UCL_EXTERN ucl_object_t* ucl_object_typed_new (unsigned int type) UCL_WARN_UNUSED_RESULT;
270,274c248
< static inline ucl_object_t *
< ucl_object_fromstring (const char *str)
< {
< return ucl_object_fromstring_common (str, 0, UCL_STRING_ESCAPE);
< }
---
> UCL_EXTERN ucl_object_t *ucl_object_fromstring (const char *str);
282,286c256
< static inline ucl_object_t *
< ucl_object_fromlstring (const char *str, size_t len)
< {
< return ucl_object_fromstring_common (str, len, UCL_STRING_ESCAPE);
< }
---
> UCL_EXTERN ucl_object_t *ucl_object_fromlstring (const char *str, size_t len);
293,296c263
< static inline ucl_object_t *
< ucl_object_fromint (int64_t iv)
< {
< ucl_object_t *obj;
---
> UCL_EXTERN ucl_object_t* ucl_object_fromint (int64_t iv);
298,306d264
< obj = ucl_object_new ();
< if (obj != NULL) {
< obj->type = UCL_INT;
< obj->value.iv = iv;
< }
<
< return obj;
< }
<
312,315c270
< static inline ucl_object_t *
< ucl_object_fromdouble (double dv)
< {
< ucl_object_t *obj;
---
> UCL_EXTERN ucl_object_t* ucl_object_fromdouble (double dv);
317,325d271
< obj = ucl_object_new ();
< if (obj != NULL) {
< obj->type = UCL_FLOAT;
< obj->value.dv = dv;
< }
<
< return obj;
< }
<
331,334c277
< static inline ucl_object_t *
< ucl_object_frombool (bool bv)
< {
< ucl_object_t *obj;
---
> UCL_EXTERN ucl_object_t* ucl_object_frombool (bool bv);
336,344d278
< obj = ucl_object_new ();
< if (obj != NULL) {
< obj->type = UCL_BOOLEAN;
< obj->value.iv = bv;
< }
<
< return obj;
< }
<
384a319
>
385a321,341
> * Delete key from `top` object returning the object deleted. This object is not
> * released
> * @param top object
> * @param key key to remove
> * @param keylen length of the key (or 0 for NULL terminated keys)
> * @return removed object or NULL if object has not been found
> */
> UCL_EXTERN ucl_object_t* ucl_object_pop_keyl (ucl_object_t *top, const char *key,
> size_t keylen) UCL_WARN_UNUSED_RESULT;
>
> /**
> * Delete key from `top` object returning the object deleted. This object is not
> * released
> * @param top object
> * @param key key to remove
> * @return removed object or NULL if object has not been found
> */
> UCL_EXTERN ucl_object_t* ucl_object_pop_key (ucl_object_t *top, const char *key)
> UCL_WARN_UNUSED_RESULT;
>
> /**
404c360
< static inline ucl_object_t * ucl_array_append (ucl_object_t *top,
---
> UCL_EXTERN ucl_object_t* ucl_array_append (ucl_object_t *top,
406,409d361
< static inline ucl_object_t *
< ucl_array_append (ucl_object_t *top, ucl_object_t *elt)
< {
< ucl_object_t *head;
411,439d362
< if (elt == NULL) {
< return NULL;
< }
<
< if (top == NULL) {
< top = ucl_object_typed_new (UCL_ARRAY);
< top->value.av = elt;
< elt->next = NULL;
< elt->prev = elt;
< top->len = 1;
< }
< else {
< head = top->value.av;
< if (head == NULL) {
< top->value.av = elt;
< elt->prev = elt;
< }
< else {
< elt->prev = head->prev;
< head->prev->next = elt;
< head->prev = elt;
< }
< elt->next = NULL;
< top->len ++;
< }
<
< return top;
< }
<
446c369
< static inline ucl_object_t * ucl_array_prepend (ucl_object_t *top,
---
> UCL_EXTERN ucl_object_t* ucl_array_prepend (ucl_object_t *top,
448,451d370
< static inline ucl_object_t *
< ucl_array_prepend (ucl_object_t *top, ucl_object_t *elt)
< {
< ucl_object_t *head;
453,481d371
< if (elt == NULL) {
< return NULL;
< }
<
< if (top == NULL) {
< top = ucl_object_typed_new (UCL_ARRAY);
< top->value.av = elt;
< elt->next = NULL;
< elt->prev = elt;
< top->len = 1;
< }
< else {
< head = top->value.av;
< if (head == NULL) {
< top->value.av = elt;
< elt->prev = elt;
< }
< else {
< elt->prev = head->prev;
< head->prev = elt;
< }
< elt->next = head;
< top->value.av = elt;
< top->len ++;
< }
<
< return top;
< }
<
489,492c379
< static inline ucl_object_t *
< ucl_array_delete (ucl_object_t *top, ucl_object_t *elt)
< {
< ucl_object_t *head;
---
> UCL_EXTERN ucl_object_t* ucl_array_delete (ucl_object_t *top, ucl_object_t *elt);
494,521d380
< if (top == NULL || top->type != UCL_ARRAY || top->value.av == NULL) {
< return NULL;
< }
< head = top->value.av;
<
< if (elt->prev == elt) {
< top->value.av = NULL;
< }
< else if (elt == head) {
< elt->next->prev = elt->prev;
< top->value.av = elt->next;
< }
< else {
< elt->prev->next = elt->next;
< if (elt->next) {
< elt->next->prev = elt->prev;
< }
< else {
< head->prev = elt->prev;
< }
< }
< elt->next = NULL;
< elt->prev = elt;
< top->len --;
<
< return elt;
< }
<
527,534c386
< static inline ucl_object_t *
< ucl_array_head (ucl_object_t *top)
< {
< if (top == NULL || top->type != UCL_ARRAY || top->value.av == NULL) {
< return NULL;
< }
< return top->value.av;
< }
---
> UCL_EXTERN ucl_object_t* ucl_array_head (ucl_object_t *top);
541,548c393
< static inline ucl_object_t *
< ucl_array_tail (ucl_object_t *top)
< {
< if (top == NULL || top->type != UCL_ARRAY || top->value.av == NULL) {
< return NULL;
< }
< return top->value.av->prev;
< }
---
> UCL_EXTERN ucl_object_t* ucl_array_tail (ucl_object_t *top);
556,560c401
< static inline ucl_object_t *
< ucl_array_pop_last (ucl_object_t *top)
< {
< return ucl_array_delete (top, ucl_array_tail (top));
< }
---
> UCL_EXTERN ucl_object_t* ucl_array_pop_last (ucl_object_t *top);
568,572c409
< static inline ucl_object_t *
< ucl_array_pop_first (ucl_object_t *top)
< {
< return ucl_array_delete (top, ucl_array_head (top));
< }
---
> UCL_EXTERN ucl_object_t* ucl_array_pop_first (ucl_object_t *top);
580c417
< static inline ucl_object_t * ucl_elt_append (ucl_object_t *head,
---
> UCL_EXTERN ucl_object_t* ucl_elt_append (ucl_object_t *head,
582,584d418
< static inline ucl_object_t *
< ucl_elt_append (ucl_object_t *head, ucl_object_t *elt)
< {
586,600d419
< if (head == NULL) {
< elt->next = NULL;
< elt->prev = elt;
< head = elt;
< }
< else {
< elt->prev = head->prev;
< head->prev->next = elt;
< head->prev = elt;
< elt->next = NULL;
< }
<
< return head;
< }
<
607,623c426
< static inline bool
< ucl_object_todouble_safe (ucl_object_t *obj, double *target)
< {
< if (obj == NULL) {
< return false;
< }
< switch (obj->type) {
< case UCL_INT:
< *target = obj->value.iv; /* Probaly could cause overflow */
< break;
< case UCL_FLOAT:
< case UCL_TIME:
< *target = obj->value.dv;
< break;
< default:
< return false;
< }
---
> UCL_EXTERN bool ucl_object_todouble_safe (ucl_object_t *obj, double *target);
625,627d427
< return true;
< }
<
633,636c433
< static inline double
< ucl_object_todouble (ucl_object_t *obj)
< {
< double result = 0.;
---
> UCL_EXTERN double ucl_object_todouble (ucl_object_t *obj);
638,641d434
< ucl_object_todouble_safe (obj, &result);
< return result;
< }
<
648,664c441
< static inline bool
< ucl_object_toint_safe (ucl_object_t *obj, int64_t *target)
< {
< if (obj == NULL) {
< return false;
< }
< switch (obj->type) {
< case UCL_INT:
< *target = obj->value.iv;
< break;
< case UCL_FLOAT:
< case UCL_TIME:
< *target = obj->value.dv; /* Loosing of decimal points */
< break;
< default:
< return false;
< }
---
> UCL_EXTERN bool ucl_object_toint_safe (ucl_object_t *obj, int64_t *target);
666,668d442
< return true;
< }
<
674,677c448
< static inline int64_t
< ucl_object_toint (ucl_object_t *obj)
< {
< int64_t result = 0;
---
> UCL_EXTERN int64_t ucl_object_toint (ucl_object_t *obj);
679,682d449
< ucl_object_toint_safe (obj, &result);
< return result;
< }
<
689,701c456
< static inline bool
< ucl_object_toboolean_safe (ucl_object_t *obj, bool *target)
< {
< if (obj == NULL) {
< return false;
< }
< switch (obj->type) {
< case UCL_BOOLEAN:
< *target = (obj->value.iv == true);
< break;
< default:
< return false;
< }
---
> UCL_EXTERN bool ucl_object_toboolean_safe (ucl_object_t *obj, bool *target);
703,705d457
< return true;
< }
<
711,714c463
< static inline bool
< ucl_object_toboolean (ucl_object_t *obj)
< {
< bool result = false;
---
> UCL_EXTERN bool ucl_object_toboolean (ucl_object_t *obj);
716,719d464
< ucl_object_toboolean_safe (obj, &result);
< return result;
< }
<
726,731c471
< static inline bool
< ucl_object_tostring_safe (ucl_object_t *obj, const char **target)
< {
< if (obj == NULL) {
< return false;
< }
---
> UCL_EXTERN bool ucl_object_tostring_safe (ucl_object_t *obj, const char **target);
733,743d472
< switch (obj->type) {
< case UCL_STRING:
< *target = ucl_copy_value_trash (obj);
< break;
< default:
< return false;
< }
<
< return true;
< }
<
749,752c478
< static inline const char *
< ucl_object_tostring (ucl_object_t *obj)
< {
< const char *result = NULL;
---
> UCL_EXTERN const char* ucl_object_tostring (ucl_object_t *obj);
754,757d479
< ucl_object_tostring_safe (obj, &result);
< return result;
< }
<
763,767c485
< static inline const char *
< ucl_object_tostring_forced (ucl_object_t *obj)
< {
< return ucl_copy_value_trash (obj);
< }
---
> UCL_EXTERN const char* ucl_object_tostring_forced (ucl_object_t *obj);
777,790c495,496
< static inline bool
< ucl_object_tolstring_safe (ucl_object_t *obj, const char **target, size_t *tlen)
< {
< if (obj == NULL) {
< return false;
< }
< switch (obj->type) {
< case UCL_STRING:
< *target = obj->value.sv;
< *tlen = obj->len;
< break;
< default:
< return false;
< }
---
> UCL_EXTERN bool ucl_object_tolstring_safe (ucl_object_t *obj,
> const char **target, size_t *tlen);
792,794d497
< return true;
< }
<
800,803c503
< static inline const char *
< ucl_object_tolstring (ucl_object_t *obj, size_t *tlen)
< {
< const char *result = NULL;
---
> UCL_EXTERN const char* ucl_object_tolstring (ucl_object_t *obj, size_t *tlen);
805,808d504
< ucl_object_tolstring_safe (obj, &result, tlen);
< return result;
< }
<
815c511
< UCL_EXTERN ucl_object_t * ucl_object_find_key (ucl_object_t *obj, const char *key);
---
> UCL_EXTERN ucl_object_t* ucl_object_find_key (ucl_object_t *obj, const char *key);
824c520
< UCL_EXTERN ucl_object_t *ucl_object_find_keyl (ucl_object_t *obj, const char *key, size_t klen);
---
> UCL_EXTERN ucl_object_t* ucl_object_find_keyl (ucl_object_t *obj, const char *key, size_t klen);
831,835c527
< static inline const char *
< ucl_object_key (ucl_object_t *obj)
< {
< return ucl_copy_key_trash (obj);
< }
---
> UCL_EXTERN const char* ucl_object_key (ucl_object_t *obj);
843,848c535
< static inline const char *
< ucl_object_keyl (ucl_object_t *obj, size_t *len)
< {
< *len = obj->keylen;
< return obj->key;
< }
---
> UCL_EXTERN const char* ucl_object_keyl (ucl_object_t *obj, size_t *len);
860,864c547
< static inline ucl_object_t *
< ucl_object_ref (ucl_object_t *obj) {
< obj->ref ++;
< return obj;
< }
---
> UCL_EXTERN ucl_object_t* ucl_object_ref (ucl_object_t *obj);
870,875c553,554
< static inline void
< ucl_object_unref (ucl_object_t *obj) {
< if (obj != NULL && --obj->ref <= 0) {
< ucl_object_free (obj);
< }
< }
---
> UCL_EXTERN void ucl_object_unref (ucl_object_t *obj);
>
876a556,575
> * Compare objects `o1` and `o2`
> * @param o1 the first object
> * @param o2 the second object
> * @return values >0, 0 and <0 if `o1` is more than, equal and less than `o2`.
> * The order of comparison:
> * 1) Type of objects
> * 2) Size of objects
> * 3) Content of objects
> */
> UCL_EXTERN int ucl_object_compare (ucl_object_t *o1, ucl_object_t *o2);
>
> /**
> * Sort UCL array using `cmp` compare function
> * @param ar
> * @param cmp
> */
> UCL_EXTERN void ucl_object_array_sort (ucl_object_t *ar,
> int (*cmp)(ucl_object_t *o1, ucl_object_t *o2));
>
> /**
947c646,647
< UCL_EXTERN bool ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, size_t len);
---
> UCL_EXTERN bool ucl_parser_add_chunk (struct ucl_parser *parser,
> const unsigned char *data, size_t len);
949a650,659
> * Load ucl object from a string
> * @param parser parser structure
> * @param data the pointer to the string
> * @param len the length of the string, if `len` is 0 then `data` must be zero-terminated string
> * @return true if string has been added and false in case of error
> */
> UCL_EXTERN bool ucl_parser_add_string (struct ucl_parser *parser,
> const char *data,size_t len);
>
> /**
1041a752,793
> /**
> * @defgroup schema Schema functions
> * These functions are used to validate UCL objects using json schema format
> *
> * @{
> */
>
> /**
> * Used to define UCL schema error
> */
> enum ucl_schema_error_code {
> UCL_SCHEMA_OK = 0, /**< no error */
> UCL_SCHEMA_TYPE_MISMATCH, /**< type of object is incorrect */
> UCL_SCHEMA_INVALID_SCHEMA, /**< schema is invalid */
> UCL_SCHEMA_MISSING_PROPERTY,/**< one or more missing properties */
> UCL_SCHEMA_CONSTRAINT, /**< constraint found */
> UCL_SCHEMA_MISSING_DEPENDENCY, /**< missing dependency */
> UCL_SCHEMA_UNKNOWN /**< generic error */
> };
>
> /**
> * Generic ucl schema error
> */
> struct ucl_schema_error {
> enum ucl_schema_error_code code; /**< error code */
> char msg[128]; /**< error message */
> ucl_object_t *obj; /**< object where error occured */
> };
>
> /**
> * Validate object `obj` using schema object `schema`.
> * @param schema schema object
> * @param obj object to validate
> * @param err error pointer, if this parameter is not NULL and error has been
> * occured, then `err` is filled with the exact error definition.
> * @return true if `obj` is valid using `schema`
> */
> UCL_EXTERN bool ucl_object_validate (ucl_object_t *schema,
> ucl_object_t *obj, struct ucl_schema_error *err);
>
> /** @} */
>