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