diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-05-24 23:40:39 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-05-24 23:40:39 +0000 |
commit | eaa81a1805da0fde938c109a768e9c48471c3bb9 (patch) | |
tree | 11177c8667280f65b11e0c5d96830f43a8e5d860 /include/ucl.h | |
parent | d4fc17b1e5ff64ea70cfb02594ae87f599f81c29 (diff) | |
download | src-eaa81a1805da0fde938c109a768e9c48471c3bb9.tar.gz src-eaa81a1805da0fde938c109a768e9c48471c3bb9.zip |
Import libucl version 2014-05-14 (almost 0.4.1)vendor/libucl/20140514
This bring ucl_lookup_path (xpath like for ucl objects)
Notes
Notes:
svn path=/vendor/libucl/dist/; revision=266634
svn path=/vendor/libucl/20140514/; revision=266635; tag=vendor/libucl/20140514
Diffstat (limited to 'include/ucl.h')
-rw-r--r-- | include/ucl.h | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/include/ucl.h b/include/ucl.h index 08039b29001e..3eeea9a7df0e 100644 --- a/include/ucl.h +++ b/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 |