theConfig 10.0
Loading...
Searching...
No Matches
LcSettingC_Misc_C_API

LcSettingC - various functions to perform misc operations … More...

+ Collaboration diagram for LcSettingC_Misc_C_API:

Functions

void liblcconfig::LcSettingLog_RT (MK_RT mkrt, LC_CFSN const setting, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)
 log the setting
 
static LC_CFS liblcconfig::LcSettingParent (LC_CFSN setting)
 This function returns the parent setting of the given setting, or NULL if setting is the root setting …
 
static MK_I32 liblcconfig::LcSettingIndex (LC_CFSN setting)
 This function returns the index of the given setting within its parent setting …
 
static MK_I32 liblcconfig::LcSettingLength (LC_CFSN setting)
 This function returns the number of settings in a group, or the number of elements in a list or array …
 
static MK_STRN liblcconfig::LcSettingName (LC_CFSN setting)
 This function returns the name of the given setting, or NULL if the setting has no name …
 
static enum MkErrorE liblcconfig::LcSettingRemove (LC_CFS parent, MK_STRN name)
 This function removes and destroys the setting named name from the parent setting parent, which must be a group …
 
static enum MkErrorE liblcconfig::LcSettingRemoveElem (LC_CFS parent, MK_I32 idx)
 This function removes the child setting at the given index index from the setting parent, which must be a group, list, or array …
 
static MK_STRN liblcconfig::LcSettingSourceFile (LC_CFSN setting)
 This function returns the name of the file from which the setting setting was read, or NULL if the setting was not read from a file …
 
static MK_I32 liblcconfig::LcSettingSourceLine (LC_CFSN setting)
 This function returns the line number of the configuration file or stream at which the setting setting was read, or 0 if no line number is available …
 
static enum LcConfigTypeE liblcconfig::LcSettingType (LC_CFSN setting)
 This function returns the type of the given setting
 
static LC_CFS liblcconfig::LcSettingAddIfNotExists (LC_CFS setting, MK_STRN name, enum LcConfigTypeE cfgtype)
 addon - add name with type only if not exists in the setting
 
static bool liblcconfig::LcSettingExists (const LC_CFS setting, MK_STRN name)
 addon - return true if name exists in the setting otherwise false
 

LcSettingC - LcSettingC_Misc_C_API - overload

#define LcSettingLog_NULL(...)
 
#define LcSettingLog(...)
 
#define LcSettingLog_4(setting, fmtobj, debug, callfunc)
 
#define LcSettingLog_3(setting, fmtobj, debug)
 
#define LcSettingLog_2(setting, fmtobj)
 
#define LcSettingLog_1(setting)
 
#define LcSettingRemove_E(...)
 
#define LcSettingRemove_C(...)
 
#define LcSettingRemoveElem_E(...)
 
#define LcSettingRemoveElem_C(...)
 

Detailed Description

LcSettingC - various functions to perform misc operations …

Macro Definition Documentation

◆ LcSettingLog

#define LcSettingLog ( ...)
Value:
LcSettingLog_RT(MK_RT_CALL __VA_ARGS__)
#define MK_RT_CALL

Definition at line 211 of file config_overload_lc.h.

◆ LcSettingLog_1

#define LcSettingLog_1 ( setting)
Value:
LcSettingLog(setting,NULL,0,__func__,0)
#define LcSettingLog(...)

Definition at line 215 of file config_overload_lc.h.

◆ LcSettingLog_2

#define LcSettingLog_2 ( setting,
fmtobj )
Value:
LcSettingLog(setting,fmtobj,0,__func__,0)

Definition at line 214 of file config_overload_lc.h.

◆ LcSettingLog_3

#define LcSettingLog_3 ( setting,
fmtobj,
debug )
Value:
LcSettingLog(setting,fmtobj,debug,__func__,0)

Definition at line 213 of file config_overload_lc.h.

◆ LcSettingLog_4

#define LcSettingLog_4 ( setting,
fmtobj,
debug,
callfunc )
Value:
LcSettingLog(setting,fmtobj,debug,callfunc,0)

Definition at line 212 of file config_overload_lc.h.

◆ LcSettingLog_NULL

#define LcSettingLog_NULL ( ...)
Value:
LcSettingLog_RT(MK_RT_CALL_NULL __VA_ARGS__)
#define MK_RT_CALL_NULL

Definition at line 210 of file config_overload_lc.h.

◆ LcSettingRemove_C

#define LcSettingRemove_C ( ...)
Value:
if (MkErrorCheckI(LcSettingRemove(__VA_ARGS__)))

