gwenhywfar  4.99.8beta
tm_enum.c
Go to the documentation of this file.
1 /**********************************************************
2  * This file has been automatically created by "typemaker2"
3  * from the file "tm_enum.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_enum_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_ENUM, Typemaker2_Enum)
21 
22 
24  TYPEMAKER2_ENUM *p_struct;
25 
28  /* members */
29  p_struct->id=NULL;
30  p_struct->prefix=NULL;
31  p_struct->type=NULL;
32  p_struct->items=Typemaker2_Item_List_new();
33  p_struct->toStringFn=NULL;
34  p_struct->fromStringFn=NULL;
35  /* virtual functions */
36 
37  return p_struct;
38 }
39 
41  if (p_struct) {
43  /* members */
44  free(p_struct->id);
45  free(p_struct->prefix);
46  free(p_struct->type);
47  Typemaker2_Item_List_free(p_struct->items);
48  free(p_struct->toStringFn);
49  free(p_struct->fromStringFn);
50  GWEN_FREE_OBJECT(p_struct);
51  }
52 }
53 
55  TYPEMAKER2_ENUM *p_struct;
56 
57  assert(p_src);
58  p_struct=Typemaker2_Enum_new();
59  /* member "id" */
60  if (p_struct->id) {
61  free(p_struct->id);
62  p_struct->id=NULL;
63  }
64  if (p_src->id) {
65  p_struct->id=strdup(p_src->id);
66  }
67 
68  /* member "prefix" */
69  if (p_struct->prefix) {
70  free(p_struct->prefix);
71  p_struct->prefix=NULL;
72  }
73  if (p_src->prefix) {
74  p_struct->prefix=strdup(p_src->prefix);
75  }
76 
77  /* member "type" */
78  if (p_struct->type) {
79  free(p_struct->type);
80  p_struct->type=NULL;
81  }
82  if (p_src->type) {
83  p_struct->type=strdup(p_src->type);
84  }
85 
86  /* member "items" */
87  if (p_struct->items) {
88  Typemaker2_Item_List_free(p_struct->items);
89  p_struct->items=NULL;
90  }
91  if (p_src->items) {
92  p_struct->items=Typemaker2_Item_List_dup(p_src->items);
93  }
94 
95  /* member "toStringFn" */
96  if (p_struct->toStringFn) {
97  free(p_struct->toStringFn);
98  p_struct->toStringFn=NULL;
99  }
100  if (p_src->toStringFn) {
101  p_struct->toStringFn=strdup(p_src->toStringFn);
102  }
103 
104  /* member "fromStringFn" */
105  if (p_struct->fromStringFn) {
106  free(p_struct->fromStringFn);
107  p_struct->fromStringFn=NULL;
108  }
109  if (p_src->fromStringFn) {
110  p_struct->fromStringFn=strdup(p_src->fromStringFn);
111  }
112 
113  return p_struct;
114 }
115 
117  assert(p_struct);
118  assert(p_src);
119  /* member "id" */
120  if (p_struct->id) {
121  free(p_struct->id);
122  p_struct->id=NULL;
123  }
124  if (p_src->id) {
125  p_struct->id=strdup(p_src->id);
126  }
127 
128  /* member "prefix" */
129  if (p_struct->prefix) {
130  free(p_struct->prefix);
131  p_struct->prefix=NULL;
132  }
133  if (p_src->prefix) {
134  p_struct->prefix=strdup(p_src->prefix);
135  }
136 
137  /* member "type" */
138  if (p_struct->type) {
139  free(p_struct->type);
140  p_struct->type=NULL;
141  }
142  if (p_src->type) {
143  p_struct->type=strdup(p_src->type);
144  }
145 
146  /* member "items" */
147  if (p_struct->items) {
148  Typemaker2_Item_List_free(p_struct->items);
149  p_struct->items=NULL;
150  }
151  if (p_src->items) {
152  p_struct->items=Typemaker2_Item_List_dup(p_src->items);
153  }
154 
155  /* member "toStringFn" */
156  if (p_struct->toStringFn) {
157  free(p_struct->toStringFn);
158  p_struct->toStringFn=NULL;
159  }
160  if (p_src->toStringFn) {
161  p_struct->toStringFn=strdup(p_src->toStringFn);
162  }
163 
164  /* member "fromStringFn" */
165  if (p_struct->fromStringFn) {
166  free(p_struct->fromStringFn);
167  p_struct->fromStringFn=NULL;
168  }
169  if (p_src->fromStringFn) {
170  p_struct->fromStringFn=strdup(p_src->fromStringFn);
171  }
172 
173  return p_struct;
174 }
175 
176 const char *Typemaker2_Enum_GetId(const TYPEMAKER2_ENUM *p_struct) {
177  assert(p_struct);
178  return p_struct->id;
179 }
180 
181 const char *Typemaker2_Enum_GetPrefix(const TYPEMAKER2_ENUM *p_struct) {
182  assert(p_struct);
183  return p_struct->prefix;
184 }
185 
186 const char *Typemaker2_Enum_GetType(const TYPEMAKER2_ENUM *p_struct) {
187  assert(p_struct);
188  return p_struct->type;
189 }
190 
191 TYPEMAKER2_ITEM_LIST *Typemaker2_Enum_GetItems(const TYPEMAKER2_ENUM *p_struct) {
192  assert(p_struct);
193  return p_struct->items;
194 }
195 
196 const char *Typemaker2_Enum_GetToStringFn(const TYPEMAKER2_ENUM *p_struct) {
197  assert(p_struct);
198  return p_struct->toStringFn;
199 }
200 
201 const char *Typemaker2_Enum_GetFromStringFn(const TYPEMAKER2_ENUM *p_struct) {
202  assert(p_struct);
203  return p_struct->fromStringFn;
204 }
205 
206 void Typemaker2_Enum_SetId(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
207  assert(p_struct);
208  if (p_struct->id) {
209  free(p_struct->id);
210  }
211  if (p_src) {
212  p_struct->id=strdup(p_src);
213  }
214  else {
215  p_struct->id=NULL;
216  }
217 }
218 
219 void Typemaker2_Enum_SetPrefix(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
220  assert(p_struct);
221  if (p_struct->prefix) {
222  free(p_struct->prefix);
223  }
224  if (p_src) {
225  p_struct->prefix=strdup(p_src);
226  }
227  else {
228  p_struct->prefix=NULL;
229  }
230 }
231 
232 void Typemaker2_Enum_SetType(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
233  assert(p_struct);
234  if (p_struct->type) {
235  free(p_struct->type);
236  }
237  if (p_src) {
238  p_struct->type=strdup(p_src);
239  }
240  else {
241  p_struct->type=NULL;
242  }
243 }
244 
245 void Typemaker2_Enum_SetItems(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ITEM_LIST *p_src) {
246  assert(p_struct);
247  if (p_struct->items) {
248  Typemaker2_Item_List_free(p_struct->items);
249  }
250  if (p_src) {
251  p_struct->items=Typemaker2_Item_List_dup(p_src);
252  }
253  else {
254  p_struct->items=Typemaker2_Item_List_new();
255  }
256 }
257 
258 void Typemaker2_Enum_SetToStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
259  assert(p_struct);
260  if (p_struct->toStringFn) {
261  free(p_struct->toStringFn);
262  }
263  if (p_src) {
264  p_struct->toStringFn=strdup(p_src);
265  }
266  else {
267  p_struct->toStringFn=NULL;
268  }
269 }
270 
271 void Typemaker2_Enum_SetFromStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src) {
272  assert(p_struct);
273  if (p_struct->fromStringFn) {
274  free(p_struct->fromStringFn);
275  }
276  if (p_src) {
277  p_struct->fromStringFn=strdup(p_src);
278  }
279  else {
280  p_struct->fromStringFn=NULL;
281  }
282 }
283 
284 TYPEMAKER2_ENUM_LIST *Typemaker2_Enum_List_dup(const TYPEMAKER2_ENUM_LIST *p_src) {
285  TYPEMAKER2_ENUM_LIST *p_dest;
286  TYPEMAKER2_ENUM *p_elem;
287 
288  assert(p_src);
289  p_dest=Typemaker2_Enum_List_new();
290  p_elem=Typemaker2_Enum_List_First(p_src);
291  while(p_elem) {
292  TYPEMAKER2_ENUM *p_cpy;
293 
294  p_cpy=Typemaker2_Enum_dup(p_elem);
295  Typemaker2_Enum_List_Add(p_cpy, p_dest);
296  p_elem=Typemaker2_Enum_List_Next(p_elem);
297  }
298 
299  return p_dest;
300 }
301 
303  assert(p_struct);
304  /* member "id" */
305  if (p_struct->id) {
306  free(p_struct->id);
307  }
308  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "id", NULL); if (s) p_struct->id=strdup(s); }
309  if (p_struct->id==NULL) { /* member "id" is volatile, just presetting */
310  p_struct->id=NULL;
311  }
312 
313  /* member "prefix" */
314  if (p_struct->prefix) {
315  free(p_struct->prefix);
316  }
317  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "prefix", NULL); if (s) p_struct->prefix=strdup(s); }
318  if (p_struct->prefix==NULL) { /* member "prefix" is volatile, just presetting */
319  p_struct->prefix=NULL;
320  }
321 
322  /* member "type" */
323  if (p_struct->type) {
324  free(p_struct->type);
325  }
326  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "type", NULL); if (s) p_struct->type=strdup(s); }
327  if (p_struct->type==NULL) { /* member "type" is volatile, just presetting */
328  p_struct->type=NULL;
329  }
330 
331  /* member "items" */
332  if (p_struct->items) {
333  Typemaker2_Item_List_free(p_struct->items);
334  }
335  /* member "items" is volatile, just presetting */
336  p_struct->items=Typemaker2_Item_List_new();
337 
338  /* member "toStringFn" */
339  if (p_struct->toStringFn) {
340  free(p_struct->toStringFn);
341  }
342  /* member "toStringFn" is volatile, just presetting */
343  p_struct->toStringFn=NULL;
344 
345  /* member "fromStringFn" */
346  if (p_struct->fromStringFn) {
347  free(p_struct->fromStringFn);
348  }
349  /* member "fromStringFn" is volatile, just presetting */
350  p_struct->fromStringFn=NULL;
351 
352 }
353 
355  assert(p_struct);
356  /* member "id" */
357  GWEN_XMLNode_SetProperty(p_db, "id", p_struct->id);
358 
359  /* member "prefix" */
360  GWEN_XMLNode_SetProperty(p_db, "prefix", p_struct->prefix);
361 
362  /* member "type" */
363  GWEN_XMLNode_SetProperty(p_db, "type", p_struct->type);
364 
365  /* member "items" is volatile, not writing to xml */
366 
367  /* member "toStringFn" is volatile, not writing to xml */
368 
369  /* member "fromStringFn" is volatile, not writing to xml */
370 
371 }
372 
373 void Typemaker2_Enum_toXml(const TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db) {
374  Typemaker2_Enum_WriteXml(p_struct, p_db);
375 }
376 
378  TYPEMAKER2_ENUM *p_struct;
379  p_struct=Typemaker2_Enum_new();
380  Typemaker2_Enum_ReadXml(p_struct, p_db);
381  return p_struct;
382 }
383 
384 
385 /* code headers */
386 
void Typemaker2_Enum_WriteXml(const TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_enum.c:354
const char * Typemaker2_Enum_GetFromStringFn(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:201
TYPEMAKER2_ITEM_LIST * Typemaker2_Enum_GetItems(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:191
TYPEMAKER2_ENUM * Typemaker2_Enum_fromXml(GWEN_XMLNODE *p_db)
Definition: tm_enum.c:377
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:228
TYPEMAKER2_ENUM_LIST * Typemaker2_Enum_List_dup(const TYPEMAKER2_ENUM_LIST *p_src)
Definition: tm_enum.c:284
TYPEMAKER2_ENUM * Typemaker2_Enum_dup(const TYPEMAKER2_ENUM *p_src)
Definition: tm_enum.c:54
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define NULL
Definition: binreloc.c:290
void Typemaker2_Enum_ReadXml(TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_enum.c:302
void GWEN_XMLNode_SetProperty(GWEN_XMLNODE *n, const char *name, const char *value)
Definition: xml.c:308
TYPEMAKER2_ENUM * Typemaker2_Enum_copy(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ENUM *p_src)
Definition: tm_enum.c:116
struct TYPEMAKER2_ENUM TYPEMAKER2_ENUM
Definition: tm_enum.h:24
void Typemaker2_Enum_SetFromStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:271
void Typemaker2_Enum_toXml(const TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_enum.c:373
void Typemaker2_Enum_SetItems(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ITEM_LIST *p_src)
Definition: tm_enum.c:245
TYPEMAKER2_ENUM * Typemaker2_Enum_new(void)
Definition: tm_enum.c:23
const char * Typemaker2_Enum_GetId(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:176
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:86
void Typemaker2_Enum_SetType(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:232
void Typemaker2_Enum_free(TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:40
TYPEMAKER2_ITEM_LIST * Typemaker2_Item_List_dup(const TYPEMAKER2_ITEM_LIST *p_src)
Definition: tm_item.c:133
const char * Typemaker2_Enum_GetPrefix(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:181
void Typemaker2_Enum_SetPrefix(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:219
void Typemaker2_Enum_SetId(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:206
void Typemaker2_Enum_SetToStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:258
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
const char * Typemaker2_Enum_GetToStringFn(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:196
const char * Typemaker2_Enum_GetType(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:186
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:148