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