diff options
author | bapt <bapt@FreeBSD.org> | 2014-05-24 23:46:41 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2014-05-24 23:46:41 +0000 |
commit | d66fac1ce6945cd9678282056da4d2f4fabb4adc (patch) | |
tree | d79bb7ef653c040679a51c1bace22f0fb236ccd4 /contrib/libucl/include/ucl.h | |
parent | 51a05acc08355b84ae16b193ccb7037691f8ba90 (diff) | |
download | FreeBSD-src-d66fac1ce6945cd9678282056da4d2f4fabb4adc.zip FreeBSD-src-d66fac1ce6945cd9678282056da4d2f4fabb4adc.tar.gz |
merge libucl 20140514
this version brings xpath-like interface for ucl objects
Diffstat (limited to 'contrib/libucl/include/ucl.h')
-rw-r--r-- | contrib/libucl/include/ucl.h | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/contrib/libucl/include/ucl.h b/contrib/libucl/include/ucl.h index 08039b2..3eeea9a 100644 --- a/contrib/libucl/include/ucl.h +++ b/contrib/libucl/include/ucl.h @@ -236,7 +236,13 @@ UCL_EXTERN ucl_object_t* ucl_object_new (void) UCL_WARN_UNUSED_RESULT; * @param type type of a new object * @return new object */ -UCL_EXTERN ucl_object_t* ucl_object_typed_new (unsigned int type) UCL_WARN_UNUSED_RESULT; +UCL_EXTERN ucl_object_t* ucl_object_typed_new (ucl_type_t type) UCL_WARN_UNUSED_RESULT; + +/** + * Return the type of an object + * @return the object type + */ +UCL_EXTERN ucl_type_t ucl_object_type (const ucl_object_t *obj); /** * Convert any string to an ucl object making the specified transformations @@ -413,6 +419,15 @@ UCL_EXTERN const ucl_object_t* ucl_array_tail (const ucl_object_t *top); UCL_EXTERN ucl_object_t* ucl_array_pop_last (ucl_object_t *top); /** + * Return object identified by an index of the array `top` + * @param obj object to get a key from (must be of type UCL_ARRAY) + * @param index index to return + * @return object at the specified index or NULL if index is not found + */ +UCL_EXTERN const ucl_object_t* ucl_array_find_index (const ucl_object_t *top, + unsigned int index); + +/** * Removes the first element from the array `top`. Caller must unref the returned object when it is not * needed. * @param top array ucl object @@ -534,6 +549,15 @@ UCL_EXTERN const ucl_object_t* ucl_object_find_keyl (const ucl_object_t *obj, const char *key, size_t klen); /** + * Return object identified by dot notation string + * @param obj object to search in + * @param path dot.notation.path to the path to lookup. May use numeric .index on arrays + * @return object matched the specified path or NULL if path is not found + */ +UCL_EXTERN const ucl_object_t *ucl_lookup_path (const ucl_object_t *obj, + const char *path); + +/** * Returns a key of an object as a NULL terminated string * @param obj CL object * @return key or NULL if there is no key @@ -643,6 +667,19 @@ UCL_EXTERN void ucl_parser_register_macro (struct ucl_parser *parser, const char ucl_macro_handler handler, void* ud); /** + * Handler to detect unregistered variables + * @param data variable data + * @param len length of variable + * @param replace (out) replace value for variable + * @param replace_len (out) replace length for variable + * @param need_free (out) UCL will free `dest` after usage + * @param ud opaque userdata + * @return true if variable + */ +typedef bool (*ucl_variable_handler) (const unsigned char *data, size_t len, + unsigned char **replace, size_t *replace_len, bool *need_free, void* ud); + +/** * Register new parser variable * @param parser parser object * @param var variable name @@ -652,6 +689,15 @@ UCL_EXTERN void ucl_parser_register_variable (struct ucl_parser *parser, const c const char *value); /** + * Set handler for unknown variables + * @param parser parser structure + * @param handler desired handler + * @param ud opaque data for the handler + */ +UCL_EXTERN void ucl_parser_set_variables_handler (struct ucl_parser *parser, + ucl_variable_handler handler, void *ud); + +/** * Load new chunk to a parser * @param parser parser structure * @param data the pointer to the beginning of a chunk |