theConfig 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - cs - py - rb - jv - cc
Loading...
Searching...
No Matches
LcConfigC_lc.h
Go to the documentation of this file.
1
12/* LABEL-START */
13#pragma once
14
15#include "LibLcConfig_lc.h"
16/* LABEL-END */
17
18#include "LcConfigC_def_lc.h"
19#include "LcSettingC_def_lc.h"
20
22
23/* MARK_C ################################################################ */
24/* ### ### */
25/* ### C O N F I G - A P I ### */
26/* ### ### */
27/* ####################################################################### */
28
31
32// doc-key: LcConfigC,LcConfigC-TOR,sCc
33
40__parser__(constructor,lng-constr)
43 MK_TYP type __parser__(internal,default=NULL),
44 config_t *nat __parser__(internal,keep-original-type,default=NULL)
45) {
47 if (LcConfigC_TT == NULL) {
48 MkErrorSetC_1E("initialization failed, use 'LcConfig.Setup()' at startup");
49 return NULL;
50 }
51
52 if (type == NULL) type = LcConfigC_TT;
53 return (LC_CFG)MkObjCreate(type,nat,NULL);
54}
55
57__parser__(destructor)
60 LC_CFG const cfg
62
64// LcConfigC_TOR_C_API
65
66// ======================================================================================================
67
68// \brief \b addon - check if \arg{cfg} is \null …
69// mk_inline bool LcConfigIsNullI ( LC_CFG const cfg ) {
70// return cfg->nat == NULL;
71// }
72
73// \brief \b addon - check if \arg{cfg} is \null …
74// __parser__(inline=LcConfigIsNullI)
75// LC_EXTERN MK_BOOL MK_DECL LcConfigIsNull(LC_CFG cfg);
76
79__parser__(internal,no-alias,overload-c-no,class=LcConfigC)
82);
83
86__parser__(internal,no-alias,class=LcConfigC)
89);
90
97// [LcConfigSetIncludeFunc_RT]
98__parser__(callback-name=ConfigInclude, callback-null)
101 LC_CFG const cfg,
102 LcConfigIncludeCallF fConfigIncludeCall __parser__(callback-call) ,
103 LC_CBP fConfigIncludeData __parser__(callback-data) ,
104 LcConfigIncludeFreeF fConfigIncludeFree __parser__(callback-free)
106// [LcConfigSetIncludeFunc_RT]
107
114 LC_CFG const cfg
115) {
116 return cfg ? cfg->fConfigIncludeData : NULL;
117}
118
134__parser__( callback-name=SettingDelete, callback-null)
137 LC_CFG const cfg,
138 LcSettingDeleteCallF fSettingDeleteCall __parser__(callback-call),
139 LC_CBP fSettingDeleteData __parser__(callback-data),
140 LcSettingDeleteFreeF fSettingDeleteFree __parser__(callback-free)
142
151__parser__(hide)
154 LC_CFG const cfg
155) {
156 return cfg ? cfg->fSettingDeleteData : NULL;
157}
158
167__parser__(no-alias)
170 LC_CFGN const cfg,
171 MK_STRN *val_out
173
183__parser__(const,flags=new)
186 LC_CFGN const cfg ,
188 MK_DBG const debug __parser__(default=0),
189 MK_STRN const callfunc __parser__(default=F#FUNC),
190 MK_I32 const lvl __parser__(default=0)
192
193
194// =========================================================================
195// BEGIN-LcConfigC-fupu - created by 'c_Native.tcl -i NHI1_HOME/theConfig/c/gen/c_lcconfig.meta' - DO NOT change
196
197// -> no data
198
199// END-LcConfigC-fupu - created by 'c_Native.tcl -i NHI1_HOME/theConfig/c/gen/c_lcconfig.meta' - DO NOT change
200
201// =========================================================================
202// BEGIN-LcConfigC-inline - created by 'c_Native.tcl -i NHI1_HOME/theConfig/c/gen/c_lcconfig.meta' - DO NOT change
203
204#ifndef PARSE_C_HEADER_TO_META
205
206 // doc-key: LcConfigC,LcConfigC-Error,om_
207
210 LC_INSTANCE_HDL(config);
211 return (enum LcErrorTypeE)config_error_type(config->nat);
212 }
213#endif
214
215#ifndef PARSE_C_HEADER_TO_META
216
217 // doc-key: LcConfigC,LcConfigC-Get,om_
218
224
230
233 LC_INSTANCE_HDL(config);
234 MK_STRN __retVal__L = config_get_include_dir(config->nat);
235 return __retVal__L;
236 }
237
240 LC_INSTANCE_HDL(config);
241 return (MK_BOOL)config_get_option(config->nat, option);
242 }
243
249
252 LC_INSTANCE_HDL(config);
253 return (MK_I16)config_get_tab_width(config->nat);
254 }
255#endif
256
257#ifndef PARSE_C_HEADER_TO_META
258
259 // doc-key: LcConfigC,LcConfigC-Lookup,oc_
260
263 LC_INSTANCE_HDL(config);
264 return LcSettingC_ObjNew(config_lookup(config->nat, path));
265 }
266
267 // doc-key: LcConfigC,LcConfigC-Lookup,omo
268
270 mk_inline enum MkErrorE LcConfigLookupBool (LC_CFGN config, MK_STRN path, MK_BOOL *value_out) {
271 LC_INSTANCE_HDL(config);
272 MK_I32 value_out_val = 0;
273 enum LcErrorE errVal = (enum LcErrorE)config_lookup_bool(config->nat, path, &value_out_val);
274 *value_out = (MK_BOOL)(value_out_val);
275 LcErrorE_Check(config, errVal);
276 return MK_OK;
277 error:
278 return MK_ERROR;
279 }
280
282 mk_inline enum MkErrorE LcConfigLookupFloat (LC_CFGN config, MK_STRN path, MK_DBL *value_out) {
283 LC_INSTANCE_HDL(config);
284 enum LcErrorE errVal = (enum LcErrorE)config_lookup_float(config->nat, path, value_out);
285 LcErrorE_Check(config, errVal);
286 return MK_OK;
287 error:
288 return MK_ERROR;
289 }
290
292 mk_inline enum MkErrorE LcConfigLookupInt (LC_CFGN config, MK_STRN path, MK_I32 *value_out) {
293 LC_INSTANCE_HDL(config);
294 enum LcErrorE errVal = (enum LcErrorE)config_lookup_int(config->nat, path, value_out);
295 LcErrorE_Check(config, errVal);
296 return MK_OK;
297 error:
298 return MK_ERROR;
299 }
300
302 mk_inline enum MkErrorE LcConfigLookupInt64 (LC_CFGN config, MK_STRN path, MK_I64 *value_out) {
303 LC_INSTANCE_HDL(config);
304 enum LcErrorE errVal = (enum LcErrorE)config_lookup_int64(config->nat, path, value_out);
305 LcErrorE_Check(config, errVal);
306 return MK_OK;
307 error:
308 return MK_ERROR;
309 }
310
313 LC_INSTANCE_HDL(config);
314 enum LcErrorE errVal = (enum LcErrorE)config_lookup_string(config->nat, path, value_out);
315 LcErrorE_Check(config, errVal);
316 return MK_OK;
317 error:
318 return MK_ERROR;
319 }
320#endif
321
322#ifndef PARSE_C_HEADER_TO_META
323
324 // doc-key: LcConfigC,LcConfigC-Misc,oc_
325
331
332 // doc-key: LcConfigC,LcConfigC-Misc,om_
333
336 LC_INSTANCE_HDL(config);
337 config_clear(config->nat);
338 }
339
342 LC_INSTANCE_HDL(config);
343 enum LcErrorE errVal = (enum LcErrorE)config_read_file(config->nat, filename);
344 LcErrorE_Check(config, errVal);
345 return MK_OK;
346 error:
347 return MK_ERROR;
348 }
349
352 LC_INSTANCE_HDL(config);
353 enum LcErrorE errVal = (enum LcErrorE)config_read_string(config->nat, str);
354 LcErrorE_Check(config, errVal);
355 return MK_OK;
356 error:
357 return MK_ERROR;
358 }
359
362 LC_INSTANCE_HDL(config);
363 enum LcErrorE errVal = (enum LcErrorE)config_write_file(config->nat, filename);
364 LcErrorE_Check(config, errVal);
365 return MK_OK;
366 error:
367 return MK_ERROR;
368 }
369#endif
370
371#ifndef PARSE_C_HEADER_TO_META
372
373 // doc-key: LcConfigC,LcConfigC-Set,om_
374
377 LC_INSTANCE_HDL(config);
378 config_set_default_format(config->nat, format);
379 }
380
383 LC_INSTANCE_HDL(config);
384 config_set_float_precision(config->nat, (MK_U16)digits);
385 }
386
388 mk_inline void LcConfigSetIncludeDir (LC_CFG config, MK_STRN include_dir) {
389 LC_INSTANCE_HDL(config);
390 config_set_include_dir(config->nat, include_dir);
391 }
392
398
400 mk_inline void LcConfigSetOption (LC_CFG config, enum LcConfigOptionsEF option, MK_BOOL flag) {
401 LC_INSTANCE_HDL(config);
402 config_set_option(config->nat, option, flag);
403 }
404
407 LC_INSTANCE_HDL(config);
408 config_set_options(config->nat, options);
409 }
410
413 LC_INSTANCE_HDL(config);
414 config_set_tab_width(config->nat, (MK_U16)width);
415 }
416#endif
417
418// END-LcConfigC-inline - created by 'c_Native.tcl -i NHI1_HOME/theConfig/c/gen/c_lcconfig.meta' - DO NOT change
419
LcConfigC_def_lc.h - 16 Nov 2024 - aotto1968.
LcSettingC_def_lc.h - 16 Nov 2024 - aotto1968.
LibLcConfig_lc.h - 16 Nov 2024 - aotto1968.
#define BEGIN_LC_C_DECLS
#define END_LC_C_DECLS
MK_PTRB * LC_CBP
void(* LcConfigIncludeFreeF)(LcConfigIncludeFreeF_ARGS)
enum MkErrorE(* LcSettingDeleteCallF)(LcSettingDeleteCallF_ARGS)
enum MkErrorE(* LcConfigIncludeCallF)(LcConfigIncludeCallF_ARGS)
void(* LcSettingDeleteFreeF)(LcSettingDeleteFreeF_ARGS)
#define LcConfigIncludeFreeF_ARGS
#define LcConfigIncludeCallF_ARGS
__thread MK_TYP LcConfigC_TT
class as MkSuperTypeS-class-type …
static enum LcErrorTypeE LcConfigErrorType(LC_CFGN config)
This function, which is implemented as a macro, returns the type of error that occurred during the la...
static enum LcConfigFormatE LcConfigGetDefaultFormat(LC_CFGN config)
These functions, which are implemented as macros, get and set the default external format for setting...
static MK_I16 LcConfigGetTabWidth(LC_CFGN config)
These functions, which are implemented as macros, get and set the tab width for the configuration con...
static MK_BOOL LcConfigGetOption(LC_CFGN config, enum LcConfigOptionsEF option)
Since v1.7 These functions get and set the given option of the configuration config …
static MK_I16 LcConfigGetFloatPrecision(LC_CFGN config)
Since v1.6 These functions get and set the number of decimal digits to output after the radix charact...
static MK_PTR LcConfigGetIncludeFunc(LC_CFG const cfg)
return the callback-name for the include-config-file …
static MK_PTR LcConfigGetSettingDeleteFunc(LC_CFG const cfg)
get the __parser__(callback-name) for setting-delete …
static enum LcConfigOptionsEF LcConfigGetOptions(LC_CFGN config)
These functions get and set the options for the configuration config …
static MK_STRN LcConfigGetIncludeDir(LC_CFGN config)
config_set_include_dir specifies the include directory, include_dir, relative to which the files spec...
static enum MkErrorE LcConfigLookupFloat(LC_CFGN config, MK_STRN path, MK_DBL *value_out)
These functions look up the value of the setting in the configuration config specified by the path pa...
static enum MkErrorE LcConfigLookupBool(LC_CFGN config, MK_STRN path, MK_BOOL *value_out)
These functions look up the value of the setting in the configuration config specified by the path pa...
static enum MkErrorE LcConfigLookupString(LC_CFGN config, MK_STRN path, MK_STRN *value_out)
These functions look up the value of the setting in the configuration config specified by the path pa...
static enum MkErrorE LcConfigLookupInt(LC_CFGN config, MK_STRN path, MK_I32 *value_out)
These functions look up the value of the setting in the configuration config specified by the path pa...
static enum MkErrorE LcConfigLookupInt64(LC_CFGN config, MK_STRN path, MK_I64 *value_out)
These functions look up the value of the setting in the configuration config specified by the path pa...
static LC_CFS LcConfigLookup(LC_CFGN config, MK_STRN path)
This function locates the setting in the configuration config specified by the path path …
static enum MkErrorE LcConfigWriteFile(LC_CFG config, MK_STRN filename)
This function writes the configuration config to the file named filename …
static LC_CFS LcConfigRootSetting(LC_CFGN config)
This function, which is implemented as a macro, returns the root setting for the configuration config...
enum MkErrorE LcConfigWriteString_RT(MK_RT mkrt, LC_CFGN const cfg, MK_STRN *val_out)
read the entire configuration cfg into the string val_out …
void LcConfigLog_RT(MK_RT mkrt, LC_CFGN const cfg, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
log the config …
static void LcConfigClear(LC_CFG config)
Since v1.7 This function clears the configuration config …
static enum MkErrorE LcConfigReadFile(LC_CFG config, MK_STRN filename)
This function reads and parses a configuration from the file named filename into the configuration ob...
static enum MkErrorE LcConfigReadString(LC_CFG config, MK_STRN str)
This function reads and parses a configuration from the string str into the configuration object conf...
enum MkErrorE LcConfigSetIncludeFunc_RT(MK_RT mkrt, LC_CFG const cfg, LcConfigIncludeCallF fConfigIncludeCall, LC_CBP fConfigIncludeData, LcConfigIncludeFreeF fConfigIncludeFree)
set the __parser__(callback-name) for the include-config-file …
static void LcConfigSetTabWidth(LC_CFG config, MK_I16 width)
These functions, which are implemented as macros, get and set the tab width for the configuration con...
static void LcConfigSetFloatPrecision(LC_CFG config, MK_I16 digits)
Since v1.6 These functions get and set the number of decimal digits to output after the radix charact...
enum MkErrorE LcConfigIncludeCall(LcConfigIncludeCallF_ARGS)
config-file include __parser__(callback-name) → call …
static void LcConfigSetOptions(LC_CFG config, enum LcConfigOptionsEF options)
These functions get and set the options for the configuration config …
enum MkErrorE LcConfigSetSettingDeleteFunc_RT(MK_RT mkrt, LC_CFG const cfg, LcSettingDeleteCallF fSettingDeleteCall, LC_CBP fSettingDeleteData, LcSettingDeleteFreeF fSettingDeleteFree)
set the callback-name for the setting-delete …
static void LcConfigSetOption(LC_CFG config, enum LcConfigOptionsEF option, MK_BOOL flag)
Since v1.7 These functions get and set the given option of the configuration config …
static void LcConfigSetIncludeDir(LC_CFG config, MK_STRN include_dir)
config_set_include_dir specifies the include directory, include_dir, relative to which the files spec...
static void LcConfigSetIncludeFuncHide(LC_CFG config, config_include_fn_t func)
Since v1.7 Specifies the include function func to use when processing include directives …
void LcConfigIncludeFree(LcConfigIncludeFreeF_ARGS)
config-file include __parser__(callback-name) → free …
static void LcConfigSetDefaultFormat(LC_CFG config, enum LcConfigFormatE format)
These functions, which are implemented as macros, get and set the default external format for setting...
void LcConfigDelete_RT(MK_RT mkrt, LC_CFG const cfg)
delete a LcConfigC instance …
static LC_CFG LcConfigCreate(MK_TYP type, config_t *nat)
create a LcConfigC instance …
#define LC_EXTERN
static library
LcErrorE
Signals an error and is used as the return value of a function …
Definition LcEnum_lc.h:191
LcConfigFormatE
set the format of a LcSettingC …
Definition LcEnum_lc.h:33
LcConfigOptionsEF
define the configuration-option of a LcConfigC …
Definition LcEnum_lc.h:137
LcErrorTypeE
error types
Definition LcEnum_lc.h:231
#define LcErrorE_Check(lc_hdl, PROC)
check on a liblcconfig error and convert into a liblcconfig error …
#define LC_INSTANCE_HDL(x)
static MK_ARTIFICIAL LC_CFS LcSettingC_ObjNew(config_setting_t *hdl)
return Programming-Language-Micro-Kernel (PLMK) instance from native hdl …
#define MkErrorSetC_1E(message)
#define MK_PARSER_fmtobj
#define MK_DECL
#define mk_inline
MkErrorE
MK_ERROR
MK_OK
#define __parser__(...)
MK_PTRB * MK_PTR
const MK_STRB * MK_STRN
signed long long MK_I64
bool MK_BOOL
unsigned short MK_U16
signed short int MK_I16
double MK_DBL
signed int MK_I32
int MK_DBG
#define MkObjCreate(...)
#define MK_ATTR_STATIC
#define MK_ATTR_RT_INSTANCE
#define MK_ATTR_INSTANCE
#define MK_PARSER_RT
#define MkRtSetup_NULL
LIBCONFIG_API int config_read_file(config_t *config, const char *filename)
LIBCONFIG_API void config_set_float_precision(config_t *config, unsigned short digits)
LIBCONFIG_API config_setting_t * config_lookup(const config_t *config, const char *path)
LIBCONFIG_API void config_set_include_dir(config_t *config, const char *include_dir)
LIBCONFIG_API unsigned short config_get_tab_width(const config_t *config)
LIBCONFIG_API void config_set_include_func(config_t *config, config_include_fn_t func)
LIBCONFIG_API void config_set_tab_width(config_t *config, unsigned short width)
LIBCONFIG_API void config_set_options(config_t *config, int options)
LIBCONFIG_API int config_lookup_string(const config_t *config, const char *path, const char **value)
const char **(* config_include_fn_t)(struct config_t *, const char *, const char *, const char **)
#define config_set_default_format(C, F)
LIBCONFIG_API unsigned short config_get_float_precision(const config_t *config)
LIBCONFIG_API int config_lookup_bool(const config_t *config, const char *path, int *value)
LIBCONFIG_API int config_lookup_float(const config_t *config, const char *path, double *value)
#define config_error_type(C)
LIBCONFIG_API int config_lookup_int(const config_t *config, const char *path, int *value)
LIBCONFIG_API int config_get_options(const config_t *config)
#define config_root_setting(C)
LIBCONFIG_API void config_set_option(config_t *config, int option, int flag)
LIBCONFIG_API int config_write_file(config_t *config, const char *filename)
LIBCONFIG_API int config_get_option(const config_t *config, int option)
LIBCONFIG_API int config_lookup_int64(const config_t *config, const char *path, long long *value)
#define config_get_include_dir(C)
LIBCONFIG_API void config_clear(config_t *config)
LIBCONFIG_API int config_read_string(config_t *config, const char *str)
#define config_get_default_format(C)
Struct to represent the data from the LcConfigC …
config_t * nat
internal - link between LcConfigS and native library
Struct to represent the data from the LcSettingC …