77#ifndef PARACONF_H__
88#define PARACONF_H__
99
10- #include <string.h>
1110#include <stdarg.h>
11+ #include <string.h>
1212#include <yaml.h>
1313
1414#include "paraconf_export.h"
@@ -24,7 +24,7 @@ extern "C" {
2424 */
2525typedef enum PC_status_e {
2626 /// no error
27- PC_OK = 0 ,
27+ PC_OK = 0 ,
2828 /// a parameter value is invalid
2929 PC_INVALID_PARAMETER ,
3030 /// unexpected type found for a node
@@ -42,30 +42,28 @@ typedef enum PC_status_e {
4242 * \param message the human-readable error message
4343 * \param context a user-provided context
4444 */
45- typedef void (* PC_errfunc_f )(PC_status_t status , const char * message , void * context );
45+ typedef void (* PC_errfunc_f )(PC_status_t status , const char * message , void * context );
4646
4747/** Definition of an error handler
4848 */
49- typedef struct PC_errhandler_s
50- {
49+ typedef struct PC_errhandler_s {
5150 /// The function to handle the error (none if NULL)
5251 PC_errfunc_f func ;
53-
52+
5453 /// the context that will be provided to the function
55- void * context ;
56-
54+ void * context ;
55+
5756} PC_errhandler_t ;
5857
5958/** An opaque type describing a yaml tree (possibly a leaf node)
6059 */
61- typedef struct PC_tree_s
62- {
60+ typedef struct PC_tree_s {
6361 /// The tree status
6462 PC_status_t status ;
65-
63+
6664 /// The document containing the tree
6765 yaml_document_t * document ;
68-
66+
6967 /// the node inside the tree
7068 yaml_node_t * node ;
7169
@@ -83,11 +81,14 @@ extern const PARACONF_EXPORT PC_errhandler_t PC_NULL_HANDLER;
8381 * \param tree the tree to check
8482 * \return the status
8583 */
86- static inline PC_status_t PC_status (PC_tree_t tree ) { return tree .status ; }
84+ static inline PC_status_t PC_status (PC_tree_t tree )
85+ {
86+ return tree .status ;
87+ }
8788
8889/** Return a human-readabe message describing the last error that occured in paraconf
8990 */
90- char PARACONF_EXPORT * PC_errmsg ();
91+ char PARACONF_EXPORT * PC_errmsg ();
9192
9293/** Sets the error handler to use
9394 *
@@ -108,7 +109,7 @@ PC_errhandler_t PARACONF_EXPORT PC_errhandler(PC_errhandler_t handler);
108109 * \param[in] path the file path as a character string
109110 * \return the tree, valid as long as the containing document is
110111 */
111- PC_tree_t PARACONF_EXPORT PC_parse_path (const char * path );
112+ PC_tree_t PARACONF_EXPORT PC_parse_path (const char * path );
112113
113114/** Returns the tree as found in an already open file
114115 *
@@ -120,7 +121,7 @@ PC_tree_t PARACONF_EXPORT PC_parse_path(const char *path);
120121 * \param[in] file the file containing the tree
121122 * \return the tree, valid as long as the containing document is
122123 */
123- PC_tree_t PARACONF_EXPORT PC_parse_file (FILE * file );
124+ PC_tree_t PARACONF_EXPORT PC_parse_file (FILE * file );
124125
125126/** Returns the tree contained in a character string
126127 *
@@ -132,7 +133,7 @@ PC_tree_t PARACONF_EXPORT PC_parse_file(FILE *file);
132133 * \param[in] document the document as a character string to parse
133134 * \return the tree, valid as long as the containing document is
134135 */
135- PC_tree_t PARACONF_EXPORT PC_parse_string (const char * document );
136+ PC_tree_t PARACONF_EXPORT PC_parse_string (const char * document );
136137
137138/** Returns the tree at the root of a document
138139 *
@@ -161,7 +162,7 @@ PC_tree_t PARACONF_EXPORT PC_root(yaml_document_t* document);
161162 * \param[in] ... the printf-style values
162163 * \return the subtree corresponding to the ypath index
163164 */
164- PC_tree_t PARACONF_EXPORT PC_get (PC_tree_t tree , const char * index_fmt , ...);
165+ PC_tree_t PARACONF_EXPORT PC_get (PC_tree_t tree , const char * index_fmt , ...);
165166
166167/** Looks for a node in a yaml document given a ypath index
167168 *
@@ -172,7 +173,7 @@ PC_tree_t PARACONF_EXPORT PC_get(PC_tree_t tree, const char *index_fmt, ...);
172173 * \param[in] va the printf-style values
173174 * \return the subtree corresponding to the ypath index
174175 */
175- PC_tree_t PARACONF_EXPORT PC_vget (PC_tree_t tree , const char * index_fmt , va_list va );
176+ PC_tree_t PARACONF_EXPORT PC_vget (PC_tree_t tree , const char * index_fmt , va_list va );
176177
177178/** Returns the length of a node, for a sequence, the number of nodes, for a mapping, the number of pairs, for a scalar, the string length
178179 *
@@ -182,7 +183,7 @@ PC_tree_t PARACONF_EXPORT PC_vget(PC_tree_t tree, const char *index_fmt, va_list
182183 * \param[out] value the length
183184 * \return the status of the execution
184185 */
185- PC_status_t PARACONF_EXPORT PC_len (PC_tree_t tree , int * value );
186+ PC_status_t PARACONF_EXPORT PC_len (PC_tree_t tree , int * value );
186187
187188/** Returns the int value of a scalar node
188189 *
@@ -192,7 +193,7 @@ PC_status_t PARACONF_EXPORT PC_len(PC_tree_t tree, int *value);
192193 * \param[out] value the int value of the scalar node
193194 * \return the status of the execution
194195 */
195- PC_status_t PARACONF_EXPORT PC_int (PC_tree_t tree , long * value );
196+ PC_status_t PARACONF_EXPORT PC_int (PC_tree_t tree , long * value );
196197
197198/** Returns the floating point value of a scalar node
198199 *
@@ -202,7 +203,7 @@ PC_status_t PARACONF_EXPORT PC_int(PC_tree_t tree, long *value);
202203 * \param[out] value the floating point value of the scalar node
203204 * \return the status of the execution
204205 */
205- PC_status_t PARACONF_EXPORT PC_double (PC_tree_t tree , double * value );
206+ PC_status_t PARACONF_EXPORT PC_double (PC_tree_t tree , double * value );
206207
207208/** Returns the string content of a scalar node
208209 *
@@ -212,7 +213,7 @@ PC_status_t PARACONF_EXPORT PC_double(PC_tree_t tree, double *value);
212213 * \param[out] value the content of the scalar node as a newly allocated string that must be deallocated using free
213214 * \return the status of the execution
214215 */
215- PC_status_t PARACONF_EXPORT PC_string (PC_tree_t tree , char * * value );
216+ PC_status_t PARACONF_EXPORT PC_string (PC_tree_t tree , char * * value );
216217
217218/** Returns the boolean value of a scalar node
218219 *
@@ -222,7 +223,7 @@ PC_status_t PARACONF_EXPORT PC_string(PC_tree_t tree, char **value);
222223 * \param[out] value the logical value (false=0, true=1) of the scalar node
223224 * \return the status of the execution
224225 */
225- PC_status_t PARACONF_EXPORT PC_bool (PC_tree_t tree , int * value );
226+ PC_status_t PARACONF_EXPORT PC_bool (PC_tree_t tree , int * value );
226227
227228/** Destroy the tree.
228229 * All the trees referring to this tree will become unusable
0 commit comments