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