gwenhywfar  5.10.1
tm_define.c
Go to the documentation of this file.
1 /**********************************************************
2  * This file has been automatically created by "typemaker2"
3  * from the file "tm_define.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 "tm_define_p.h"
13 
14 #include <gwenhywfar/misc.h>
15 #include <gwenhywfar/debug.h>
16 
17 /* code headers */
18 
19 /* macro functions */
20 GWEN_LIST_FUNCTIONS(TYPEMAKER2_DEFINE, Typemaker2_Define)
21 
22 
24 {
25  if (p_s && *p_s) {
26  if (strcasecmp(p_s, "sequence")==0)
28  else if (strcasecmp(p_s, "bitField")==0)
30  }
32 }
33 
34 const char *Typemaker2_Define_Mode_toString(int p_i)
35 {
36  switch (p_i) {
38  return "sequence";
40  return "bitField";
41  default:
42  return "unknown";
43  }
44 }
45 
47 {
48  TYPEMAKER2_DEFINE *p_struct;
49 
52  /* members */
53  p_struct->id=NULL;
54  p_struct->prefix=NULL;
55  p_struct->type=NULL;
56  p_struct->items=Typemaker2_Item_List_new();
57  p_struct->mode=Typemaker2_Define_Mode_Unknown;
58  p_struct->startValue=0;
59  p_struct->lastValue=0;
60  /* virtual functions */
61 
62  return p_struct;
63 }
64 
66 {
67  if (p_struct) {
69  /* members */
70  free(p_struct->id);
71  free(p_struct->prefix);
72  free(p_struct->type);
73  Typemaker2_Item_List_free(p_struct->items);
74  GWEN_FREE_OBJECT(p_struct);
75  }
76 }
77 
79 {
80  TYPEMAKER2_DEFINE *p_struct;
81 
82  assert(p_src);
83  p_struct=Typemaker2_Define_new();
84  /* member "id" */
85  if (p_struct->id) {
86  free(p_struct->id);
87  p_struct->id=NULL;
88  }
89  if (p_src->id) {
90  p_struct->id=strdup(p_src->id);
91  }
92 
93  /* member "prefix" */
94  if (p_struct->prefix) {
95  free(p_struct->prefix);
96  p_struct->prefix=NULL;
97  }
98  if (p_src->prefix) {
99  p_struct->prefix=strdup(p_src->prefix);
100  }
101 
102  /* member "type" */
103  if (p_struct->type) {
104  free(p_struct->type);
105  p_struct->type=NULL;
106  }
107  if (p_src->type) {
108  p_struct->type=strdup(p_src->type);
109  }
110 
111  /* member "items" */
112  if (p_struct->items) {
113  Typemaker2_Item_List_free(p_struct->items);
114  p_struct->items=NULL;
115  }
116  if (p_src->items) {
117  p_struct->items=Typemaker2_Item_List_dup(p_src->items);
118  }
119 
120  /* member "mode" */
121  p_struct->mode=p_src->mode;
122 
123  /* member "startValue" */
124  p_struct->startValue=p_src->startValue;
125 
126  /* member "lastValue" */
127  p_struct->lastValue=p_src->lastValue;
128 
129  return p_struct;
130 }
131 
133 {
134  assert(p_struct);
135  assert(p_src);
136  /* member "id" */
137  if (p_struct->id) {
138  free(p_struct->id);
139  p_struct->id=NULL;
140  }
141  if (p_src->id) {
142  p_struct->id=strdup(p_src->id);
143  }
144 
145  /* member "prefix" */
146  if (p_struct->prefix) {
147  free(p_struct->prefix);
148  p_struct->prefix=NULL;
149  }
150  if (p_src->prefix) {
151  p_struct->prefix=strdup(p_src->prefix);
152  }
153 
154  /* member "type" */
155  if (p_struct->type) {
156  free(p_struct->type);
157  p_struct->type=NULL;
158  }
159  if (p_src->type) {
160  p_struct->type=strdup(p_src->type);
161  }
162 
163  /* member "items" */
164  if (p_struct->items) {
165  Typemaker2_Item_List_free(p_struct->items);
166  p_struct->items=NULL;
167  }
168  if (p_src->items) {
169  p_struct->items=Typemaker2_Item_List_dup(p_src->items);
170  }
171 
172  /* member "mode" */
173  p_struct->mode=p_src->mode;
174 
175  /* member "startValue" */
176  p_struct->startValue=p_src->startValue;
177 
178  /* member "lastValue" */
179  p_struct->lastValue=p_src->lastValue;
180 
181  return p_struct;
182 }
183 
184 const char *Typemaker2_Define_GetId(const TYPEMAKER2_DEFINE *p_struct)
185 {
186  assert(p_struct);
187  return p_struct->id;
188 }
189 
190 const char *Typemaker2_Define_GetPrefix(const TYPEMAKER2_DEFINE *p_struct)
191 {
192  assert(p_struct);
193  return p_struct->prefix;
194 }
195 
196 const char *Typemaker2_Define_GetType(const TYPEMAKER2_DEFINE *p_struct)
197 {
198  assert(p_struct);
199  return p_struct->type;
200 }
201 
202 TYPEMAKER2_ITEM_LIST *Typemaker2_Define_GetItems(const TYPEMAKER2_DEFINE *p_struct)
203 {
204  assert(p_struct);
205  return p_struct->items;
206 }
207 
209 {
210  assert(p_struct);
211  return p_struct->mode;
212 }
213 
215 {
216  assert(p_struct);
217  return p_struct->startValue;
218 }
219 
221 {
222  assert(p_struct);
223  return p_struct->lastValue;
224 }
225 
226 void Typemaker2_Define_SetId(TYPEMAKER2_DEFINE *p_struct, const char *p_src)
227 {
228  assert(p_struct);
229  if (p_struct->id) {
230  free(p_struct->id);
231  }
232  if (p_src) {
233  p_struct->id=strdup(p_src);
234  }
235  else {
236  p_struct->id=NULL;
237  }
238 }
239 
240 void Typemaker2_Define_SetPrefix(TYPEMAKER2_DEFINE *p_struct, const char *p_src)
241 {
242  assert(p_struct);
243  if (p_struct->prefix) {
244  free(p_struct->prefix);
245  }
246  if (p_src) {
247  p_struct->prefix=strdup(p_src);
248  }
249  else {
250  p_struct->prefix=NULL;
251  }
252 }
253 
254 void Typemaker2_Define_SetType(TYPEMAKER2_DEFINE *p_struct, const char *p_src)
255 {
256  assert(p_struct);
257  if (p_struct->type) {
258  free(p_struct->type);
259  }
260  if (p_src) {
261  p_struct->type=strdup(p_src);
262  }
263  else {
264  p_struct->type=NULL;
265  }
266 }
267 
268 void Typemaker2_Define_SetItems(TYPEMAKER2_DEFINE *p_struct, const TYPEMAKER2_ITEM_LIST *p_src)
269 {
270  assert(p_struct);
271  if (p_struct->items) {
272  Typemaker2_Item_List_free(p_struct->items);
273  }
274  if (p_src) {
275  p_struct->items=Typemaker2_Item_List_dup(p_src);
276  }
277  else {
278  p_struct->items=Typemaker2_Item_List_new();
279  }
280 }
281 
283 {
284  assert(p_struct);
285  p_struct->mode=p_src;
286 }
287 
289 {
290  assert(p_struct);
291  p_struct->startValue=p_src;
292 }
293 
295 {
296  assert(p_struct);
297  p_struct->lastValue=p_src;
298 }
299 
300 TYPEMAKER2_DEFINE_LIST *Typemaker2_Define_List_dup(const TYPEMAKER2_DEFINE_LIST *p_src)
301 {
302  TYPEMAKER2_DEFINE_LIST *p_dest;
303  TYPEMAKER2_DEFINE *p_elem;
304 
305  assert(p_src);
306  p_dest=Typemaker2_Define_List_new();
307  p_elem=Typemaker2_Define_List_First(p_src);
308  while (p_elem) {
309  TYPEMAKER2_DEFINE *p_cpy;
310 
311  p_cpy=Typemaker2_Define_dup(p_elem);
312  Typemaker2_Define_List_Add(p_cpy, p_dest);
313  p_elem=Typemaker2_Define_List_Next(p_elem);
314  }
315 
316  return p_dest;
317 }
318 
320 {
321  assert(p_struct);
322  /* member "id" */
323  if (p_struct->id) {
324  free(p_struct->id);
325  }
326  {
327  const char *s;
328  s=GWEN_XMLNode_GetProperty(p_db, "id", NULL);
329  if (s)
330  p_struct->id=strdup(s);
331  }
332  if (p_struct->id==NULL) { /* member "id" is volatile, just presetting */
333  p_struct->id=NULL;
334  }
335 
336  /* member "prefix" */
337  if (p_struct->prefix) {
338  free(p_struct->prefix);
339  }
340  {
341  const char *s;
342  s=GWEN_XMLNode_GetProperty(p_db, "prefix", NULL);
343  if (s)
344  p_struct->prefix=strdup(s);
345  }
346  if (p_struct->prefix==NULL) { /* member "prefix" is volatile, just presetting */
347  p_struct->prefix=NULL;
348  }
349 
350  /* member "type" */
351  if (p_struct->type) {
352  free(p_struct->type);
353  }
354  {
355  const char *s;
356  s=GWEN_XMLNode_GetProperty(p_db, "type", NULL);
357  if (s)
358  p_struct->type=strdup(s);
359  }
360  if (p_struct->type==NULL) { /* member "type" is volatile, just presetting */
361  p_struct->type=NULL;
362  }
363 
364  /* member "items" */
365  if (p_struct->items) {
366  Typemaker2_Item_List_free(p_struct->items);
367  }
368  /* member "items" is volatile, just presetting */
369  p_struct->items=Typemaker2_Item_List_new();
370 
371  /* member "mode" */
372  {
373  const char *s;
374  s=GWEN_XMLNode_GetProperty(p_db, "mode", NULL);
375  if (s)
376  p_struct->mode=Typemaker2_Define_Mode_fromString(s);
377  else
378  p_struct->mode=Typemaker2_Define_Mode_Unknown;
379  }
380 
381  /* member "startValue" */
382  p_struct->startValue=GWEN_XMLNode_GetIntValue(p_db, "startValue", 0);
383 
384  /* member "lastValue" */
385  /* member "lastValue" is volatile, just presetting */
386  p_struct->lastValue=0;
387 
388 }
389 
391 {
392  assert(p_struct);
393  /* member "id" */
394  GWEN_XMLNode_SetProperty(p_db, "id", p_struct->id);
395 
396  /* member "prefix" */
397  GWEN_XMLNode_SetProperty(p_db, "prefix", p_struct->prefix);
398 
399  /* member "type" */
400  GWEN_XMLNode_SetProperty(p_db, "type", p_struct->type);
401 
402  /* member "items" is volatile, not writing to xml */
403 
404  /* member "mode" */
405  GWEN_XMLNode_SetProperty(p_db, "mode", Typemaker2_Define_Mode_toString(p_struct->mode));
406 
407  /* member "startValue" */
408  GWEN_XMLNode_SetIntValue(p_db, "startValue", p_struct->startValue);
409 
410  /* member "lastValue" is volatile, not writing to xml */
411 
412 }
413 
415 {
416  Typemaker2_Define_WriteXml(p_struct, p_db);
417 }
418 
420 {
421  TYPEMAKER2_DEFINE *p_struct;
422  p_struct=Typemaker2_Define_new();
423  Typemaker2_Define_ReadXml(p_struct, p_db);
424  return p_struct;
425 }
426 
427 
428 /* code headers */
429 
const char * Typemaker2_Define_Mode_toString(int p_i)
Definition: tm_define.c:34
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:239
void Typemaker2_Define_WriteXml(const TYPEMAKER2_DEFINE *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_define.c:390
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:300
void GWEN_XMLNode_SetProperty(GWEN_XMLNODE *n, const char *name, const char *value)
Definition: xml.c:322
void Typemaker2_Define_toXml(const TYPEMAKER2_DEFINE *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_define.c:414
TYPEMAKER2_DEFINE * Typemaker2_Define_dup(const TYPEMAKER2_DEFINE *p_src)
Definition: tm_define.c:78
TYPEMAKER2_DEFINE_LIST * Typemaker2_Define_List_dup(const TYPEMAKER2_DEFINE_LIST *p_src)
Definition: tm_define.c:300
struct TYPEMAKER2_DEFINE TYPEMAKER2_DEFINE
Definition: tm_define.h:24
const char * Typemaker2_Define_GetPrefix(const TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:190
int GWEN_XMLNode_GetIntValue(const GWEN_XMLNODE *n, const char *name, int defValue)
Definition: xml.c:923
void Typemaker2_Define_ReadXml(TYPEMAKER2_DEFINE *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_define.c:319
const char * Typemaker2_Define_GetId(const TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:184
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
int Typemaker2_Define_GetStartValue(const TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:214
void Typemaker2_Define_SetId(TYPEMAKER2_DEFINE *p_struct, const char *p_src)
Definition: tm_define.c:226
void Typemaker2_Define_SetType(TYPEMAKER2_DEFINE *p_struct, const char *p_src)
Definition: tm_define.c:254
void Typemaker2_Define_free(TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:65
int Typemaker2_Define_Mode_fromString(const char *p_s)
Definition: tm_define.c:23
TYPEMAKER2_ITEM_LIST * Typemaker2_Item_List_dup(const TYPEMAKER2_ITEM_LIST *p_src)
Definition: tm_item.c:141
void Typemaker2_Define_SetStartValue(TYPEMAKER2_DEFINE *p_struct, int p_src)
Definition: tm_define.c:288
TYPEMAKER2_ITEM_LIST * Typemaker2_Define_GetItems(const TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:202
int Typemaker2_Define_GetLastValue(const TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:220
const char * Typemaker2_Define_GetType(const TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:196
TYPEMAKER2_DEFINE * Typemaker2_Define_fromXml(GWEN_XMLNODE *p_db)
Definition: tm_define.c:419
void Typemaker2_Define_SetPrefix(TYPEMAKER2_DEFINE *p_struct, const char *p_src)
Definition: tm_define.c:240
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
void Typemaker2_Define_SetItems(TYPEMAKER2_DEFINE *p_struct, const TYPEMAKER2_ITEM_LIST *p_src)
Definition: tm_define.c:268
TYPEMAKER2_DEFINE * Typemaker2_Define_copy(TYPEMAKER2_DEFINE *p_struct, const TYPEMAKER2_DEFINE *p_src)
Definition: tm_define.c:132
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
void Typemaker2_Define_SetLastValue(TYPEMAKER2_DEFINE *p_struct, int p_src)
Definition: tm_define.c:294
TYPEMAKER2_DEFINE * Typemaker2_Define_new(void)
Definition: tm_define.c:46
void Typemaker2_Define_SetMode(TYPEMAKER2_DEFINE *p_struct, int p_src)
Definition: tm_define.c:282
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:156
int Typemaker2_Define_GetMode(const TYPEMAKER2_DEFINE *p_struct)
Definition: tm_define.c:208
void GWEN_XMLNode_SetIntValue(GWEN_XMLNODE *n, const char *name, int value)
Definition: xml.c:940