1 /* Copyright (c) 2013, Vsevolod Stakhov
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
12 * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
13 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15 * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
16 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * This is a reference manual for UCL API. You may find the description of UCL format by following this
38 * [github repository](https://github.com/vstakhov/libucl).
40 * This manual has several main sections:
49 * @brief UCL parsing and emitting functions
51 * UCL is universal configuration language, which is a form of
52 * JSON with less strict rules that make it more comfortable for
53 * using as a configuration language
59 * Memory allocation utilities
60 * UCL_ALLOC(size) - allocate memory for UCL
61 * UCL_FREE(size, ptr) - free memory of specified size at ptr
62 * Default: malloc and free
65 #define UCL_ALLOC(size) malloc(size)
68 #define UCL_FREE(size, ptr) free(ptr)
71 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
72 #define UCL_WARN_UNUSED_RESULT \
73 __attribute__((warn_unused_result))
75 #define UCL_WARN_UNUSED_RESULT
79 * @defgroup structures Structures and types
80 * UCL defines several enumeration types used for error reporting or specifying flags and attributes.
86 * The common error codes returned by ucl parser
88 typedef enum ucl_error {
89 UCL_EOK = 0, /**< No error */
90 UCL_ESYNTAX, /**< Syntax error occurred during parsing */
91 UCL_EIO, /**< IO error occurred during parsing */
92 UCL_ESTATE, /**< Invalid state machine state */
93 UCL_ENESTED, /**< Input has too many recursion levels */
94 UCL_EMACRO, /**< Error processing a macro */
95 UCL_EINTERNAL, /**< Internal unclassified error */
96 UCL_ESSL /**< SSL error */
100 * #ucl_object_t may have one of specified types, some types are compatible with each other and some are not.
101 * For example, you can always convert #UCL_TIME to #UCL_FLOAT. Also you can convert #UCL_FLOAT to #UCL_INTEGER
102 * by loosing floating point. Every object may be converted to a string by #ucl_object_tostring_forced() function.
105 typedef enum ucl_type {
106 UCL_OBJECT = 0, /**< UCL object - key/value pairs */
107 UCL_ARRAY, /**< UCL array */
108 UCL_INT, /**< Integer number */
109 UCL_FLOAT, /**< Floating point number */
110 UCL_STRING, /**< Null terminated string */
111 UCL_BOOLEAN, /**< Boolean value */
112 UCL_TIME, /**< Time value (floating point number of seconds) */
113 UCL_USERDATA, /**< Opaque userdata pointer (may be used in macros) */
114 UCL_NULL /**< Null value */
118 * You can use one of these types to serialise #ucl_object_t by using ucl_object_emit().
120 typedef enum ucl_emitter {
121 UCL_EMIT_JSON = 0, /**< Emit fine formatted JSON */
122 UCL_EMIT_JSON_COMPACT, /**< Emit compacted JSON */
123 UCL_EMIT_CONFIG, /**< Emit human readable config format */
124 UCL_EMIT_YAML /**< Emit embedded YAML format */
128 * These flags defines parser behaviour. If you specify #UCL_PARSER_ZEROCOPY you must ensure
129 * that the input memory is not freed if an object is in use. Moreover, if you want to use
130 * zero-terminated keys and string values then you should not use zero-copy mode, as in this case
131 * UCL still has to perform copying implicitly.
133 typedef enum ucl_parser_flags {
134 UCL_PARSER_KEY_LOWERCASE = 0x1, /**< Convert all keys to lower case */
135 UCL_PARSER_ZEROCOPY = 0x2 /**< Parse input in zero-copy mode if possible */
136 } ucl_parser_flags_t;
139 * String conversion flags, that are used in #ucl_object_fromstring_common function.
141 typedef enum ucl_string_flags {
142 UCL_STRING_ESCAPE = 0x1, /**< Perform JSON escape */
143 UCL_STRING_TRIM = 0x2, /**< Trim leading and trailing whitespaces */
144 UCL_STRING_PARSE_BOOLEAN = 0x4, /**< Parse passed string and detect boolean */
145 UCL_STRING_PARSE_INT = 0x8, /**< Parse passed string and detect integer number */
146 UCL_STRING_PARSE_DOUBLE = 0x10, /**< Parse passed string and detect integer or float number */
147 UCL_STRING_PARSE_NUMBER = UCL_STRING_PARSE_INT|UCL_STRING_PARSE_DOUBLE , /**<
148 Parse passed string and detect number */
149 UCL_STRING_PARSE = UCL_STRING_PARSE_BOOLEAN|UCL_STRING_PARSE_NUMBER, /**<
150 Parse passed string (and detect booleans and numbers) */
151 UCL_STRING_PARSE_BYTES = 0x20 /**< Treat numbers as bytes */
152 } ucl_string_flags_t;
155 * Basic flags for an object
157 typedef enum ucl_object_flags {
158 UCL_OBJECT_ALLOCATED_KEY = 1, /**< An object has key allocated internally */
159 UCL_OBJECT_ALLOCATED_VALUE = 2, /**< An object has a string value allocated internally */
160 UCL_OBJECT_NEED_KEY_ESCAPE = 4 /**< The key of an object need to be escaped on output */
161 } ucl_object_flags_t;
164 * UCL object structure. Please mention that the most of fields should not be touched by
165 * UCL users. In future, this structure may be converted to private one.
167 typedef struct ucl_object_s {
172 int64_t iv; /**< Int value of an object */
173 const char *sv; /**< String value of an object */
174 double dv; /**< Double value of an object */
175 struct ucl_object_s *av; /**< Array */
176 void *ov; /**< Object */
177 void* ud; /**< Opaque user data */
179 const char *key; /**< Key of an object */
180 struct ucl_object_s *next; /**< Array handle */
181 struct ucl_object_s *prev; /**< Array handle */
182 unsigned char* trash_stack[2]; /**< Pointer to allocated chunks */
183 unsigned keylen; /**< Lenght of a key */
184 unsigned len; /**< Size of an object */
185 enum ucl_type type; /**< Real type */
186 uint16_t ref; /**< Reference count */
187 uint16_t flags; /**< Object flags */
193 * @defgroup utils Utility functions
194 * A number of utility functions simplify handling of UCL objects
199 * Copy and return a key of an object, returned key is zero-terminated
200 * @param obj CL object
201 * @return zero terminated key
203 char* ucl_copy_key_trash (ucl_object_t *obj);
206 * Copy and return a string value of an object, returned key is zero-terminated
207 * @param obj CL object
208 * @return zero terminated string representation of object value
210 char* ucl_copy_value_trash (ucl_object_t *obj);
213 * Creates a new object
216 static inline ucl_object_t* ucl_object_new (void) UCL_WARN_UNUSED_RESULT;
217 static inline ucl_object_t *
218 ucl_object_new (void)
221 new = malloc (sizeof (ucl_object_t));
223 memset (new, 0, sizeof (ucl_object_t));
225 new->type = UCL_NULL;
231 * Create new object with type specified
232 * @param type type of a new object
235 static inline ucl_object_t* ucl_object_typed_new (unsigned int type) UCL_WARN_UNUSED_RESULT;
236 static inline ucl_object_t *
237 ucl_object_typed_new (unsigned int type)
240 new = malloc (sizeof (ucl_object_t));
242 memset (new, 0, sizeof (ucl_object_t));
244 new->type = (type <= UCL_NULL ? type : UCL_NULL);
250 * Convert any string to an ucl object making the specified transformations
251 * @param str fixed size or NULL terminated string
252 * @param len length (if len is zero, than str is treated as NULL terminated)
253 * @param flags conversion flags
256 ucl_object_t * ucl_object_fromstring_common (const char *str, size_t len,
257 enum ucl_string_flags flags) UCL_WARN_UNUSED_RESULT;
260 * Create a UCL object from the specified string
261 * @param str NULL terminated string, will be json escaped
264 static inline ucl_object_t *
265 ucl_object_fromstring (const char *str)
267 return ucl_object_fromstring_common (str, 0, UCL_STRING_ESCAPE);
271 * Create a UCL object from the specified string
272 * @param str fixed size string, will be json escaped
273 * @param len length of a string
276 static inline ucl_object_t *
277 ucl_object_fromlstring (const char *str, size_t len)
279 return ucl_object_fromstring_common (str, len, UCL_STRING_ESCAPE);
283 * Create an object from an integer number
287 static inline ucl_object_t *
288 ucl_object_fromint (int64_t iv)
292 obj = ucl_object_new ();
302 * Create an object from a float number
306 static inline ucl_object_t *
307 ucl_object_fromdouble (double dv)
311 obj = ucl_object_new ();
313 obj->type = UCL_FLOAT;
321 * Create an object from a boolean
322 * @param bv bool value
325 static inline ucl_object_t *
326 ucl_object_frombool (bool bv)
330 obj = ucl_object_new ();
332 obj->type = UCL_BOOLEAN;
340 * Insert a object 'elt' to the hash 'top' and associate it with key 'key'
341 * @param top destination object (will be created automatically if top is NULL)
342 * @param elt element to insert (must NOT be NULL)
343 * @param key key to associate with this object (either const or preallocated)
344 * @param keylen length of the key (or 0 for NULL terminated keys)
345 * @param copy_key make an internal copy of key
346 * @return new value of top object
348 ucl_object_t* ucl_object_insert_key (ucl_object_t *top, ucl_object_t *elt,
349 const char *key, size_t keylen, bool copy_key) UCL_WARN_UNUSED_RESULT;
352 * Replace a object 'elt' to the hash 'top' and associate it with key 'key', old object will be unrefed,
353 * if no object has been found this function works like ucl_object_insert_key()
354 * @param top destination object (will be created automatically if top is NULL)
355 * @param elt element to insert (must NOT be NULL)
356 * @param key key to associate with this object (either const or preallocated)
357 * @param keylen length of the key (or 0 for NULL terminated keys)
358 * @param copy_key make an internal copy of key
359 * @return new value of top object
361 ucl_object_t* ucl_object_replace_key (ucl_object_t *top, ucl_object_t *elt,
362 const char *key, size_t keylen, bool copy_key) UCL_WARN_UNUSED_RESULT;
365 * Insert a object 'elt' to the hash 'top' and associate it with key 'key', if the specified key exist,
366 * try to merge its content
367 * @param top destination object (will be created automatically if top is NULL)
368 * @param elt element to insert (must NOT be NULL)
369 * @param key key to associate with this object (either const or preallocated)
370 * @param keylen length of the key (or 0 for NULL terminated keys)
371 * @param copy_key make an internal copy of key
372 * @return new value of top object
374 ucl_object_t* ucl_object_insert_key_merged (ucl_object_t *top, ucl_object_t *elt,
375 const char *key, size_t keylen, bool copy_key) UCL_WARN_UNUSED_RESULT;
378 * Append an element to the front of array object
379 * @param top destination object (will be created automatically if top is NULL)
380 * @param elt element to append (must NOT be NULL)
381 * @return new value of top object
383 static inline ucl_object_t * ucl_array_append (ucl_object_t *top,
384 ucl_object_t *elt) UCL_WARN_UNUSED_RESULT;
385 static inline ucl_object_t *
386 ucl_array_append (ucl_object_t *top, ucl_object_t *elt)
395 top = ucl_object_typed_new (UCL_ARRAY);
402 head = top->value.av;
408 elt->prev = head->prev;
409 head->prev->next = elt;
420 * Append an element to the start of array object
421 * @param top destination object (will be created automatically if top is NULL)
422 * @param elt element to append (must NOT be NULL)
423 * @return new value of top object
425 static inline ucl_object_t * ucl_array_prepend (ucl_object_t *top,
426 ucl_object_t *elt) UCL_WARN_UNUSED_RESULT;
427 static inline ucl_object_t *
428 ucl_array_prepend (ucl_object_t *top, ucl_object_t *elt)
437 top = ucl_object_typed_new (UCL_ARRAY);
444 head = top->value.av;
450 elt->prev = head->prev;
462 * Removes an element `elt` from the array `top`. Caller must unref the returned object when it is not
464 * @param top array ucl object
465 * @param elt element to remove
466 * @return removed element or NULL if `top` is NULL or not an array
468 static inline ucl_object_t *
469 ucl_array_delete (ucl_object_t *top, ucl_object_t *elt)
473 if (top == NULL || top->type != UCL_ARRAY || top->value.av == NULL) {
476 head = top->value.av;
478 if (elt->prev == elt) {
479 top->value.av = NULL;
481 else if (elt == head) {
482 elt->next->prev = elt->prev;
483 top->value.av = elt->next;
486 elt->prev->next = elt->next;
488 elt->next->prev = elt->prev;
491 head->prev = elt->prev;
502 * Returns the first element of the array `top`
503 * @param top array ucl object
504 * @return element or NULL if `top` is NULL or not an array
506 static inline ucl_object_t *
507 ucl_array_head (ucl_object_t *top)
509 if (top == NULL || top->type != UCL_ARRAY || top->value.av == NULL) {
512 return top->value.av;
516 * Returns the last element of the array `top`
517 * @param top array ucl object
518 * @return element or NULL if `top` is NULL or not an array
520 static inline ucl_object_t *
521 ucl_array_tail (ucl_object_t *top)
523 if (top == NULL || top->type != UCL_ARRAY || top->value.av == NULL) {
526 return top->value.av->prev;
530 * Removes the last element from the array `top`. Caller must unref the returned object when it is not
532 * @param top array ucl object
533 * @return removed element or NULL if `top` is NULL or not an array
535 static inline ucl_object_t *
536 ucl_array_pop_last (ucl_object_t *top)
538 return ucl_array_delete (top, ucl_array_tail (top));
542 * Removes the first element from the array `top`. Caller must unref the returned object when it is not
544 * @param top array ucl object
545 * @return removed element or NULL if `top` is NULL or not an array
547 static inline ucl_object_t *
548 ucl_array_pop_first (ucl_object_t *top)
550 return ucl_array_delete (top, ucl_array_head (top));
554 * Append a element to another element forming an implicit array
555 * @param head head to append (may be NULL)
556 * @param elt new element
557 * @return new head if applicable
559 static inline ucl_object_t * ucl_elt_append (ucl_object_t *head,
560 ucl_object_t *elt) UCL_WARN_UNUSED_RESULT;
561 static inline ucl_object_t *
562 ucl_elt_append (ucl_object_t *head, ucl_object_t *elt)
571 elt->prev = head->prev;
572 head->prev->next = elt;
581 * Converts an object to double value
582 * @param obj CL object
583 * @param target target double variable
584 * @return true if conversion was successful
587 ucl_object_todouble_safe (ucl_object_t *obj, double *target)
594 *target = obj->value.iv; /* Probaly could cause overflow */
598 *target = obj->value.dv;
608 * Unsafe version of \ref ucl_obj_todouble_safe
609 * @param obj CL object
610 * @return double value
613 ucl_object_todouble (ucl_object_t *obj)
617 ucl_object_todouble_safe (obj, &result);
622 * Converts an object to integer value
623 * @param obj CL object
624 * @param target target integer variable
625 * @return true if conversion was successful
628 ucl_object_toint_safe (ucl_object_t *obj, int64_t *target)
635 *target = obj->value.iv;
639 *target = obj->value.dv; /* Loosing of decimal points */
649 * Unsafe version of \ref ucl_obj_toint_safe
650 * @param obj CL object
653 static inline int64_t
654 ucl_object_toint (ucl_object_t *obj)
658 ucl_object_toint_safe (obj, &result);
663 * Converts an object to boolean value
664 * @param obj CL object
665 * @param target target boolean variable
666 * @return true if conversion was successful
669 ucl_object_toboolean_safe (ucl_object_t *obj, bool *target)
676 *target = (obj->value.iv == true);
686 * Unsafe version of \ref ucl_obj_toboolean_safe
687 * @param obj CL object
688 * @return boolean value
691 ucl_object_toboolean (ucl_object_t *obj)
695 ucl_object_toboolean_safe (obj, &result);
700 * Converts an object to string value
701 * @param obj CL object
702 * @param target target string variable, no need to free value
703 * @return true if conversion was successful
706 ucl_object_tostring_safe (ucl_object_t *obj, const char **target)
714 *target = ucl_copy_value_trash (obj);
724 * Unsafe version of \ref ucl_obj_tostring_safe
725 * @param obj CL object
726 * @return string value
728 static inline const char *
729 ucl_object_tostring (ucl_object_t *obj)
731 const char *result = NULL;
733 ucl_object_tostring_safe (obj, &result);
738 * Convert any object to a string in JSON notation if needed
739 * @param obj CL object
740 * @return string value
742 static inline const char *
743 ucl_object_tostring_forced (ucl_object_t *obj)
745 return ucl_copy_value_trash (obj);
749 * Return string as char * and len, string may be not zero terminated, more efficient that \ref ucl_obj_tostring as it
750 * allows zero-copy (if #UCL_PARSER_ZEROCOPY has been used during parsing)
751 * @param obj CL object
752 * @param target target string variable, no need to free value
753 * @param tlen target length
754 * @return true if conversion was successful
757 ucl_object_tolstring_safe (ucl_object_t *obj, const char **target, size_t *tlen)
764 *target = obj->value.sv;
775 * Unsafe version of \ref ucl_obj_tolstring_safe
776 * @param obj CL object
777 * @return string value
779 static inline const char *
780 ucl_object_tolstring (ucl_object_t *obj, size_t *tlen)
782 const char *result = NULL;
784 ucl_object_tolstring_safe (obj, &result, tlen);
789 * Return object identified by a key in the specified object
790 * @param obj object to get a key from (must be of type UCL_OBJECT)
791 * @param key key to search
792 * @return object matched the specified key or NULL if key is not found
794 ucl_object_t * ucl_object_find_key (ucl_object_t *obj, const char *key);
797 * Return object identified by a fixed size key in the specified object
798 * @param obj object to get a key from (must be of type UCL_OBJECT)
799 * @param key key to search
800 * @param klen length of a key
801 * @return object matched the specified key or NULL if key is not found
803 ucl_object_t *ucl_object_find_keyl (ucl_object_t *obj, const char *key, size_t klen);
806 * Returns a key of an object as a NULL terminated string
807 * @param obj CL object
808 * @return key or NULL if there is no key
810 static inline const char *
811 ucl_object_key (ucl_object_t *obj)
813 return ucl_copy_key_trash (obj);
817 * Returns a key of an object as a fixed size string (may be more efficient)
818 * @param obj CL object
819 * @param len target key length
820 * @return key pointer
822 static inline const char *
823 ucl_object_keyl (ucl_object_t *obj, size_t *len)
831 * @param obj ucl object to free
833 void ucl_object_free (ucl_object_t *obj);
836 * Increase reference count for an object
837 * @param obj object to ref
839 static inline ucl_object_t *
840 ucl_object_ref (ucl_object_t *obj) {
846 * Decrease reference count for an object
847 * @param obj object to unref
850 ucl_object_unref (ucl_object_t *obj) {
851 if (obj != NULL && --obj->ref <= 0) {
852 ucl_object_free (obj);
856 * Opaque iterator object
858 typedef void* ucl_object_iter_t;
861 * Get next key from an object
862 * @param obj object to iterate
863 * @param iter opaque iterator, must be set to NULL on the first call:
864 * ucl_object_iter_t it = NULL;
865 * while ((cur = ucl_iterate_object (obj, &it)) != NULL) ...
866 * @return the next object or NULL
868 ucl_object_t* ucl_iterate_object (ucl_object_t *obj, ucl_object_iter_t *iter, bool expand_values);
873 * @defgroup parser Parsing functions
874 * These functions are used to parse UCL objects
880 * Macro handler for a parser
881 * @param data the content of macro
882 * @param len the length of content
883 * @param ud opaque user data
884 * @param err error pointer
885 * @return true if macro has been parsed
887 typedef bool (*ucl_macro_handler) (const unsigned char *data, size_t len, void* ud);
893 * Creates new parser object
894 * @param pool pool to allocate memory from
895 * @return new parser object
897 struct ucl_parser* ucl_parser_new (int flags);
900 * Register new handler for a macro
901 * @param parser parser object
902 * @param macro macro name (without leading dot)
903 * @param handler handler (it is called immediately after macro is parsed)
904 * @param ud opaque user data for a handler
906 void ucl_parser_register_macro (struct ucl_parser *parser, const char *macro,
907 ucl_macro_handler handler, void* ud);
910 * Register new parser variable
911 * @param parser parser object
912 * @param var variable name
913 * @param value variable value
915 void ucl_parser_register_variable (struct ucl_parser *parser, const char *var,
919 * Load new chunk to a parser
920 * @param parser parser structure
921 * @param data the pointer to the beginning of a chunk
922 * @param len the length of a chunk
923 * @param err if *err is NULL it is set to parser error
924 * @return true if chunk has been added and false in case of error
926 bool ucl_parser_add_chunk (struct ucl_parser *parser, const unsigned char *data, size_t len);
929 * Load and add data from a file
930 * @param parser parser structure
931 * @param filename the name of file
932 * @param err if *err is NULL it is set to parser error
933 * @return true if chunk has been added and false in case of error
935 bool ucl_parser_add_file (struct ucl_parser *parser, const char *filename);
938 * Get a top object for a parser
939 * @param parser parser structure
940 * @param err if *err is NULL it is set to parser error
941 * @return top parser object or NULL
943 ucl_object_t* ucl_parser_get_object (struct ucl_parser *parser);
946 * Get the error string if failing
947 * @param parser parser object
949 const char *ucl_parser_get_error(struct ucl_parser *parser);
951 * Free ucl parser object
952 * @param parser parser object
954 void ucl_parser_free (struct ucl_parser *parser);
957 * Add new public key to parser for signatures check
958 * @param parser parser object
959 * @param key PEM representation of a key
960 * @param len length of the key
961 * @param err if *err is NULL it is set to parser error
962 * @return true if a key has been successfully added
964 bool ucl_pubkey_add (struct ucl_parser *parser, const unsigned char *key, size_t len);
967 * Set FILENAME and CURDIR variables in parser
968 * @param parser parser object
969 * @param filename filename to set or NULL to set FILENAME to "undef" and CURDIR to getcwd()
970 * @param need_expand perform realpath() if this variable is true and filename is not NULL
971 * @return true if variables has been set
973 bool ucl_parser_set_filevars (struct ucl_parser *parser, const char *filename,
979 * @defgroup emitter Emitting functions
980 * These functions are used to serialise UCL objects to some string representation.
986 * Structure using for emitter callbacks
988 struct ucl_emitter_functions {
989 /** Append a single character */
990 int (*ucl_emitter_append_character) (unsigned char c, size_t nchars, void *ud);
991 /** Append a string of a specified length */
992 int (*ucl_emitter_append_len) (unsigned const char *str, size_t len, void *ud);
993 /** Append a 64 bit integer */
994 int (*ucl_emitter_append_int) (int64_t elt, void *ud);
995 /** Append floating point element */
996 int (*ucl_emitter_append_double) (double elt, void *ud);
997 /** Opaque userdata pointer */
1002 * Emit object to a string
1004 * @param emit_type if type is #UCL_EMIT_JSON then emit json, if type is
1005 * #UCL_EMIT_CONFIG then emit config like object
1006 * @return dump of an object (must be freed after using) or NULL in case of error
1008 unsigned char *ucl_object_emit (ucl_object_t *obj, enum ucl_emitter emit_type);
1011 * Emit object to a string
1013 * @param emit_type if type is #UCL_EMIT_JSON then emit json, if type is
1014 * #UCL_EMIT_CONFIG then emit config like object
1015 * @return dump of an object (must be freed after using) or NULL in case of error
1017 bool ucl_object_emit_full (ucl_object_t *obj, enum ucl_emitter emit_type,
1018 struct ucl_emitter_functions *emitter);
1025 * XXX: Poorly named API functions, need to replace them with the appropriate
1026 * named function. All API functions *must* use naming ucl_object_*. Usage of
1027 * ucl_obj* should be avoided.
1029 #define ucl_obj_todouble_safe ucl_object_todouble_safe
1030 #define ucl_obj_todouble ucl_object_todouble
1031 #define ucl_obj_tostring ucl_object_tostring
1032 #define ucl_obj_tostring_safe ucl_object_tostring_safe
1033 #define ucl_obj_tolstring ucl_object_tolstring
1034 #define ucl_obj_tolstring_safe ucl_object_tolstring_safe
1035 #define ucl_obj_toint ucl_object_toint
1036 #define ucl_obj_toint_safe ucl_object_toint_safe
1037 #define ucl_obj_toboolean ucl_object_toboolean
1038 #define ucl_obj_toboolean_safe ucl_object_toboolean_safe
1039 #define ucl_obj_get_key ucl_object_find_key
1040 #define ucl_obj_get_keyl ucl_object_find_keyl
1041 #define ucl_obj_unref ucl_object_unref
1042 #define ucl_obj_ref ucl_object_ref
1043 #define ucl_obj_free ucl_object_free