Definition at line 217 of file config_overload_lc.h.

◆ LcSettingRemove_E

#define LcSettingRemove_E ( ...)
Value:
MkErrorCheck(LcSettingRemove(__VA_ARGS__))

Definition at line 216 of file config_overload_lc.h.

◆ LcSettingRemoveElem_C

#define LcSettingRemoveElem_C ( ...)
Value:
if (MkErrorCheckI(LcSettingRemoveElem(__VA_ARGS__)))

Definition at line 219 of file config_overload_lc.h.

◆ LcSettingRemoveElem_E

#define LcSettingRemoveElem_E ( ...)
Value:
MkErrorCheck(LcSettingRemoveElem(__VA_ARGS__))

Definition at line 218 of file config_overload_lc.h.

Function Documentation

◆ LcSettingAddIfNotExists()

static LC_CFS liblcconfig::LcSettingAddIfNotExists ( LC_CFS setting,
MK_STRN name,
enum LcConfigTypeE cfgtype )
inlinestatic

addon - add name with type only if not exists in the setting

If parent is an array or list, the name parameter is ignored and may be NULL.

The function returns the new setting on success, or NULL if parent is not a group, array, or list; or if there is already a child setting of parent named name; or if type is invalid. If type is a scalar type, the new setting will have a default value of 0, 0.0, false, or NULL, as appropriate.

Definition at line 474 of file LcSettingC_lc.h.

478 {
479 config_setting_t* mbr = config_setting_get_member(setting->nat,name);
480 if (mbr == NULL) {
481 mbr = config_setting_add ( setting->nat, name, cfgtype );
482 }
483 return LcSettingC_ObjNew(mbr);
484}
LIBCONFIG_API config_setting_t * config_setting_get_member(const config_setting_t *setting, const char *name)
LIBCONFIG_API config_setting_t * config_setting_add(config_setting_t *parent, const char *name, int __type)
+ Here is the caller graph for this function:

◆ LcSettingExists()

static bool liblcconfig::LcSettingExists ( const LC_CFS setting,
MK_STRN name )
inlinestatic

addon - return true if name exists in the setting otherwise false

Same as LcSettingGetMember but only test on exists

Definition at line 499 of file LcSettingC_lc.h.

502 {
503 return config_setting_get_member(setting->nat,name) != NULL;
504}
+ Here is the caller graph for this function:

◆ LcSettingIndex()

static MK_I32 liblcconfig::LcSettingIndex ( LC_CFSN setting)
inlinestatic

This function returns the index of the given setting within its parent setting …

If setting is the root setting, this function returns -1.

Definition at line 293 of file LcSettingC_lc.h.

293 {
294 LC_INSTANCE_HDL(setting);
295 return config_setting_index(setting->nat);
296 }
#define LC_INSTANCE_HDL(x)
LIBCONFIG_API int config_setting_index(const config_setting_t *setting)
+ Here is the caller graph for this function:

◆ LcSettingLength()

static MK_I32 liblcconfig::LcSettingLength ( LC_CFSN setting)
inlinestatic

This function returns the number of settings in a group, or the number of elements in a list or array …

For other types of settings, it returns 0.

Definition at line 299 of file LcSettingC_lc.h.

299 {
300 LC_INSTANCE_HDL(setting);
301 return config_setting_length(setting->nat);
302 }
LIBCONFIG_API int config_setting_length(const config_setting_t *setting)
+ Here is the caller graph for this function:

◆ LcSettingLog_RT()

void liblcconfig::LcSettingLog_RT ( MK_RT mkrt,
LC_CFSN const setting,
MK_OBJN fmtobj,
MK_DBG const debug,
MK_STRN const callfunc,
MK_I32 const lvl )

log the setting

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]settingsame as config_setting_t
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling-function or the environment (default = name-of-function, MK_NULL = resolve-own-name)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)

◆ LcSettingName()

static MK_STRN liblcconfig::LcSettingName ( LC_CFSN setting)
inlinestatic

This function returns the name of the given setting, or NULL if the setting has no name …

Storage for the returned string is managed by the library and released automatically when the setting is destroyed; the string must not be freed by the caller.

Definition at line 305 of file LcSettingC_lc.h.

305 {
306 LC_INSTANCE_HDL(setting);
307 MK_STRN __retVal__L = config_setting_name(setting->nat);
308 return __retVal__L;
309 }
const MK_STRB * MK_STRN
#define config_setting_name(S)
+ Here is the caller graph for this function:

◆ LcSettingParent()

static LC_CFS liblcconfig::LcSettingParent ( LC_CFSN setting)
inlinestatic

