gwenhywfar  5.10.1
tm_item.c
Go to the documentation of this file.
1 /**********************************************************
2  * This file has been automatically created by "typemaker2"
3  * from the file "tm_item.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_item_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_ITEM, Typemaker2_Item)
21 GWEN_LIST2_FUNCTIONS(TYPEMAKER2_ITEM, Typemaker2_Item)
22 
23 
25 {
26  TYPEMAKER2_ITEM *p_struct;
27 
30  /* members */
31  p_struct->name=NULL;
32  p_struct->value=NULL;
33  /* virtual functions */
34 
35  return p_struct;
36 }
37 
39 {
40  if (p_struct) {
42  /* members */
43  free(p_struct->name);
44  free(p_struct->value);
45  GWEN_FREE_OBJECT(p_struct);
46  }
47 }
48 
50 {
51  TYPEMAKER2_ITEM *p_struct;
52 
53  assert(p_src);
54  p_struct=Typemaker2_Item_new();
55  /* member "name" */
56  if (p_struct->name) {
57  free(p_struct->name);
58  p_struct->name=NULL;
59  }
60  if (p_src->name) {
61  p_struct->name=strdup(p_src->name);
62  }
63 
64  /* member "value" */
65  if (p_struct->value) {
66  free(p_struct->value);
67  p_struct->value=NULL;
68  }
69  if (p_src->value) {
70  p_struct->value=strdup(p_src->value);
71  }
72 
73  return p_struct;
74 }
75 
77 {
78  assert(p_struct);
79  assert(p_src);
80  /* member "name" */
81  if (p_struct->name) {
82  free(p_struct->name);
83  p_struct->name=NULL;
84  }
85  if (p_src->name) {
86  p_struct->name=strdup(p_src->name);
87  }
88 
89  /* member "value" */
90  if (p_struct->value) {
91  free(p_struct->value);
92  p_struct->value=NULL;
93  }
94  if (p_src->value) {
95  p_struct->value=strdup(p_src->value);
96  }
97 
98  return p_struct;
99 }
100 
101 const char *Typemaker2_Item_GetName(const TYPEMAKER2_ITEM *p_struct)
102 {
103  assert(p_struct);
104  return p_struct->name;
105 }
106 
107 const char *Typemaker2_Item_GetValue(const TYPEMAKER2_ITEM *p_struct)
108 {
109  assert(p_struct);
110  return p_struct->value;
111 }
112 
113 void Typemaker2_Item_SetName(TYPEMAKER2_ITEM *p_struct, const char *p_src)
114 {
115  assert(p_struct);
116  if (p_struct->name) {
117  free(p_struct->name);
118  }
119  if (p_src) {
120  p_struct->name=strdup(p_src);
121  }
122  else {
123  p_struct->name=NULL;
124  }
125 }
126 
127 void Typemaker2_Item_SetValue(TYPEMAKER2_ITEM *p_struct, const char *p_src)
128 {
129  assert(p_struct);
130  if (p_struct->value) {
131  free(p_struct->value);
132  }
133  if (p_src) {
134  p_struct->value=strdup(p_src);
135  }
136  else {
137  p_struct->value=NULL;
138  }
139 }
140 
141 TYPEMAKER2_ITEM_LIST *Typemaker2_Item_List_dup(const TYPEMAKER2_ITEM_LIST *p_src)
142 {
143  TYPEMAKER2_ITEM_LIST *p_dest;
144  TYPEMAKER2_ITEM *p_elem;
145 
146  assert(p_src);
147  p_dest=Typemaker2_Item_List_new();
148  p_elem=Typemaker2_Item_List_First(p_src);
149  while (p_elem) {
150  TYPEMAKER2_ITEM *p_cpy;
151 
152  p_cpy=Typemaker2_Item_dup(p_elem);
153  Typemaker2_Item_List_Add(p_cpy, p_dest);
154  p_elem=Typemaker2_Item_List_Next(p_elem);
155  }
156 
157  return p_dest;
158 }
159 
161 {
162  assert(p_struct);
163  /* member "name" */
164  if (p_struct->name) {
165  free(p_struct->name);
166  }
167  {
168  const char *s;
169  s=GWEN_XMLNode_GetProperty(p_db, "name", NULL);
170  if (s)
171  p_struct->name=strdup(s);
172  }
173  if (p_struct->name==NULL) { /* member "name" is volatile, just presetting */
174  p_struct->name=NULL;
175  }
176 
177  /* member "value" */
178  if (p_struct->value) {
179  free(p_struct->value);
180  }
181  {
182  const char *s;
183  s=GWEN_XMLNode_GetProperty(p_db, "value", NULL);
184  if (s)
185  p_struct->value=strdup(s);
186  }
187  if (p_struct->value==NULL) { /* member "value" is volatile, just presetting */
188  p_struct->value=NULL;
189  }
190 
191 }
192 
194 {
195  assert(p_struct);
196  /* member "name" */
197  GWEN_XMLNode_SetProperty(p_db, "name", p_struct->name);
198 
199  /* member "value" */
200  GWEN_XMLNode_SetProperty(p_db, "value", p_struct->value);
201 
202 }
203 
205 {
206  Typemaker2_Item_WriteXml(p_struct, p_db);
207 }
208 
210 {
211  TYPEMAKER2_ITEM *p_struct;
212  p_struct=Typemaker2_Item_new();
213  Typemaker2_Item_ReadXml(p_struct, p_db);
214  return p_struct;
215 }
216 
217 
218 /* code headers */
219 
const char * Typemaker2_Item_GetName(const TYPEMAKER2_ITEM *p_struct)
Definition: tm_item.c:101
#define GWEN_LIST2_FUNCTIONS(t, pr)
Definition: list2.h:99
void Typemaker2_Item_ReadXml(TYPEMAKER2_ITEM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_item.c:160
const char * GWEN_XMLNode_GetProperty(const GWEN_XMLNODE *n, const char *name, const char *defaultValue)
Definition: xml.c:239
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:300
void GWEN_XMLNode_SetProperty(GWEN_XMLNODE *n, const char *name, const char *value)
Definition: xml.c:322
void Typemaker2_Item_toXml(const TYPEMAKER2_ITEM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_item.c:204
struct TYPEMAKER2_ITEM TYPEMAKER2_ITEM
Definition: tm_item.h:22
const char * Typemaker2_Item_GetValue(const TYPEMAKER2_ITEM *p_struct)
Definition: tm_item.c:107
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
TYPEMAKER2_ITEM * Typemaker2_Item_fromXml(GWEN_XMLNODE *p_db)
Definition: tm_item.c:209
TYPEMAKER2_ITEM_LIST * Typemaker2_Item_List_dup(const TYPEMAKER2_ITEM_LIST *p_src)
Definition: tm_item.c:141
TYPEMAKER2_ITEM * Typemaker2_Item_copy(TYPEMAKER2_ITEM *p_struct, const TYPEMAKER2_ITEM *p_src)
Definition: tm_item.c:76
void Typemaker2_Item_SetValue(TYPEMAKER2_ITEM *p_struct, const char *p_src)
Definition: tm_item.c:127
void Typemaker2_Item_WriteXml(const TYPEMAKER2_ITEM *p_struct, GWEN_XMLNODE *p_db)
Definition: tm_item.c:193
TYPEMAKER2_ITEM * Typemaker2_Item_dup(const TYPEMAKER2_ITEM *p_src)
Definition: tm_item.c:49
void Typemaker2_Item_SetName(TYPEMAKER2_ITEM *p_struct, const char *p_src)
Definition: tm_item.c:113
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
TYPEMAKER2_ITEM * Typemaker2_Item_new(void)
Definition: tm_item.c:24
void Typemaker2_Item_free(TYPEMAKER2_ITEM *p_struct)
Definition: tm_item.c:38
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:156