gwenhywfar  4.99.8beta
test.c
Go to the documentation of this file.
1 /**********************************************************
2  * This file has been automatically created by "typemaker2"
3  * from the file "test.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 "test_p.h"
13 
14 #include <gwenhywfar/misc.h>
15 #include <gwenhywfar/debug.h>
16 
17 /* code headers */
18 
19 /* macro functions */
21 
22 
23 int Test_Mode_fromString(const char *p_s) {
24  if (p_s && *p_s) {
25  if (strcasecmp(p_s, "sequence")==0)
26  return Test_Mode_Sequence;
27  else if (strcasecmp(p_s, "bitField")==0)
28  return Test_Mode_BitField;
29  }
30  return Test_Mode_Unknown;
31 }
32 
33 const char *Test_Mode_toString(int p_i) {
34  switch(p_i) {
35  case Test_Mode_Sequence: return "sequence";
36  case Test_Mode_BitField: return "bitField";
37  default: return "unknown";
38  }
39 }
40 
42  TEST *p_struct;
43 
44  GWEN_NEW_OBJECT(TEST, p_struct)
45  GWEN_LIST_INIT(TEST, p_struct)
46  /* members */
47  p_struct->id=NULL;
48  p_struct->prefix=NULL;
49  p_struct->type=NULL;
50 
51 
52 
53  return p_struct;
54 }
55 
56 void Test_free(TEST *p_struct) {
57  if (p_struct) {
58  GWEN_LIST_FINI(TEST, p_struct)
59  /* members */
60  free(p_struct->id);
61  free(p_struct->prefix);
62  free(p_struct->type);
63 
64 
65  GWEN_FREE_OBJECT(p_struct);
66  }
67 }
68 
69 TEST *Test_dup(const TEST *p_src) {
70  TEST *p_struct;
71 
72  assert(p_src);
73  p_struct=Test_new();
74  /* member "id" */
75  if (p_struct->id) {
76  free(p_struct->id);
77  p_struct->id=NULL;
78  }
79  if (p_src->id) {
80  p_struct->id=strdup(p_src->id);
81  }
82 
83  /* member "prefix" */
84  if (p_struct->prefix) {
85  free(p_struct->prefix);
86  p_struct->prefix=NULL;
87  }
88  if (p_src->prefix) {
89  p_struct->prefix=strdup(p_src->prefix);
90  }
91 
92  /* member "type" */
93  if (p_struct->type) {
94  free(p_struct->type);
95  p_struct->type=NULL;
96  }
97  if (p_src->type) {
98  p_struct->type=strdup(p_src->type);
99  }
100 
101  /* member "items" */
102  if (p_struct->items) {
103 
104  p_struct->items=NULL;
105  }
106  if (p_src->items) {
107 
108  }
109 
110  /* member "mode" */
111 
112 
113  return p_struct;
114 }
115 
116 const char *Test_GetId(const TEST *p_struct) {
117  assert(p_struct);
118  return p_struct->id;
119 }
120 
121 const char *Test_GetPrefix(const TEST *p_struct) {
122  assert(p_struct);
123  return p_struct->prefix;
124 }
125 
126 const char *Test_GetType(const TEST *p_struct) {
127  assert(p_struct);
128  return p_struct->type;
129 }
130 
131 TYPEMAKER2_ITEM_LIST *Test_GetItems(const TEST *p_struct) {
132  assert(p_struct);
133  return p_struct->items;
134 }
135 
136 int Test_GetMode(const TEST *p_struct) {
137  assert(p_struct);
138  return p_struct->mode;
139 }
140 
141 void Test_SetId(TEST *p_struct, const char *p_src) {
142  assert(p_struct);
143  if (p_struct->id) {
144  free(p_struct->id);
145  }
146  if (p_src) {
147  p_struct->id=strdup(p_src);
148  }
149  else {
150  p_struct->id=NULL;
151  }
152 }
153 
154 void Test_SetPrefix(TEST *p_struct, const char *p_src) {
155  assert(p_struct);
156  if (p_struct->prefix) {
157  free(p_struct->prefix);
158  }
159  if (p_src) {
160  p_struct->prefix=strdup(p_src);
161  }
162  else {
163  p_struct->prefix=NULL;
164  }
165 }
166 
167 void Test_SetType(TEST *p_struct, const char *p_src) {
168  assert(p_struct);
169  if (p_struct->type) {
170  free(p_struct->type);
171  }
172  if (p_src) {
173  p_struct->type=strdup(p_src);
174  }
175  else {
176  p_struct->type=NULL;
177  }
178 }
179 
180 void Test_SetItems(TEST *p_struct, const TYPEMAKER2_ITEM_LIST *p_src) {
181  assert(p_struct);
182  if (p_struct->items) {
183 
184  }
185  if (p_src) {
186 
187  }
188  else {
189 
190  }
191 }
192 
193 void Test_SetMode(TEST *p_struct, int p_src) {
194  assert(p_struct);
195 
196 }
197 
198 void Test_ReadXml(TEST *p_struct, GWEN_XMLNODE *p_db) {
199  assert(p_struct);
200  /* member "id" */
201  if (p_struct->id) {
202  free(p_struct->id);
203  }
204  p_struct->id=NULL;
205  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "id", NULL); if (s) p_struct->id=strdup(s); }
206 
207  /* member "prefix" */
208  if (p_struct->prefix) {
209  free(p_struct->prefix);
210  }
211  p_struct->prefix=NULL;
212  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "prefix", NULL); if (s) p_struct->prefix=strdup(s); }
213 
214  /* member "type" */
215  if (p_struct->type) {
216  free(p_struct->type);
217  }
218  p_struct->type=NULL;
219  { const char *s; s=GWEN_XMLNode_GetProperty(p_db, "type", NULL); if (s) p_struct->type=strdup(s); }
220 
221  /* member "items" */
222  if (p_struct->items) {
223 
224  }
225 
226  /* member "items" is volatile, not reading from xml */
227 
228  /* member "mode" */
229 
230 
231 
232 }
233 
234 void Test_WriteXml(const TEST *p_struct, GWEN_XMLNODE *p_db) {
235  assert(p_struct);
236  /* member "id" */
237  GWEN_XMLNode_SetProperty(p_db, "id", p_struct->id);
238 
239  /* member "prefix" */
240  GWEN_XMLNode_SetProperty(p_db, "prefix", p_struct->prefix);
241 
242  /* member "type" */
243  GWEN_XMLNode_SetProperty(p_db, "type", p_struct->type);
244 
245  /* member "items" is volatile, not writing to xml */
246 
247  /* member "mode" */
248 
249 
250 }
251 
252 void Test_toXml(const TEST *p_struct, GWEN_XMLNODE *p_db) {
253  Test_WriteXml(p_struct, p_db);
254 }
255 
257  TEST *p_struct;
258  p_struct=Test_new();
259  Test_ReadXml(p_struct, p_db);
260  return p_struct;
261 }
262 
const char * Test_Mode_toString(int p_i)
Definition: test.c:33
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:228
struct TEST TEST
Definition: test.h:32
int Test_GetMode(const TEST *p_struct)
Definition: test.c:136
const char * Test_GetPrefix(const TEST *p_struct)
Definition: test.c:121
void Test_SetPrefix(TEST *p_struct, const char *p_src)
Definition: test.c:154
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define NULL
Definition: binreloc.c:290
void Test_SetMode(TEST *p_struct, int p_src)
Definition: test.c:193
const char * Test_GetId(const TEST *p_struct)
Definition: test.c:116
void GWEN_XMLNode_SetProperty(GWEN_XMLNODE *n, const char *name, const char *value)
Definition: xml.c:308
void Test_SetType(TEST *p_struct, const char *p_src)
Definition: test.c:167
int Test_Mode_fromString(const char *p_s)
Definition: test.c:23
TEST * Test_new()
Definition: test.c:41
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:86
const char * Test_GetType(const TEST *p_struct)
Definition: test.c:126
void Test_ReadXml(TEST *p_struct, GWEN_XMLNODE *p_db)
Definition: test.c:198
void Test_free(TEST *p_struct)
Definition: test.c:56
void Test_SetItems(TEST *p_struct, const TYPEMAKER2_ITEM_LIST *p_src)
Definition: test.c:180
void Test_SetId(TEST *p_struct, const char *p_src)
Definition: test.c:141
TEST * Test_dup(const TEST *p_src)
Definition: test.c:69
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
void Test_toXml(const TEST *p_struct, GWEN_XMLNODE *p_db)
Definition: test.c:252
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
TEST * Test_fromXml(GWEN_XMLNODE *p_db)
Definition: test.c:256
TYPEMAKER2_ITEM_LIST * Test_GetItems(const TEST *p_struct)
Definition: test.c:131
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:148
void Test_WriteXml(const TEST *p_struct, GWEN_XMLNODE *p_db)
Definition: test.c:234