gwenhywfar  5.10.1
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 {
25  TYPEMAKER2_ENUM *p_struct;
26 
29  /* members */
30  p_struct->id=NULL;
31  p_struct->prefix=NULL;
32  p_struct->type=NULL;
33  p_struct->items=Typemaker2_Item_List_new();
34  p_struct->toStringFn=NULL;
35  p_struct->fromStringFn=NULL;
36  /* virtual functions */
37 
38  return p_struct;
39 }
40 
42 {
43  if (p_struct) {
45  /* members */
46  free(p_struct->id);
47  free(p_struct->prefix);
48  free(p_struct->type);
49  Typemaker2_Item_List_free(p_struct->items);
50  free(p_struct->toStringFn);
51  free(p_struct->fromStringFn);
52  GWEN_FREE_OBJECT(p_struct);
53  }
54 }
55 
57 {
58  TYPEMAKER2_ENUM *p_struct;
59 
60  assert(p_src);
61  p_struct=Typemaker2_Enum_new();
62  /* member "id" */
63  if (p_struct->id) {
64  free(p_struct->id);
65  p_struct->id=NULL;
66  }
67  if (p_src->id) {
68  p_struct->id=strdup(p_src->id);
69  }
70 
71  /* member "prefix" */
72  if (p_struct->prefix) {
73  free(p_struct->prefix);
74  p_struct->prefix=NULL;
75  }
76  if (p_src->prefix) {
77  p_struct->prefix=strdup(p_src->prefix);
78  }
79 
80  /* member "type" */
81  if (p_struct->type) {
82  free(p_struct->type);
83  p_struct->type=NULL;
84  }
85  if (p_src->type) {
86  p_struct->type=strdup(p_src->type);
87  }
88 
89  /* member "items" */
90  if (p_struct->items) {
91  Typemaker2_Item_List_free(p_struct->items);
92  p_struct->items=NULL;
93  }
94  if (p_src->items) {
95  p_struct->items=Typemaker2_Item_List_dup(p_src->items);
96  }
97 
98  /* member "toStringFn" */
99  if (p_struct->toStringFn) {
100  free(p_struct->toStringFn);
101  p_struct->toStringFn=NULL;
102  }
103  if (p_src->toStringFn) {
104  p_struct->toStringFn=strdup(p_src->toStringFn);
105  }
106 
107  /* member "fromStringFn" */
108  if (p_struct->fromStringFn) {
109  free(p_struct->fromStringFn);
110  p_struct->fromStringFn=NULL;
111  }
112  if (p_src->fromStringFn) {
113  p_struct->fromStringFn=strdup(p_src->fromStringFn);
114  }
115 
116  return p_struct;
117 }
118 
120 {
121  assert(p_struct);
122  assert(p_src);
123  /* member "id" */
124  if (p_struct->id) {
125  free(p_struct->id);
126  p_struct->id=NULL;
127  }
128  if (p_src->id) {
129  p_struct->id=strdup(p_src->id);
130  }
131 
132  /* member "prefix" */
133  if (p_struct->prefix) {
134  free(p_struct->prefix);
135  p_struct->prefix=NULL;
136  }
137  if (p_src->prefix) {
138  p_struct->prefix=strdup(p_src->prefix);
139  }
140 
141  /* member "type" */
142  if (p_struct->type) {
143  free(p_struct->type);
144  p_struct->type=NULL;
145  }
146  if (p_src->type) {
147  p_struct->type=strdup(p_src->type);
148  }
149 
150  /* member "items" */
151  if (p_struct->items) {
152  Typemaker2_Item_List_free(p_struct->items);
153  p_struct->items=NULL;
154  }
155  if (p_src->items) {
156  p_struct->items=Typemaker2_Item_List_dup(p_src->items);
157  }
158 
159  /* member "toStringFn" */
160  if (p_struct->toStringFn) {
161  free(p_struct->toStringFn);
162  p_struct->toStringFn=NULL;
163  }
164  if (p_src->toStringFn) {
165  p_struct->toStringFn=strdup(p_src->toStringFn);
166  }
167 
168  /* member "fromStringFn" */
169  if (p_struct->fromStringFn) {
170  free(p_struct->fromStringFn);
171  p_struct->fromStringFn=NULL;
172  }
173  if (p_src->fromStringFn) {
174  p_struct->fromStringFn=strdup(p_src->fromStringFn);
175  }
176 
177  return p_struct;
178 }
179 
180 const char *Typemaker2_Enum_GetId(const TYPEMAKER2_ENUM *p_struct)
181 {
182  assert(p_struct);
183  return p_struct->id;
184 }
185 
186 const char *Typemaker2_Enum_GetPrefix(const TYPEMAKER2_ENUM *p_struct)
187 {
188  assert(p_struct);
189  return p_struct->prefix;
190 }
191 
192 const char *Typemaker2_Enum_GetType(const TYPEMAKER2_ENUM *p_struct)
193 {
194  assert(p_struct);
195  return p_struct->type;
196 }
197 
198 TYPEMAKER2_ITEM_LIST *Typemaker2_Enum_GetItems(const TYPEMAKER2_ENUM *p_struct)
199 {
200  assert(p_struct);
201  return p_struct->items;
202 }
203 
204 const char *Typemaker2_Enum_GetToStringFn(const TYPEMAKER2_ENUM *p_struct)
205 {
206  assert(p_struct);
207  return p_struct->toStringFn;
208 }
209 
211 {
212  assert(p_struct);
213  return p_struct->fromStringFn;
214 }
215 
216 void Typemaker2_Enum_SetId(TYPEMAKER2_ENUM *p_struct, const char *p_src)
217 {
218  assert(p_struct);
219  if (p_struct->id) {
220  free(p_struct->id);
221  }
222  if (p_src) {
223  p_struct->id=strdup(p_src);
224  }
225  else {
226  p_struct->id=NULL;
227  }
228 }
229 
230 void Typemaker2_Enum_SetPrefix(TYPEMAKER2_ENUM *p_struct, const char *p_src)
231 {
232  assert(p_struct);
233  if (p_struct->prefix) {
234  free(p_struct->prefix);
235  }
236  if (p_src) {
237  p_struct->prefix=strdup(p_src);
238  }
239  else {
240  p_struct->prefix=NULL;
241  }
242 }
243 
244 void Typemaker2_Enum_SetType(TYPEMAKER2_ENUM *p_struct, const char *p_src)
245 {
246  assert(p_struct);
247  if (p_struct->type) {
248  free(p_struct->type);
249  }
250  if (p_src) {
251  p_struct->type=strdup(p_src);
252  }
253  else {
254  p_struct->type=NULL;
255  }
256 }
257 
258 void Typemaker2_Enum_SetItems(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ITEM_LIST *p_src)
259 {
260  assert(p_struct);
261  if (p_struct->items) {
262  Typemaker2_Item_List_free(p_struct->items);
263  }
264  if (p_src) {
265  p_struct->items=Typemaker2_Item_List_dup(p_src);
266  }
267  else {
268  p_struct->items=Typemaker2_Item_List_new();
269  }
270 }
271 
272 void Typemaker2_Enum_SetToStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src)
273 {
274  assert(p_struct);
275  if (p_struct->toStringFn) {
276  free(p_struct->toStringFn);
277  }
278  if (p_src) {
279  p_struct->toStringFn=strdup(p_src);
280  }
281  else {
282  p_struct->toStringFn=NULL;
283  }
284 }
285 
286 void Typemaker2_Enum_SetFromStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src)
287 {
288  assert(p_struct);
289  if (p_struct->fromStringFn) {
290  free(p_struct->fromStringFn);
291  }
292  if (p_src) {
293  p_struct->fromStringFn=strdup(p_src);
294  }
295  else {
296  p_struct->fromStringFn=NULL;
297  }
298 }
299 
300 TYPEMAKER2_ENUM_LIST *Typemaker2_Enum_List_dup(const TYPEMAKER2_ENUM_LIST *p_src)
301 {
302  TYPEMAKER2_ENUM_LIST *p_dest;
303  TYPEMAKER2_ENUM *p_elem;
304 
305  assert(p_src);
306  p_dest=Typemaker2_Enum_List_new();
307  p_elem=Typemaker2_Enum_List_First(p_src);
308  while (p_elem) {
309  TYPEMAKER2_ENUM *p_cpy;
310 
311  p_cpy=Typemaker2_Enum_dup(p_elem);
312  Typemaker2_Enum_List_Add(p_cpy, p_dest);
313  p_elem=Typemaker2_Enum_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 "toStringFn" */
372  if (p_struct->toStringFn) {
373  free(p_struct->toStringFn);
374  }
375  /* member "toStringFn" is volatile, just presetting */
376  p_struct->toStringFn=NULL;
377 
378  /* member "fromStringFn" */
379  if (p_struct->fromStringFn) {
380  free(p_struct->fromStringFn);
381  }
382  /* member "fromStringFn" is volatile, just presetting */
383  p_struct->fromStringFn=NULL;
384 
385 }
386 
388 {
389  assert(p_struct);
390  /* member "id" */
391  GWEN_XMLNode_SetProperty(p_db, "id", p_struct->id);
392 
393  /* member "prefix" */
394  GWEN_XMLNode_SetProperty(p_db, "prefix", p_struct->prefix);
395 
396  /* member "type" */
397  GWEN_XMLNode_SetProperty(p_db, "type", p_struct->type);
398 
399  /* member "items" is volatile, not writing to xml */
400 
401  /* member "toStringFn" is volatile, not writing to xml */
402 
403  /* member "fromStringFn" is volatile, not writing to xml */
404 
405 }
406 
408 {
409  Typemaker2_Enum_WriteXml(p_struct, p_db);
410 }
411 
413 {
414  TYPEMAKER2_ENUM *p_struct;
415  p_struct=Typemaker2_Enum_new();
416  Typemaker2_Enum_ReadXml(p_struct, p_db);
417  return p_struct;
418 }
419 
420 
421 /* code headers */
422 
void Typemaker2_Enum_WriteXml(const TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_enum.c:387
const char * Typemaker2_Enum_GetFromStringFn(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:210
TYPEMAKER2_ITEM_LIST * Typemaker2_Enum_GetItems(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:198
TYPEMAKER2_ENUM * Typemaker2_Enum_fromXml(GWEN_XMLNODE *p_db)
Definition: tm_enum.c:412
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:239
TYPEMAKER2_ENUM_LIST * Typemaker2_Enum_List_dup(const TYPEMAKER2_ENUM_LIST *p_src)
Definition: tm_enum.c:300
TYPEMAKER2_ENUM * Typemaker2_Enum_dup(const TYPEMAKER2_ENUM *p_src)
Definition: tm_enum.c:56
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:300
void Typemaker2_Enum_ReadXml(TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_enum.c:319
void GWEN_XMLNode_SetProperty(GWEN_XMLNODE *n, const char *name, const char *value)
Definition: xml.c:322
TYPEMAKER2_ENUM * Typemaker2_Enum_copy(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ENUM *p_src)
Definition: tm_enum.c:119
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:286
void Typemaker2_Enum_toXml(const TYPEMAKER2_ENUM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_enum.c:407
void Typemaker2_Enum_SetItems(TYPEMAKER2_ENUM *p_struct, const TYPEMAKER2_ITEM_LIST *p_src)
Definition: tm_enum.c:258
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:180
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
void Typemaker2_Enum_SetType(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:244
void Typemaker2_Enum_free(TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:41
TYPEMAKER2_ITEM_LIST * Typemaker2_Item_List_dup(const TYPEMAKER2_ITEM_LIST *p_src)
Definition: tm_item.c:141
const char * Typemaker2_Enum_GetPrefix(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:186
void Typemaker2_Enum_SetPrefix(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:230
void Typemaker2_Enum_SetId(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:216
void Typemaker2_Enum_SetToStringFn(TYPEMAKER2_ENUM *p_struct, const char *p_src)
Definition: tm_enum.c:272
#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:204
const char * Typemaker2_Enum_GetType(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:192
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:156