gwenhywfar  4.6.0beta
xsdnode.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Wed Feb 27 2008
3  copyright : (C) 2008 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * Lesser General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU Lesser General Public *
19  * License along with this library; if not, write to the Free Software *
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21  * MA 02111-1307 USA *
22  * *
23  ***************************************************************************/
24 
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 
29 
30 #include "xsdnode_p.h"
31 
32 #include <gwenhywfar/debug.h>
33 #include <gwenhywfar/misc.h>
34 
35 #include <stdlib.h>
36 #include <assert.h>
37 #include <string.h>
38 #include <ctype.h>
39 
40 
43 
44 
45 
46 GWEN_XSD_NODE *GWEN_XsdNode_new(GWEN_XSD_NODE *parent,
48  const char *name) {
49  GWEN_XSD_NODE *xsdNode;
50 
51  GWEN_NEW_OBJECT(GWEN_XSD_NODE, xsdNode);
52  GWEN_INHERIT_INIT(GWEN_XSD_NODE, xsdNode);
53  GWEN_LIST_INIT(GWEN_XSD_NODE, xsdNode);
54  xsdNode->nodeType=t;
55  xsdNode->parent=parent;
56  xsdNode->children=GWEN_XsdNode_List_new();
57  if (name)
58  xsdNode->name=strdup(name);
59 
60  return xsdNode;
61 }
62 
63 
64 
66  if (xsdNode) {
67  GWEN_LIST_FINI(GWEN_XSD_NODE, xsdNode);
69  GWEN_XsdNode_List_free(xsdNode->children);
70  free(xsdNode->name);
71  GWEN_FREE_OBJECT(xsdNode);
72  }
73 }
74 
75 
76 
78  assert(xsdNode);
79  return xsdNode->nodeType;
80 }
81 
82 
83 
84 const char *GWEN_XsdNode_GetName(const GWEN_XSD_NODE *xsdNode) {
85  assert(xsdNode);
86  return xsdNode->name;
87 }
88 
89 
90 
91 uint32_t GWEN_XsdNode_GetFlags(const GWEN_XSD_NODE *xsdNode) {
92  assert(xsdNode);
93  return xsdNode->flags;
94 }
95 
96 
97 
98 void GWEN_XsdNode_SetFlags(GWEN_XSD_NODE *xsdNode, uint32_t fl) {
99  assert(xsdNode);
100  xsdNode->flags=fl;
101 }
102 
103 
104 
105 void GWEN_XsdNode_AddFlags(GWEN_XSD_NODE *xsdNode, uint32_t fl) {
106  assert(xsdNode);
107  xsdNode->flags|=fl;
108 }
109 
110 
111 
112 void GWEN_XsdNode_SubFlags(GWEN_XSD_NODE *xsdNode, uint32_t fl) {
113  assert(xsdNode);
114  xsdNode->flags&=~fl;
115 }
116 
117 
118 
120  assert(xsdNode);
121  return xsdNode->parent;
122 }
123 
124 
125 
126 GWEN_XSD_NODE_LIST *GWEN_XsdNode_GetChildren(const GWEN_XSD_NODE *xsdNode) {
127  assert(xsdNode);
128  return xsdNode->children;
129 }
130 
131 
132 
134  assert(xsdNode);
135  assert(newChild);
136  GWEN_XsdNode_List_Add(newChild, xsdNode->children);
137  newChild->parent=xsdNode;
138 }
139 
140 
141 
143  GWEN_XsdNode_List_Del(xsdNode);
144  xsdNode->parent=NULL;
145 }
146 
147 
148 
151  GWEN_XSDNODE_READ_FN oldFn;
152 
153  assert(xsdNode);
154  oldFn=xsdNode->readFn;
155  xsdNode->readFn=fn;
156  return oldFn;
157 }
158 
159 
160 
163  GWEN_XSDNODE_WRITE_FN oldFn;
164 
165  assert(xsdNode);
166  oldFn=xsdNode->writeFn;
167  xsdNode->writeFn=fn;
168  return oldFn;
169 }
170 
171 
172 
174  GWEN_XMLNODE *xmlNode,
175  GWEN_DB_NODE *db) {
176  assert(xsdNode);
177  if (xsdNode->readFn)
178  return xsdNode->readFn(xsdNode, xmlNode, db);
179  else
181 }
182 
183 
184 
186  GWEN_XMLNODE *xmlNode,
187  GWEN_DB_NODE *db) {
188  assert(xsdNode);
189  if (xsdNode->writeFn)
190  return xsdNode->writeFn(xsdNode, xmlNode, db);
191  else
193 }
194 
195 
196 
197