14 #include <gwenhywfar/misc.h>
15 #include <gwenhywfar/debug.h>
27 if (strcasecmp(p_s,
"int")==0)
29 else if (strcasecmp(p_s,
"bool")==0)
31 else if (strcasecmp(p_s,
"float")==0)
33 else if (strcasecmp(p_s,
"string")==0)
41 if (strcasecmp(p_s,
"simple")==0)
43 else if (strcasecmp(p_s,
"choice")==0)
79 p_struct->_refCount=1;
87 p_struct->shortDescription=
NULL;
88 p_struct->longDescription=
NULL;
89 p_struct->currentValue=
NULL;
90 p_struct->defaultValue=
NULL;
91 p_struct->choices=
NULL;
92 p_struct->internalIntValue=0;
93 p_struct->internalFloatValue=0;
94 p_struct->runtimeFlags=0;
102 assert(p_struct->_refCount);
103 if (p_struct->_refCount==1) {
107 free(p_struct->name);
108 free(p_struct->shortDescription);
109 free(p_struct->longDescription);
110 free(p_struct->currentValue);
111 free(p_struct->defaultValue);
113 p_struct->_refCount=0;
117 p_struct->_refCount--;
123 assert(p_struct->_refCount);
124 p_struct->_refCount++;
133 if (p_struct->name) {
134 free(p_struct->name);
138 p_struct->name=strdup(p_src->name);
142 p_struct->flags=p_src->flags;
145 p_struct->type=p_src->type;
148 p_struct->dataType=p_src->dataType;
151 if (p_struct->shortDescription) {
152 free(p_struct->shortDescription);
153 p_struct->shortDescription=
NULL;
155 if (p_src->shortDescription) {
156 p_struct->shortDescription=strdup(p_src->shortDescription);
160 if (p_struct->longDescription) {
161 free(p_struct->longDescription);
162 p_struct->longDescription=
NULL;
164 if (p_src->longDescription) {
165 p_struct->longDescription=strdup(p_src->longDescription);
169 if (p_struct->currentValue) {
170 free(p_struct->currentValue);
171 p_struct->currentValue=
NULL;
173 if (p_src->currentValue) {
174 p_struct->currentValue=strdup(p_src->currentValue);
178 if (p_struct->defaultValue) {
179 free(p_struct->defaultValue);
180 p_struct->defaultValue=
NULL;
182 if (p_src->defaultValue) {
183 p_struct->defaultValue=strdup(p_src->defaultValue);
187 if (p_struct->choices) {
189 p_struct->choices=
NULL;
191 if (p_src->choices) {
196 p_struct->internalIntValue=p_src->internalIntValue;
199 p_struct->internalFloatValue=p_src->internalFloatValue;
202 p_struct->runtimeFlags=p_src->runtimeFlags;
211 if (p_struct->name) {
212 free(p_struct->name);
216 p_struct->name=strdup(p_src->name);
220 p_struct->flags=p_src->flags;
223 p_struct->type=p_src->type;
226 p_struct->dataType=p_src->dataType;
229 if (p_struct->shortDescription) {
230 free(p_struct->shortDescription);
231 p_struct->shortDescription=
NULL;
233 if (p_src->shortDescription) {
234 p_struct->shortDescription=strdup(p_src->shortDescription);
238 if (p_struct->longDescription) {
239 free(p_struct->longDescription);
240 p_struct->longDescription=
NULL;
242 if (p_src->longDescription) {
243 p_struct->longDescription=strdup(p_src->longDescription);
247 if (p_struct->currentValue) {
248 free(p_struct->currentValue);
249 p_struct->currentValue=
NULL;
251 if (p_src->currentValue) {
252 p_struct->currentValue=strdup(p_src->currentValue);
256 if (p_struct->defaultValue) {
257 free(p_struct->defaultValue);
258 p_struct->defaultValue=
NULL;
260 if (p_src->defaultValue) {
261 p_struct->defaultValue=strdup(p_src->defaultValue);
265 if (p_struct->choices) {
267 p_struct->choices=
NULL;
269 if (p_src->choices) {
274 p_struct->internalIntValue=p_src->internalIntValue;
277 p_struct->internalFloatValue=p_src->internalFloatValue;
280 p_struct->runtimeFlags=p_src->runtimeFlags;
287 return p_struct->name;
292 return p_struct->flags;
297 return p_struct->type;
302 return p_struct->dataType;
307 return p_struct->shortDescription;
312 return p_struct->longDescription;
317 return p_struct->currentValue;
322 return p_struct->defaultValue;
327 return p_struct->choices;
332 return p_struct->internalIntValue;
337 return p_struct->internalFloatValue;
342 return p_struct->runtimeFlags;
347 if (p_struct->name) {
348 free(p_struct->name);
351 p_struct->name=strdup(p_src);
360 p_struct->flags=p_src;
365 p_struct->flags|=p_src;
370 p_struct->flags&=~p_src;
375 p_struct->type=p_src;
380 p_struct->dataType=p_src;
385 if (p_struct->shortDescription) {
386 free(p_struct->shortDescription);
389 p_struct->shortDescription=strdup(p_src);
392 p_struct->shortDescription=
NULL;
398 if (p_struct->longDescription) {
399 free(p_struct->longDescription);
402 p_struct->longDescription=strdup(p_src);
405 p_struct->longDescription=
NULL;
411 if (p_struct->currentValue) {
412 free(p_struct->currentValue);
415 p_struct->currentValue=strdup(p_src);
418 p_struct->currentValue=
NULL;
424 if (p_struct->defaultValue) {
425 free(p_struct->defaultValue);
428 p_struct->defaultValue=strdup(p_src);
431 p_struct->defaultValue=
NULL;
437 if (p_struct->choices) {
440 p_struct->choices=p_src;
445 p_struct->internalIntValue=p_src;
450 p_struct->internalFloatValue=p_src;
455 p_struct->runtimeFlags=p_src;
460 p_struct->runtimeFlags|=p_src;
465 p_struct->runtimeFlags&=~p_src;
490 if (p_struct->name) {
491 free(p_struct->name);
494 if (p_struct->name==
NULL) {
508 if (p_struct->shortDescription) {
509 free(p_struct->shortDescription);
511 {
const char *s; s=
GWEN_DB_GetCharValue(p_db,
"shortDescription", 0,
NULL);
if (s) p_struct->shortDescription=strdup(s); }
512 if (p_struct->shortDescription==
NULL) {
513 p_struct->shortDescription=
NULL;
517 if (p_struct->longDescription) {
518 free(p_struct->longDescription);
520 {
const char *s; s=
GWEN_DB_GetCharValue(p_db,
"longDescription", 0,
NULL);
if (s) p_struct->longDescription=strdup(s); }
521 if (p_struct->longDescription==
NULL) {
522 p_struct->longDescription=
NULL;
526 if (p_struct->currentValue) {
527 free(p_struct->currentValue);
530 if (p_struct->currentValue==
NULL) {
531 p_struct->currentValue=
NULL;
535 if (p_struct->defaultValue) {
536 free(p_struct->defaultValue);
539 if (p_struct->defaultValue==
NULL) {
540 p_struct->defaultValue=
NULL;
544 if (p_struct->choices) {
548 if (p_struct->choices==
NULL) {
549 p_struct->choices=
NULL;
554 p_struct->internalIntValue=0;
558 p_struct->internalFloatValue=0;
562 p_struct->runtimeFlags=0;
662 if (p_struct->name) {
663 free(p_struct->name);
666 if (p_struct->name==
NULL) {
680 if (p_struct->shortDescription) {
681 free(p_struct->shortDescription);
684 if (p_struct->shortDescription==
NULL) {
685 p_struct->shortDescription=
NULL;
689 if (p_struct->longDescription) {
690 free(p_struct->longDescription);
693 if (p_struct->longDescription==
NULL) {
694 p_struct->longDescription=
NULL;
698 if (p_struct->currentValue) {
699 free(p_struct->currentValue);
702 if (p_struct->currentValue==
NULL) {
703 p_struct->currentValue=
NULL;
707 if (p_struct->defaultValue) {
708 free(p_struct->defaultValue);
711 if (p_struct->defaultValue==
NULL) {
712 p_struct->defaultValue=
NULL;
716 if (p_struct->choices) {
720 if (p_struct->choices==
NULL) {
721 p_struct->choices=
NULL;
726 p_struct->internalIntValue=0;
730 p_struct->internalFloatValue=0;
734 p_struct->runtimeFlags=0;
794 if (p_struct->name && p_cmp) p_rv=strcasecmp(p_cmp, p_struct->name);
795 else if (p_cmp) p_rv=1;
796 else if (p_struct->name) p_rv=-1;
809 p_struct = GWEN_Param_Tree_GetFirst(p_tree);
813 if (p_struct->name && p_cmp) p_rv=strcasecmp(p_cmp, p_struct->name);
814 else if (p_cmp) p_rv=1;
815 else if (p_struct->name) p_rv=-1;
819 p_struct = GWEN_Param_Tree_GetBelow(p_struct);
GWEN_PARAM_DATATYPE GWEN_Param_DataType_fromString(const char *p_s)
GWEN_PARAM * GWEN_Param_List_First(const GWEN_PARAM_LIST *l)
int GWEN_StringList2_toDb(GWEN_STRINGLIST2 *sl2, GWEN_DB_NODE *db, const char *name)
GWEN_PARAM * GWEN_Param_dup(const GWEN_PARAM *p_src)
#define GWEN_DB_FLAGS_OVERWRITE_VARS
struct GWEN_DB_NODE GWEN_DB_NODE
void GWEN_Param_SubFlags(GWEN_PARAM *p_struct, uint32_t p_src)
GWEN_PARAM_DATATYPE GWEN_Param_GetDataType(const GWEN_PARAM *p_struct)
const char * GWEN_Param_GetDefaultValue(const GWEN_PARAM *p_struct)
const char * GWEN_Param_Type_toString(GWEN_PARAM_TYPE p_i)
GWEN_STRINGLIST2 * GWEN_StringList2_dup(GWEN_STRINGLIST2 *sl2)
GWEN_PARAM_TYPE GWEN_Param_GetType(const GWEN_PARAM *p_struct)
#define GWEN_FREE_OBJECT(varname)
void GWEN_Param_SetDataType(GWEN_PARAM *p_struct, GWEN_PARAM_DATATYPE p_src)
void GWEN_Param_SetType(GWEN_PARAM *p_struct, GWEN_PARAM_TYPE p_src)
void GWEN_Param_toXml(const GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
struct GWEN_PARAM GWEN_PARAM
int GWEN_StringList2_toXml(GWEN_STRINGLIST2 *sl2, GWEN_XMLNODE *node)
double GWEN_Param_GetInternalFloatValue(const GWEN_PARAM *p_struct)
void GWEN_Param_AddFlags(GWEN_PARAM *p_struct, uint32_t p_src)
void GWEN_XMLNode_SetCharValue(GWEN_XMLNODE *n, const char *name, const char *value)
const char * GWEN_Param_DataType_toString(GWEN_PARAM_DATATYPE p_i)
GWEN_STRINGLIST2 * GWEN_StringList2_fromXml(GWEN_XMLNODE *node, GWEN_STRINGLIST2_INSERTMODE m)
GWEN_PARAM * GWEN_Param_fromXml(GWEN_XMLNODE *p_db)
GWEN_XMLNODE * GWEN_XMLNode_new(GWEN_XMLNODE_TYPE t, const char *data)
int GWEN_XMLNode_GetIntValue(const GWEN_XMLNODE *n, const char *name, int defValue)
void GWEN_Param_AddRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
GWEN_XMLNODE * GWEN_XMLNode_FindFirstTag(const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue)
void GWEN_Param_free(GWEN_PARAM *p_struct)
GWEN_PARAM * GWEN_Param_Tree_GetByName(const GWEN_PARAM_TREE *p_tree, const char *p_cmp)
#define GWEN_NEW_OBJECT(typ, varname)
void GWEN_Param_SubRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
const char * GWEN_XMLNode_GetCharValue(const GWEN_XMLNODE *n, const char *name, const char *defValue)
GWEN_STRINGLIST2 * GWEN_Param_GetChoices(const GWEN_PARAM *p_struct)
GWEN_PARAM_LIST * GWEN_Param_List_dup(const GWEN_PARAM_LIST *p_src)
void GWEN_StringList2_free(GWEN_STRINGLIST2 *sl2)
#define GWEN_TREE_FINI(t, element)
GWEN_PARAM * GWEN_Param_new(void)
void GWEN_Param_SetLongDescription(GWEN_PARAM *p_struct, const char *p_src)
void GWEN_Param_SetInternalFloatValue(GWEN_PARAM *p_struct, double p_src)
GWEN_PARAM * GWEN_Param_List_Next(const GWEN_PARAM *element)
GWEN_PARAM * GWEN_Param_fromDb(GWEN_DB_NODE *p_db)
void GWEN_Param_ReadXml(GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
uint32_t GWEN_Param_GetFlags(const GWEN_PARAM *p_struct)
int GWEN_DB_DeleteVar(GWEN_DB_NODE *n, const char *path)
GWEN_PARAM_LIST * GWEN_Param_List_new()
GWEN_LIST2_FUNCTIONS(TYPEMAKER2_TYPE, Typemaker2_Type)
void GWEN_Param_Attach(GWEN_PARAM *p_struct)
int GWEN_Param_GetInternalIntValue(const GWEN_PARAM *p_struct)
const char * GWEN_Param_GetName(const GWEN_PARAM *p_struct)
void GWEN_Param_SetCurrentValue(GWEN_PARAM *p_struct, const char *p_src)
void GWEN_Param_SetDefaultValue(GWEN_PARAM *p_struct, const char *p_src)
int GWEN_Param_toDb(const GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
struct GWEN_STRINGLIST2 GWEN_STRINGLIST2
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
GWEN_PARAM_TYPE GWEN_Param_Type_fromString(const char *p_s)
#define DBG_INFO(dbg_logger, format, args...)
#define GWEN_TREE_INIT(t, element)
#define GWEN_LIST_INIT(t, element)
const char * GWEN_Param_GetCurrentValue(const GWEN_PARAM *p_struct)
GWEN_PARAM * GWEN_Param_copy(GWEN_PARAM *p_struct, const GWEN_PARAM *p_src)
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
void GWEN_Param_SetInternalIntValue(GWEN_PARAM *p_struct, int p_src)
void GWEN_Param_SetFlags(GWEN_PARAM *p_struct, uint32_t p_src)
void GWEN_Param_SetChoices(GWEN_PARAM *p_struct, GWEN_STRINGLIST2 *p_src)
const char * GWEN_Param_GetLongDescription(const GWEN_PARAM *p_struct)
void GWEN_Param_SetShortDescription(GWEN_PARAM *p_struct, const char *p_src)
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
#define GWEN_LIST_FUNCTIONS(t, pr)
void GWEN_Param_List_Add(GWEN_PARAM *element, GWEN_PARAM_LIST *list)
const char * GWEN_Param_GetShortDescription(const GWEN_PARAM *p_struct)
uint32_t GWEN_Param_GetRuntimeFlags(const GWEN_PARAM *p_struct)
int GWEN_Param_WriteDb(const GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
void GWEN_Param_SetName(GWEN_PARAM *p_struct, const char *p_src)
void GWEN_Param_ReadDb(GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
#define GWEN_LIST_FINI(t, element)
struct GWEN__XMLNODE GWEN_XMLNODE
GWEN_PARAM * GWEN_Param_List_GetByName(const GWEN_PARAM_LIST *p_list, const char *p_cmp)
void GWEN_Param_WriteXml(const GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
void GWEN_Param_SetRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
GWEN_STRINGLIST2 * GWEN_StringList2_fromDb(GWEN_DB_NODE *db, const char *name, GWEN_STRINGLIST2_INSERTMODE m)
#define GWEN_TREE_FUNCTIONS(t, pr)
void GWEN_XMLNode_AddChild(GWEN_XMLNODE *n, GWEN_XMLNODE *child)
void GWEN_XMLNode_SetIntValue(GWEN_XMLNODE *n, const char *name, int value)