This function returns the parent setting of the given setting, or NULL if setting is the root setting …

Definition at line 285 of file LcSettingC_lc.h.

285 {
286 LC_INSTANCE_HDL(setting);
287 return LcSettingC_ObjNew(config_setting_parent(setting->nat));
288 }
#define config_setting_parent(S)
+ Here is the caller graph for this function:

◆ LcSettingRemove()

static enum MkErrorE liblcconfig::LcSettingRemove ( LC_CFS parent,
MK_STRN name )
inlinestatic

This function removes and destroys the setting named name from the parent setting parent, which must be a group …

Any child settings of the setting are recursively destroyed as well.

The name parameter can also specify a setting path relative to the provided parent. (In that case, the setting will be looked up and removed.)

The function returns CONFIG_TRUE on success. If parent is not a group, or if it has no setting with the given name, it returns CONFIG_FALSE.

Definition at line 312 of file LcSettingC_lc.h.

312 {
313 LC_INSTANCE_HDL(parent);
314 enum LcErrorE errVal = (enum LcErrorE)config_setting_remove(parent->nat, name);
315 LcErrorE_Check(parent, errVal);
316 return MK_OK;
317 error:
318 return MK_ERROR;
319 }
LcErrorE
Signals an error and is used as the return value of a function …
Definition LcEnum_lc.h:188
#define LcErrorE_Check(lc_hdl, PROC)
check on a cclcconfig error and convert into a cclcconfig error …
LIBCONFIG_API int config_setting_remove(config_setting_t *parent, const char *name)
+ Here is the caller graph for this function:

◆ LcSettingRemoveElem()

static enum MkErrorE liblcconfig::LcSettingRemoveElem ( LC_CFS parent,
MK_I32 idx )
inlinestatic

This function removes the child setting at the given index index from the setting parent, which must be a group, list, or array …

Any child settings of the removed setting are recursively destroyed as well.

The function returns CONFIG_TRUE on success. If parent is not a group, list, or array, or if index is out of range, it returns CONFIG_FALSE.

Definition at line 322 of file LcSettingC_lc.h.

322 {
323 LC_INSTANCE_HDL(parent);
324 enum LcErrorE errVal = (enum LcErrorE)config_setting_remove_elem(parent->nat, (MK_U32)idx);
325 LcErrorE_Check(parent, errVal);
326 return MK_OK;
327 error:
328 return MK_ERROR;
329 }
LIBCONFIG_API int config_setting_remove_elem(config_setting_t *parent, unsigned int idx)
+ Here is the caller graph for this function:

◆ LcSettingSourceFile()

static MK_STRN liblcconfig::LcSettingSourceFile ( LC_CFSN setting)
inlinestatic

This function returns the name of the file from which the setting setting was read, or NULL if the setting was not read from a file …

This information is useful for reporting application-level errors. Storage for the returned string is managed by the library and released automatically when the configuration is destroyed; the string must not be freed by the caller.

Definition at line 332 of file LcSettingC_lc.h.

332 {
333 LC_INSTANCE_HDL(setting);
334 MK_STRN __retVal__L = config_setting_source_file(setting->nat);
335 return __retVal__L;
336 }
#define config_setting_source_file( S)
+ Here is the caller graph for this function:

◆ LcSettingSourceLine()

static MK_I32 liblcconfig::LcSettingSourceLine ( LC_CFSN setting)
inlinestatic

This function returns the line number of the configuration file or stream at which the setting setting was read, or 0 if no line number is available …

This information is useful for reporting application-level errors.

Definition at line 339 of file LcSettingC_lc.h.

339 {
340 LC_INSTANCE_HDL(setting);
341 return (MK_I32)config_setting_source_line(setting->nat);
342 }
#define config_setting_source_line( S)
+ Here is the caller graph for this function:

◆ LcSettingType()

static enum LcConfigTypeE liblcconfig::LcSettingType ( LC_CFSN setting)
inlinestatic

This function returns the type of the given setting

The return value is one of the constants CONFIG_TYPE_INT, CONFIG_TYPE_INT64, CONFIG_TYPE_FLOAT, CONFIG_TYPE_STRING, CONFIG_TYPE_BOOL, CONFIG_TYPE_ARRAY, CONFIG_TYPE_LIST, or CONFIG_TYPE_GROUP.

Definition at line 345 of file LcSettingC_lc.h.

345 {
346 LC_INSTANCE_HDL(setting);
347 return (enum LcConfigTypeE)config_setting_type(setting->nat);
348 }
#define config_setting_type(S)
+ Here is the caller graph for this function: