gwenhywfar 5.14.1
param.c
Go to the documentation of this file.
1/**********************************************************
2 * This file has been automatically created by "typemaker2"
3 * from the file "param.xml".
4 * Please do not edit this file, all changes will be lost.
5 * Better edit the mentioned source file instead.
6 **********************************************************/
7
8#ifdef HAVE_CONFIG_H
9# include <config.h>
10#endif
11
12#include "./param_p.h"
13
14#include <gwenhywfar/misc.h>
15#include <gwenhywfar/debug.h>
16
17/* code headers */
18
19/* macro functions */
23
24
26{
27 if (p_s && *p_s) {
28 if (strcasecmp(p_s, "int")==0)
30 else if (strcasecmp(p_s, "bool")==0)
32 else if (strcasecmp(p_s, "float")==0)
34 else if (strcasecmp(p_s, "string")==0)
36 }
38}
39
41{
42 if (p_s && *p_s) {
43 if (strcasecmp(p_s, "simple")==0)
45 else if (strcasecmp(p_s, "choice")==0)
47 }
49}
50
52{
53 switch (p_i) {
55 return "int";
57 return "bool";
59 return "float";
61 return "string";
63 default:
64 return "unknown";
65 }
66}
67
69{
70 switch (p_i) {
72 return "simple";
74 return "choice";
76 default:
77 return "unknown";
78 }
79}
80
82{
83 GWEN_PARAM *p_struct;
84
86 p_struct->_refCount=1;
87 GWEN_LIST_INIT(GWEN_PARAM, p_struct)
88 GWEN_TREE_INIT(GWEN_PARAM, p_struct)
89 /* members */
90 p_struct->name=NULL;
91 p_struct->flags=0;
92 p_struct->type=GWEN_Param_Type_Unknown;
93 p_struct->dataType=GWEN_Param_DataType_Unknown;
94 p_struct->shortDescription=NULL;
95 p_struct->longDescription=NULL;
96 p_struct->currentValue=NULL;
97 p_struct->defaultValue=NULL;
98 p_struct->choices=NULL;
99 p_struct->internalIntValue=0;
100 p_struct->internalFloatValue=0;
101 p_struct->runtimeFlags=0;
102 /* virtual functions */
103
104 return p_struct;
105}
106
108{
109 if (p_struct) {
110 assert(p_struct->_refCount);
111 if (p_struct->_refCount==1) {
112 GWEN_LIST_FINI(GWEN_PARAM, p_struct)
113 GWEN_TREE_FINI(GWEN_PARAM, p_struct)
114 /* members */
115 free(p_struct->name);
116 p_struct->name=NULL;
117 free(p_struct->shortDescription);
118 p_struct->shortDescription=NULL;
119 free(p_struct->longDescription);
120 p_struct->longDescription=NULL;
121 free(p_struct->currentValue);
122 p_struct->currentValue=NULL;
123 free(p_struct->defaultValue);
124 p_struct->defaultValue=NULL;
125 GWEN_StringList2_free(p_struct->choices);
126 p_struct->choices=NULL;
127 p_struct->_refCount=0;
128 GWEN_FREE_OBJECT(p_struct);
129 }
130 else
131 p_struct->_refCount--;
132 }
133}
134
136{
137 assert(p_struct);
138 assert(p_struct->_refCount);
139 p_struct->_refCount++;
140}
141
143{
144 GWEN_PARAM *p_struct;
145
146 assert(p_src);
147 p_struct=GWEN_Param_new();
148 /* member "name" */
149 if (p_struct->name) {
150 free(p_struct->name);
151 p_struct->name=NULL;
152 p_struct->name=NULL;
153 }
154 if (p_src->name) {
155 p_struct->name=strdup(p_src->name);
156 }
157
158 /* member "flags" */
159 p_struct->flags=p_src->flags;
160
161 /* member "type" */
162 p_struct->type=p_src->type;
163
164 /* member "dataType" */
165 p_struct->dataType=p_src->dataType;
166
167 /* member "shortDescription" */
168 if (p_struct->shortDescription) {
169 free(p_struct->shortDescription);
170 p_struct->shortDescription=NULL;
171 p_struct->shortDescription=NULL;
172 }
173 if (p_src->shortDescription) {
174 p_struct->shortDescription=strdup(p_src->shortDescription);
175 }
176
177 /* member "longDescription" */
178 if (p_struct->longDescription) {
179 free(p_struct->longDescription);
180 p_struct->longDescription=NULL;
181 p_struct->longDescription=NULL;
182 }
183 if (p_src->longDescription) {
184 p_struct->longDescription=strdup(p_src->longDescription);
185 }
186
187 /* member "currentValue" */
188 if (p_struct->currentValue) {
189 free(p_struct->currentValue);
190 p_struct->currentValue=NULL;
191 p_struct->currentValue=NULL;
192 }
193 if (p_src->currentValue) {
194 p_struct->currentValue=strdup(p_src->currentValue);
195 }
196
197 /* member "defaultValue" */
198 if (p_struct->defaultValue) {
199 free(p_struct->defaultValue);
200 p_struct->defaultValue=NULL;
201 p_struct->defaultValue=NULL;
202 }
203 if (p_src->defaultValue) {
204 p_struct->defaultValue=strdup(p_src->defaultValue);
205 }
206
207 /* member "choices" */
208 if (p_struct->choices) {
209 GWEN_StringList2_free(p_struct->choices);
210 p_struct->choices=NULL;
211 p_struct->choices=NULL;
212 }
213 if (p_src->choices) {
214 p_struct->choices=GWEN_StringList2_dup(p_src->choices);
215 }
216
217 /* member "internalIntValue" */
218 p_struct->internalIntValue=p_src->internalIntValue;
219
220 /* member "internalFloatValue" */
221 p_struct->internalFloatValue=p_src->internalFloatValue;
222
223 /* member "runtimeFlags" */
224 p_struct->runtimeFlags=p_src->runtimeFlags;
225
226 return p_struct;
227}
228
230{
231 assert(p_struct);
232 assert(p_src);
233 /* member "name" */
234 if (p_struct->name) {
235 free(p_struct->name);
236 p_struct->name=NULL;
237 p_struct->name=NULL;
238 }
239 if (p_src->name) {
240 p_struct->name=strdup(p_src->name);
241 }
242
243 /* member "flags" */
244 p_struct->flags=p_src->flags;
245
246 /* member "type" */
247 p_struct->type=p_src->type;
248
249 /* member "dataType" */
250 p_struct->dataType=p_src->dataType;
251
252 /* member "shortDescription" */
253 if (p_struct->shortDescription) {
254 free(p_struct->shortDescription);
255 p_struct->shortDescription=NULL;
256 p_struct->shortDescription=NULL;
257 }
258 if (p_src->shortDescription) {
259 p_struct->shortDescription=strdup(p_src->shortDescription);
260 }
261
262 /* member "longDescription" */
263 if (p_struct->longDescription) {
264 free(p_struct->longDescription);
265 p_struct->longDescription=NULL;
266 p_struct->longDescription=NULL;
267 }
268 if (p_src->longDescription) {
269 p_struct->longDescription=strdup(p_src->longDescription);
270 }
271
272 /* member "currentValue" */
273 if (p_struct->currentValue) {
274 free(p_struct->currentValue);
275 p_struct->currentValue=NULL;
276 p_struct->currentValue=NULL;
277 }
278 if (p_src->currentValue) {
279 p_struct->currentValue=strdup(p_src->currentValue);
280 }
281
282 /* member "defaultValue" */
283 if (p_struct->defaultValue) {
284 free(p_struct->defaultValue);
285 p_struct->defaultValue=NULL;
286 p_struct->defaultValue=NULL;
287 }
288 if (p_src->defaultValue) {
289 p_struct->defaultValue=strdup(p_src->defaultValue);
290 }
291
292 /* member "choices" */
293 if (p_struct->choices) {
294 GWEN_StringList2_free(p_struct->choices);
295 p_struct->choices=NULL;
296 p_struct->choices=NULL;
297 }
298 if (p_src->choices) {
299 p_struct->choices=GWEN_StringList2_dup(p_src->choices);
300 }
301
302 /* member "internalIntValue" */
303 p_struct->internalIntValue=p_src->internalIntValue;
304
305 /* member "internalFloatValue" */
306 p_struct->internalFloatValue=p_src->internalFloatValue;
307
308 /* member "runtimeFlags" */
309 p_struct->runtimeFlags=p_src->runtimeFlags;
310
311 return p_struct;
312}
313
314const char *GWEN_Param_GetName(const GWEN_PARAM *p_struct)
315{
316 assert(p_struct);
317 return p_struct->name;
318}
319
320uint32_t GWEN_Param_GetFlags(const GWEN_PARAM *p_struct)
321{
322 assert(p_struct);
323 return p_struct->flags;
324}
325
327{
328 assert(p_struct);
329 return p_struct->type;
330}
331
333{
334 assert(p_struct);
335 return p_struct->dataType;
336}
337
338const char *GWEN_Param_GetShortDescription(const GWEN_PARAM *p_struct)
339{
340 assert(p_struct);
341 return p_struct->shortDescription;
342}
343
344const char *GWEN_Param_GetLongDescription(const GWEN_PARAM *p_struct)
345{
346 assert(p_struct);
347 return p_struct->longDescription;
348}
349
350const char *GWEN_Param_GetCurrentValue(const GWEN_PARAM *p_struct)
351{
352 assert(p_struct);
353 return p_struct->currentValue;
354}
355
356const char *GWEN_Param_GetDefaultValue(const GWEN_PARAM *p_struct)
357{
358 assert(p_struct);
359 return p_struct->defaultValue;
360}
361
363{
364 assert(p_struct);
365 return p_struct->choices;
366}
367
369{
370 assert(p_struct);
371 return p_struct->internalIntValue;
372}
373
375{
376 assert(p_struct);
377 return p_struct->internalFloatValue;
378}
379
380uint32_t GWEN_Param_GetRuntimeFlags(const GWEN_PARAM *p_struct)
381{
382 assert(p_struct);
383 return p_struct->runtimeFlags;
384}
385
386void GWEN_Param_SetName(GWEN_PARAM *p_struct, const char *p_src)
387{
388 assert(p_struct);
389 if (p_struct->name) {
390 free(p_struct->name);
391 p_struct->name=NULL;
392 }
393 if (p_src) {
394 p_struct->name=strdup(p_src);
395 }
396 else {
397 p_struct->name=NULL;
398 }
399}
400
401void GWEN_Param_SetFlags(GWEN_PARAM *p_struct, uint32_t p_src)
402{
403 assert(p_struct);
404 p_struct->flags=p_src;
405}
406
407void GWEN_Param_AddFlags(GWEN_PARAM *p_struct, uint32_t p_src)
408{
409 assert(p_struct);
410 p_struct->flags|=p_src;
411}
412
413void GWEN_Param_SubFlags(GWEN_PARAM *p_struct, uint32_t p_src)
414{
415 assert(p_struct);
416 p_struct->flags&=~p_src;
417}
418
420{
421 assert(p_struct);
422 p_struct->type=p_src;
423}
424
426{
427 assert(p_struct);
428 p_struct->dataType=p_src;
429}
430
431void GWEN_Param_SetShortDescription(GWEN_PARAM *p_struct, const char *p_src)
432{
433 assert(p_struct);
434 if (p_struct->shortDescription) {
435 free(p_struct->shortDescription);
436 p_struct->shortDescription=NULL;
437 }
438 if (p_src) {
439 p_struct->shortDescription=strdup(p_src);
440 }
441 else {
442 p_struct->shortDescription=NULL;
443 }
444}
445
446void GWEN_Param_SetLongDescription(GWEN_PARAM *p_struct, const char *p_src)
447{
448 assert(p_struct);
449 if (p_struct->longDescription) {
450 free(p_struct->longDescription);
451 p_struct->longDescription=NULL;
452 }
453 if (p_src) {
454 p_struct->longDescription=strdup(p_src);
455 }
456 else {
457 p_struct->longDescription=NULL;
458 }
459}
460
461void GWEN_Param_SetCurrentValue(GWEN_PARAM *p_struct, const char *p_src)
462{
463 assert(p_struct);
464 if (p_struct->currentValue) {
465 free(p_struct->currentValue);
466 p_struct->currentValue=NULL;
467 }
468 if (p_src) {
469 p_struct->currentValue=strdup(p_src);
470 }
471 else {
472 p_struct->currentValue=NULL;
473 }
474}
475
476void GWEN_Param_SetDefaultValue(GWEN_PARAM *p_struct, const char *p_src)
477{
478 assert(p_struct);
479 if (p_struct->defaultValue) {
480 free(p_struct->defaultValue);
481 p_struct->defaultValue=NULL;
482 }
483 if (p_src) {
484 p_struct->defaultValue=strdup(p_src);
485 }
486 else {
487 p_struct->defaultValue=NULL;
488 }
489}
490
492{
493 assert(p_struct);
494 if (p_struct->choices) {
495 GWEN_StringList2_free(p_struct->choices);
496 p_struct->choices=NULL;
497 }
498 p_struct->choices=p_src;
499}
500
502{
503 assert(p_struct);
504 p_struct->internalIntValue=p_src;
505}
506
507void GWEN_Param_SetInternalFloatValue(GWEN_PARAM *p_struct, double p_src)
508{
509 assert(p_struct);
510 p_struct->internalFloatValue=p_src;
511}
512
513void GWEN_Param_SetRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
514{
515 assert(p_struct);
516 p_struct->runtimeFlags=p_src;
517}
518
519void GWEN_Param_AddRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
520{
521 assert(p_struct);
522 p_struct->runtimeFlags|=p_src;
523}
524
525void GWEN_Param_SubRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
526{
527 assert(p_struct);
528 p_struct->runtimeFlags&=~p_src;
529}
530
531/* list1 functions */
533{
534 GWEN_PARAM_LIST *p_dest;
535 GWEN_PARAM *p_elem;
536
537 assert(p_src);
538 p_dest=GWEN_Param_List_new();
539 p_elem=GWEN_Param_List_First(p_src);
540 while (p_elem) {
541 GWEN_PARAM *p_cpy;
542
543 p_cpy=GWEN_Param_dup(p_elem);
544 GWEN_Param_List_Add(p_cpy, p_dest);
545 p_elem=GWEN_Param_List_Next(p_elem);
546 }
547
548 return p_dest;
549}
550
552{
553 assert(p_struct);
554 /* member "name" */
555 if (p_struct->name) {
556 free(p_struct->name);
557 p_struct->name=NULL;
558 }
559 {
560 const char *s;
561 s=GWEN_DB_GetCharValue(p_db, "name", 0, NULL);
562 if (s)
563 p_struct->name=strdup(s);
564 }
565 if (p_struct->name==NULL) {
566 p_struct->name=NULL;
567 }
568
569 /* member "flags" */
570 p_struct->flags=GWEN_DB_GetIntValue(p_db, "flags", 0, 0);
571
572 /* member "type" */
573 {
574 const char *s;
575 s=GWEN_DB_GetCharValue(p_db, "type", 0, NULL);
576 if (s)
577 p_struct->type=GWEN_Param_Type_fromString(s);
578 else
579 p_struct->type=GWEN_Param_Type_Unknown;
580 }
581
582 /* member "dataType" */
583 {
584 const char *s;
585 s=GWEN_DB_GetCharValue(p_db, "dataType", 0, NULL);
586 if (s)
587 p_struct->dataType=GWEN_Param_DataType_fromString(s);
588 else
589 p_struct->dataType=GWEN_Param_DataType_Unknown;
590 }
591
592 /* member "shortDescription" */
593 if (p_struct->shortDescription) {
594 free(p_struct->shortDescription);
595 p_struct->shortDescription=NULL;
596 }
597 {
598 const char *s;
599 s=GWEN_DB_GetCharValue(p_db, "shortDescription", 0, NULL);
600 if (s)
601 p_struct->shortDescription=strdup(s);
602 }
603 if (p_struct->shortDescription==NULL) {
604 p_struct->shortDescription=NULL;
605 }
606
607 /* member "longDescription" */
608 if (p_struct->longDescription) {
609 free(p_struct->longDescription);
610 p_struct->longDescription=NULL;
611 }
612 {
613 const char *s;
614 s=GWEN_DB_GetCharValue(p_db, "longDescription", 0, NULL);
615 if (s)
616 p_struct->longDescription=strdup(s);
617 }
618 if (p_struct->longDescription==NULL) {
619 p_struct->longDescription=NULL;
620 }
621
622 /* member "currentValue" */
623 if (p_struct->currentValue) {
624 free(p_struct->currentValue);
625 p_struct->currentValue=NULL;
626 }
627 {
628 const char *s;
629 s=GWEN_DB_GetCharValue(p_db, "currentValue", 0, NULL);
630 if (s)
631 p_struct->currentValue=strdup(s);
632 }
633 if (p_struct->currentValue==NULL) {
634 p_struct->currentValue=NULL;
635 }
636
637 /* member "defaultValue" */
638 if (p_struct->defaultValue) {
639 free(p_struct->defaultValue);
640 p_struct->defaultValue=NULL;
641 }
642 {
643 const char *s;
644 s=GWEN_DB_GetCharValue(p_db, "defaultValue", 0, NULL);
645 if (s)
646 p_struct->defaultValue=strdup(s);
647 }
648 if (p_struct->defaultValue==NULL) {
649 p_struct->defaultValue=NULL;
650 }
651
652 /* member "choices" */
653 if (p_struct->choices) {
654 GWEN_StringList2_free(p_struct->choices);
655 p_struct->choices=NULL;
656 }
657 {
658 p_struct->choices=GWEN_StringList2_fromDb(p_db, "choices", GWEN_StringList2_IntertMode_AlwaysAdd);
659 }
660 if (p_struct->choices==NULL) {
661 p_struct->choices=NULL;
662 }
663
664 /* member "internalIntValue" */
665 /* member "internalIntValue" is volatile, just presetting */
666 p_struct->internalIntValue=0;
667
668 /* member "internalFloatValue" */
669 /* member "internalFloatValue" is volatile, just presetting */
670 p_struct->internalFloatValue=0;
671
672 /* member "runtimeFlags" */
673 /* member "runtimeFlags" is volatile, just presetting */
674 p_struct->runtimeFlags=0;
675
676}
677
678int GWEN_Param_WriteDb(const GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
679{
680 int p_rv;
681
682 assert(p_struct);
683 /* member "name" */
684 if (p_struct->name)
685 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "name", p_struct->name);
686 else {
687 GWEN_DB_DeleteVar(p_db, "name");
688 p_rv=0;
689 }
690 if (p_rv<0) {
691 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
692 return p_rv;
693 }
694
695 /* member "flags" */
696 p_rv=GWEN_DB_SetIntValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "flags", p_struct->flags);
697 if (p_rv<0) {
698 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
699 return p_rv;
700 }
701
702 /* member "type" */
704 if (p_rv<0) {
705 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
706 return p_rv;
707 }
708
709 /* member "dataType" */
711 GWEN_Param_DataType_toString(p_struct->dataType));
712 if (p_rv<0) {
713 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
714 return p_rv;
715 }
716
717 /* member "shortDescription" */
718 if (p_struct->shortDescription)
719 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "shortDescription", p_struct->shortDescription);
720 else {
721 GWEN_DB_DeleteVar(p_db, "shortDescription");
722 p_rv=0;
723 }
724 if (p_rv<0) {
725 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
726 return p_rv;
727 }
728
729 /* member "longDescription" */
730 if (p_struct->longDescription)
731 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "longDescription", p_struct->longDescription);
732 else {
733 GWEN_DB_DeleteVar(p_db, "longDescription");
734 p_rv=0;
735 }
736 if (p_rv<0) {
737 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
738 return p_rv;
739 }
740
741 /* member "currentValue" */
742 if (p_struct->currentValue)
743 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "currentValue", p_struct->currentValue);
744 else {
745 GWEN_DB_DeleteVar(p_db, "currentValue");
746 p_rv=0;
747 }
748 if (p_rv<0) {
749 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
750 return p_rv;
751 }
752
753 /* member "defaultValue" */
754 if (p_struct->defaultValue)
755 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "defaultValue", p_struct->defaultValue);
756 else {
757 GWEN_DB_DeleteVar(p_db, "defaultValue");
758 p_rv=0;
759 }
760 if (p_rv<0) {
761 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
762 return p_rv;
763 }
764
765 /* member "choices" */
766 if (p_struct->choices) {
767 p_rv=GWEN_StringList2_toDb(p_struct->choices, p_db, "choices");
768 }
769 else {
770 GWEN_DB_DeleteVar(p_db, "choices");
771 p_rv=0;
772 }
773 if (p_rv<0) {
774 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
775 return p_rv;
776 }
777
778 /* member "internalIntValue" is volatile, not writing to db */
779
780 /* member "internalFloatValue" is volatile, not writing to db */
781
782 /* member "runtimeFlags" is volatile, not writing to db */
783
784 return 0;
785}
786
788{
789 GWEN_PARAM *p_struct;
790 p_struct=GWEN_Param_new();
791 GWEN_Param_ReadDb(p_struct, p_db);
792 return p_struct;
793}
794
795int GWEN_Param_toDb(const GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
796{
797 return GWEN_Param_WriteDb(p_struct, p_db);
798}
799
801{
802 assert(p_struct);
803 /* member "name" */
804 if (p_struct->name) {
805 free(p_struct->name);
806 p_struct->name=NULL;
807 }
808 {
809 const char *s;
810 s=GWEN_XMLNode_GetCharValue(p_db, "name", NULL);
811 if (s)
812 p_struct->name=strdup(s);
813 }
814 if (p_struct->name==NULL) { /* preset member "name" if empty */
815 p_struct->name=NULL;
816 }
817
818 /* member "flags" */
819 p_struct->flags=GWEN_XMLNode_GetIntValue(p_db, "flags", 0);
820
821 /* member "type" */
822 {
823 const char *s;
824 s=GWEN_XMLNode_GetCharValue(p_db, "type", NULL);
825 if (s)
826 p_struct->type=GWEN_Param_Type_fromString(s);
827 else
828 p_struct->type=GWEN_Param_Type_Unknown;
829 }
830
831 /* member "dataType" */
832 {
833 const char *s;
834 s=GWEN_XMLNode_GetCharValue(p_db, "dataType", NULL);
835 if (s)
836 p_struct->dataType=GWEN_Param_DataType_fromString(s);
837 else
838 p_struct->dataType=GWEN_Param_DataType_Unknown;
839 }
840
841 /* member "shortDescription" */
842 if (p_struct->shortDescription) {
843 free(p_struct->shortDescription);
844 p_struct->shortDescription=NULL;
845 }
846 {
847 const char *s;
848 s=GWEN_XMLNode_GetCharValue(p_db, "shortDescription", NULL);
849 if (s)
850 p_struct->shortDescription=strdup(s);
851 }
852 if (p_struct->shortDescription==NULL) { /* preset member "shortDescription" if empty */
853 p_struct->shortDescription=NULL;
854 }
855
856 /* member "longDescription" */
857 if (p_struct->longDescription) {
858 free(p_struct->longDescription);
859 p_struct->longDescription=NULL;
860 }
861 {
862 const char *s;
863 s=GWEN_XMLNode_GetCharValue(p_db, "longDescription", NULL);
864 if (s)
865 p_struct->longDescription=strdup(s);
866 }
867 if (p_struct->longDescription==NULL) { /* preset member "longDescription" if empty */
868 p_struct->longDescription=NULL;
869 }
870
871 /* member "currentValue" */
872 if (p_struct->currentValue) {
873 free(p_struct->currentValue);
874 p_struct->currentValue=NULL;
875 }
876 {
877 const char *s;
878 s=GWEN_XMLNode_GetCharValue(p_db, "currentValue", NULL);
879 if (s)
880 p_struct->currentValue=strdup(s);
881 }
882 if (p_struct->currentValue==NULL) { /* preset member "currentValue" if empty */
883 p_struct->currentValue=NULL;
884 }
885
886 /* member "defaultValue" */
887 if (p_struct->defaultValue) {
888 free(p_struct->defaultValue);
889 p_struct->defaultValue=NULL;
890 }
891 {
892 const char *s;
893 s=GWEN_XMLNode_GetCharValue(p_db, "defaultValue", NULL);
894 if (s)
895 p_struct->defaultValue=strdup(s);
896 }
897 if (p_struct->defaultValue==NULL) { /* preset member "defaultValue" if empty */
898 p_struct->defaultValue=NULL;
899 }
900
901 /* member "choices" */
902 if (p_struct->choices) {
903 GWEN_StringList2_free(p_struct->choices);
904 p_struct->choices=NULL;
905 }
906 {
907 GWEN_XMLNODE *n;
908 n=GWEN_XMLNode_FindFirstTag(p_db, "choices", 0, 0);
909 if (n) {
911 }
912 else
913 p_struct->choices=NULL;
914 }
915 if (p_struct->choices==NULL) { /* preset member "choices" if empty */
916 p_struct->choices=NULL;
917 }
918
919 /* member "internalIntValue" */
920 /* member "internalIntValue" is volatile, just presetting */
921 p_struct->internalIntValue=0;
922
923 /* member "internalFloatValue" */
924 /* member "internalFloatValue" is volatile, just presetting */
925 p_struct->internalFloatValue=0;
926
927 /* member "runtimeFlags" */
928 /* member "runtimeFlags" is volatile, just presetting */
929 p_struct->runtimeFlags=0;
930
931}
932
933void GWEN_Param_WriteXml(const GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
934{
935 assert(p_struct);
936 /* member "name" */
937 GWEN_XMLNode_SetCharValue(p_db, "name", p_struct->name);
938
939 /* member "flags" */
940 GWEN_XMLNode_SetIntValue(p_db, "flags", p_struct->flags);
941
942 /* member "type" */
943 GWEN_XMLNode_SetCharValue(p_db, "type", GWEN_Param_Type_toString(p_struct->type));
944
945 /* member "dataType" */
946 GWEN_XMLNode_SetCharValue(p_db, "dataType", GWEN_Param_DataType_toString(p_struct->dataType));
947
948 /* member "shortDescription" */
949 GWEN_XMLNode_SetCharValue(p_db, "shortDescription", p_struct->shortDescription);
950
951 /* member "longDescription" */
952 GWEN_XMLNode_SetCharValue(p_db, "longDescription", p_struct->longDescription);
953
954 /* member "currentValue" */
955 GWEN_XMLNode_SetCharValue(p_db, "currentValue", p_struct->currentValue);
956
957 /* member "defaultValue" */
958 GWEN_XMLNode_SetCharValue(p_db, "defaultValue", p_struct->defaultValue);
959
960 /* member "choices" */
961 if (p_struct->choices) {
962 GWEN_XMLNODE *n;
964 GWEN_StringList2_toXml(p_struct->choices, n);
965 GWEN_XMLNode_AddChild(p_db, n);
966 }
967
968 /* member "internalIntValue" is volatile, not writing to xml */
969
970 /* member "internalFloatValue" is volatile, not writing to xml */
971
972 /* member "runtimeFlags" is volatile, not writing to xml */
973
974}
975
976void GWEN_Param_toXml(const GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
977{
978 GWEN_Param_WriteXml(p_struct, p_db);
979}
980
982{
983 GWEN_PARAM *p_struct;
984 p_struct=GWEN_Param_new();
985 GWEN_Param_ReadXml(p_struct, p_db);
986 return p_struct;
987}
988
989GWEN_PARAM *GWEN_Param_List_GetByName(const GWEN_PARAM_LIST *p_list, const char *p_cmp)
990{
991 GWEN_PARAM *p_struct;
992
993 assert(p_list);
994 p_struct = GWEN_Param_List_First(p_list);
995 while (p_struct) {
996 int p_rv;
997
998 if (p_struct->name && p_cmp)
999 p_rv=strcasecmp(p_cmp, p_struct->name);
1000 else if (p_cmp)
1001 p_rv=1;
1002 else if (p_struct->name)
1003 p_rv=-1;
1004 else
1005 p_rv=0;
1006 if (p_rv == 0)
1007 return p_struct;
1008 p_struct = GWEN_Param_List_Next(p_struct);
1009 }
1010 return NULL;
1011}
1012
1013GWEN_PARAM *GWEN_Param_Tree_GetByName(const GWEN_PARAM_TREE *p_tree, const char *p_cmp)
1014{
1015 GWEN_PARAM *p_struct;
1016
1017 assert(p_tree);
1018 p_struct = GWEN_Param_Tree_GetFirst(p_tree);
1019 while (p_struct) {
1020 int p_rv;
1021
1022 if (p_struct->name && p_cmp)
1023 p_rv=strcasecmp(p_cmp, p_struct->name);
1024 else if (p_cmp)
1025 p_rv=1;
1026 else if (p_struct->name)
1027 p_rv=-1;
1028 else
1029 p_rv=0;
1030 if (p_rv == 0)
1031 return p_struct;
1032 p_struct = GWEN_Param_Tree_GetBelow(p_struct);
1033 }
1034 return NULL;
1035}
1036
1037
1038/* code headers */
1039#include "param_fns.c"
1040
#define NULL
Definition binreloc.c:300
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition db.c:971
int GWEN_DB_DeleteVar(GWEN_DB_NODE *n, const char *path)
Definition db.c:899
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
Definition db.c:1202
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
Definition db.c:997
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
Definition db.c:1163
#define GWEN_DB_FLAGS_OVERWRITE_VARS
Definition db.h:121
struct GWEN_DB_NODE GWEN_DB_NODE
Definition db.h:228
#define DBG_INFO(dbg_logger, format,...)
Definition debug.h:181
#define GWEN_LIST_FINI(t, element)
Definition list1.h:475
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition list1.h:367
#define GWEN_LIST_INIT(t, element)
Definition list1.h:466
#define GWEN_LIST2_FUNCTIONS(t, pr)
Definition list2.h:99
GWEN_PARAM * GWEN_Param_List_Next(const GWEN_PARAM *element)
void GWEN_Param_List_Add(GWEN_PARAM *element, GWEN_PARAM_LIST *list)
GWEN_PARAM * GWEN_Param_List_First(const GWEN_PARAM_LIST *l)
GWEN_PARAM_LIST * GWEN_Param_List_new()
#define GWEN_LOGDOMAIN
Definition logger.h:32
#define GWEN_FREE_OBJECT(varname)
Definition memory.h:61
#define GWEN_NEW_OBJECT(typ, varname)
Definition memory.h:55
int GWEN_Param_GetInternalIntValue(const GWEN_PARAM *p_struct)
Definition param.c:368
GWEN_PARAM * GWEN_Param_fromXml(GWEN_XMLNODE *p_db)
Definition param.c:981
void GWEN_Param_SetDataType(GWEN_PARAM *p_struct, GWEN_PARAM_DATATYPE p_src)
Definition param.c:425
GWEN_PARAM * GWEN_Param_copy(GWEN_PARAM *p_struct, const GWEN_PARAM *p_src)
Definition param.c:229
void GWEN_Param_SubRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
Definition param.c:525
void GWEN_Param_AddRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
Definition param.c:519
GWEN_PARAM * GWEN_Param_Tree_GetByName(const GWEN_PARAM_TREE *p_tree, const char *p_cmp)
Definition param.c:1013
int GWEN_Param_WriteDb(const GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
Definition param.c:678
void GWEN_Param_SetChoices(GWEN_PARAM *p_struct, GWEN_STRINGLIST2 *p_src)
Definition param.c:491
const char * GWEN_Param_GetShortDescription(const GWEN_PARAM *p_struct)
Definition param.c:338
uint32_t GWEN_Param_GetFlags(const GWEN_PARAM *p_struct)
Definition param.c:320
GWEN_PARAM_LIST * GWEN_Param_List_dup(const GWEN_PARAM_LIST *p_src)
Definition param.c:532
void GWEN_Param_SetShortDescription(GWEN_PARAM *p_struct, const char *p_src)
Definition param.c:431
GWEN_PARAM * GWEN_Param_List_GetByName(const GWEN_PARAM_LIST *p_list, const char *p_cmp)
Definition param.c:989
void GWEN_Param_SetInternalIntValue(GWEN_PARAM *p_struct, int p_src)
Definition param.c:501
const char * GWEN_Param_Type_toString(GWEN_PARAM_TYPE p_i)
Definition param.c:68
GWEN_PARAM * GWEN_Param_fromDb(GWEN_DB_NODE *p_db)
Definition param.c:787
void GWEN_Param_SetLongDescription(GWEN_PARAM *p_struct, const char *p_src)
Definition param.c:446
const char * GWEN_Param_GetCurrentValue(const GWEN_PARAM *p_struct)
Definition param.c:350
GWEN_PARAM * GWEN_Param_new(void)
Definition param.c:81
void GWEN_Param_SetName(GWEN_PARAM *p_struct, const char *p_src)
Definition param.c:386
GWEN_PARAM_TYPE GWEN_Param_Type_fromString(const char *p_s)
Definition param.c:40
void GWEN_Param_AddFlags(GWEN_PARAM *p_struct, uint32_t p_src)
Definition param.c:407
void GWEN_Param_free(GWEN_PARAM *p_struct)
Definition param.c:107
GWEN_PARAM_TYPE GWEN_Param_GetType(const GWEN_PARAM *p_struct)
Definition param.c:326
double GWEN_Param_GetInternalFloatValue(const GWEN_PARAM *p_struct)
Definition param.c:374
void GWEN_Param_SubFlags(GWEN_PARAM *p_struct, uint32_t p_src)
Definition param.c:413
void GWEN_Param_SetInternalFloatValue(GWEN_PARAM *p_struct, double p_src)
Definition param.c:507
void GWEN_Param_SetType(GWEN_PARAM *p_struct, GWEN_PARAM_TYPE p_src)
Definition param.c:419
int GWEN_Param_toDb(const GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
Definition param.c:795
GWEN_PARAM * GWEN_Param_dup(const GWEN_PARAM *p_src)
Definition param.c:142
void GWEN_Param_toXml(const GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
Definition param.c:976
void GWEN_Param_Attach(GWEN_PARAM *p_struct)
Definition param.c:135
GWEN_STRINGLIST2 * GWEN_Param_GetChoices(const GWEN_PARAM *p_struct)
Definition param.c:362
void GWEN_Param_WriteXml(const GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
Definition param.c:933
uint32_t GWEN_Param_GetRuntimeFlags(const GWEN_PARAM *p_struct)
Definition param.c:380
void GWEN_Param_SetDefaultValue(GWEN_PARAM *p_struct, const char *p_src)
Definition param.c:476
GWEN_PARAM_DATATYPE GWEN_Param_DataType_fromString(const char *p_s)
Definition param.c:25
void GWEN_Param_SetFlags(GWEN_PARAM *p_struct, uint32_t p_src)
Definition param.c:401
void GWEN_Param_ReadDb(GWEN_PARAM *p_struct, GWEN_DB_NODE *p_db)
Definition param.c:551
const char * GWEN_Param_DataType_toString(GWEN_PARAM_DATATYPE p_i)
Definition param.c:51
const char * GWEN_Param_GetLongDescription(const GWEN_PARAM *p_struct)
Definition param.c:344
void GWEN_Param_SetRuntimeFlags(GWEN_PARAM *p_struct, uint32_t p_src)
Definition param.c:513
void GWEN_Param_SetCurrentValue(GWEN_PARAM *p_struct, const char *p_src)
Definition param.c:461
GWEN_PARAM_DATATYPE GWEN_Param_GetDataType(const GWEN_PARAM *p_struct)
Definition param.c:332
const char * GWEN_Param_GetDefaultValue(const GWEN_PARAM *p_struct)
Definition param.c:356
const char * GWEN_Param_GetName(const GWEN_PARAM *p_struct)
Definition param.c:314
void GWEN_Param_ReadXml(GWEN_PARAM *p_struct, GWEN_XMLNODE *p_db)
Definition param.c:800
GWEN_PARAM_DATATYPE
Definition param.h:123
@ GWEN_Param_DataType_Float
Definition param.h:127
@ GWEN_Param_DataType_Unknown
Definition param.h:124
@ GWEN_Param_DataType_Int
Definition param.h:125
@ GWEN_Param_DataType_String
Definition param.h:128
@ GWEN_Param_DataType_Bool
Definition param.h:126
GWEN_PARAM_TYPE
Definition param.h:132
@ GWEN_Param_Type_Unknown
Definition param.h:133
@ GWEN_Param_Type_Choice
Definition param.h:135
@ GWEN_Param_Type_Simple
Definition param.h:134
struct GWEN_PARAM GWEN_PARAM
Definition param.h:116
int GWEN_StringList2_toDb(GWEN_STRINGLIST2 *sl2, GWEN_DB_NODE *db, const char *name)
Definition stringlist2.c:86
int GWEN_StringList2_toXml(GWEN_STRINGLIST2 *sl2, GWEN_XMLNODE *node)
GWEN_STRINGLIST2 * GWEN_StringList2_fromXml(GWEN_XMLNODE *node, GWEN_STRINGLIST2_INSERTMODE m)
GWEN_STRINGLIST2 * GWEN_StringList2_dup(GWEN_STRINGLIST2 *sl2)
Definition stringlist2.c:73
GWEN_STRINGLIST2 * GWEN_StringList2_fromDb(GWEN_DB_NODE *db, const char *name, GWEN_STRINGLIST2_INSERTMODE m)
void GWEN_StringList2_free(GWEN_STRINGLIST2 *sl2)
Definition stringlist2.c:63
struct GWEN_STRINGLIST2 GWEN_STRINGLIST2
Definition stringlist2.h:43
@ GWEN_StringList2_IntertMode_AlwaysAdd
Definition stringlist2.h:48
#define GWEN_TREE_FINI(t, element)
Definition tree.h:571
#define GWEN_TREE_FUNCTIONS(t, pr)
Definition tree.h:402
#define GWEN_TREE_INIT(t, element)
Definition tree.h:562
GWEN_XMLNODE * GWEN_XMLNode_FindFirstTag(const GWEN_XMLNODE *n, const char *tname, const char *pname, const char *pvalue)
Definition xml.c:776
GWEN_XMLNODE * GWEN_XMLNode_new(GWEN_XMLNODE_TYPE t, const char *data)
Definition xml.c:144
void GWEN_XMLNode_SetIntValue(GWEN_XMLNODE *n, const char *name, int value)
Definition xml.c:940
int GWEN_XMLNode_GetIntValue(const GWEN_XMLNODE *n, const char *name, int defValue)
Definition xml.c:923
const char * GWEN_XMLNode_GetCharValue(const GWEN_XMLNODE *n, const char *name, const char *defValue)
Definition xml.c:812
void GWEN_XMLNode_AddChild(GWEN_XMLNODE *n, GWEN_XMLNODE *child)
Definition xml.c:423
void GWEN_XMLNode_SetCharValue(GWEN_XMLNODE *n, const char *name, const char *value)
Definition xml.c:897
struct GWEN__XMLNODE GWEN_XMLNODE
Definition xml.h:156
@ GWEN_XMLNodeTypeTag
Definition xml.h:145