Config-UCL

 view release on metacpan or  search on metacpan

libucl-0.8.1/include/ucl.h  view on Meta::CPAN

/**
 * Utility function to find a comment object for the specified object in the input
 * @param comments comments object
 * @param srch search object
 * @return string comment enclosed in ucl_object_t
 */
UCL_EXTERN const ucl_object_t * ucl_comments_find (const ucl_object_t *comments,
		const ucl_object_t *srch);

/**
 * Move comment from `from` object to `to` object
 * @param comments comments object
 * @param what source object
 * @param with destination object
 * @return `true` if `from` has comment and it has been moved to `to`
 */
UCL_EXTERN bool ucl_comments_move (ucl_object_t *comments,
		const ucl_object_t *from, const ucl_object_t *to);

/**
 * Adds a new comment for an object
 * @param comments comments object
 * @param obj object to add comment to
 * @param comment string representation of a comment
 */
UCL_EXTERN void ucl_comments_add (ucl_object_t *comments,
		const ucl_object_t *obj, const char *comment);

/**
 * Add new public key to parser for signatures check
 * @param parser parser object
 * @param key PEM representation of a key
 * @param len length of the key
 * @param err if *err is NULL it is set to parser error
 * @return true if a key has been successfully added
 */
UCL_EXTERN bool ucl_parser_pubkey_add (struct ucl_parser *parser,
		const unsigned char *key, size_t len);

/**
 * Set FILENAME and CURDIR variables in parser
 * @param parser parser object
 * @param filename filename to set or NULL to set FILENAME to "undef" and CURDIR to getcwd()
 * @param need_expand perform realpath() if this variable is true and filename is not NULL
 * @return true if variables has been set
 */
UCL_EXTERN bool ucl_parser_set_filevars (struct ucl_parser *parser, const char *filename,
		bool need_expand);

/** @} */

/**
 * @defgroup emitter Emitting functions
 * These functions are used to serialise UCL objects to some string representation.
 *
 * @{
 */

struct ucl_emitter_context;
/**
 * Structure using for emitter callbacks
 */
struct ucl_emitter_functions {
	/** Append a single character */
	int (*ucl_emitter_append_character) (unsigned char c, size_t nchars, void *ud);
	/** Append a string of a specified length */
	int (*ucl_emitter_append_len) (unsigned const char *str, size_t len, void *ud);
	/** Append a 64 bit integer */
	int (*ucl_emitter_append_int) (int64_t elt, void *ud);
	/** Append floating point element */
	int (*ucl_emitter_append_double) (double elt, void *ud);
	/** Free userdata */
	void (*ucl_emitter_free_func)(void *ud);
	/** Opaque userdata pointer */
	void *ud;
};

struct ucl_emitter_operations {
	/** Write a primitive element */
	void (*ucl_emitter_write_elt) (struct ucl_emitter_context *ctx,
		const ucl_object_t *obj, bool first, bool print_key);
	/** Start ucl object */
	void (*ucl_emitter_start_object) (struct ucl_emitter_context *ctx,
		const ucl_object_t *obj, bool print_key);
	/** End ucl object */
	void (*ucl_emitter_end_object) (struct ucl_emitter_context *ctx,
		const ucl_object_t *obj);
	/** Start ucl array */
	void (*ucl_emitter_start_array) (struct ucl_emitter_context *ctx,
		const ucl_object_t *obj, bool print_key);
	void (*ucl_emitter_end_array) (struct ucl_emitter_context *ctx,
		const ucl_object_t *obj);
};

/**
 * Structure that defines emitter functions
 */
struct ucl_emitter_context {
	/** Name of emitter (e.g. json, compact_json) */
	const char *name;
	/** Unique id (e.g. UCL_EMIT_JSON for standard emitters */
	int id;
	/** A set of output functions */
	const struct ucl_emitter_functions *func;
	/** A set of output operations */
	const struct ucl_emitter_operations *ops;
	/** Current amount of indent tabs */
	unsigned int indent;
	/** Top level object */
	const ucl_object_t *top;
	/** Optional comments */
	const ucl_object_t *comments;
};

/**
 * Emit object to a string
 * @param obj object
 * @param emit_type if type is #UCL_EMIT_JSON then emit json, if type is
 * #UCL_EMIT_CONFIG then emit config like object
 * @return dump of an object (must be freed after using) or NULL in case of error
 */



( run in 0.507 second using v1.01-cache-2.11-cpan-39bf76dae61 )