1 /***************************************************************************
2  begin       : Sat Feb 20 2010
3  copyright   : (C) 2010 by Martin Preuss
4  email       : martin@libchipcard.de
5 
6  ***************************************************************************
7  *          Please see toplevel file COPYING for license details           *
8  ***************************************************************************/
9 
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13 
14 #define DISABLE_DEBUGLOG
15 
16 
17 #include "htmlgroup_p.h"
18 
19 #include <gwenhywfar/misc.h>
20 #include <gwenhywfar/debug.h>
21 
22 
23 
GWEN_INHERIT_FUNCTIONS(HTML_GROUP)24 GWEN_INHERIT_FUNCTIONS(HTML_GROUP)
25 
26 
27 
28 
29 
30 HTML_GROUP *HtmlGroup_new(const char *groupName,
31                           HTML_GROUP *parent,
32                           GWEN_XML_CONTEXT *ctx)
33 {
34   HTML_GROUP *g;
35 
36   GWEN_NEW_OBJECT(HTML_GROUP, g);
37   GWEN_INHERIT_INIT(HTML_GROUP, g);
38   g->parent=parent;
39   g->xmlContext=ctx;
40   if (groupName)
41     g->groupName=strdup(groupName);
42   if (g->xmlContext==NULL && g->parent)
43     g->xmlContext=parent->xmlContext;
44 
45   return g;
46 }
47 
48 
49 
HtmlGroup_free(HTML_GROUP * g)50 void HtmlGroup_free(HTML_GROUP *g)
51 {
52   if (g) {
53     GWEN_INHERIT_FINI(HTML_GROUP, g);
54 
55     HtmlProps_free(g->properties);
56     free(g->groupName);
57 
58     GWEN_FREE_OBJECT(g);
59   }
60 }
61 
62 
63 
HtmlGroup_GetParent(const HTML_GROUP * g)64 HTML_GROUP *HtmlGroup_GetParent(const HTML_GROUP *g)
65 {
66   assert(g);
67   return g->parent;
68 }
69 
70 
71 
HtmlGroup_GetXmlContext(const HTML_GROUP * g)72 GWEN_XML_CONTEXT *HtmlGroup_GetXmlContext(const HTML_GROUP *g)
73 {
74   assert(g);
75   return g->xmlContext;
76 }
77 
78 
79 
HtmlGroup_GetGroupName(const HTML_GROUP * g)80 const char *HtmlGroup_GetGroupName(const HTML_GROUP *g)
81 {
82   assert(g);
83   return g->groupName;
84 }
85 
86 
87 
HtmlGroup_GetObject(const HTML_GROUP * g)88 HTML_OBJECT *HtmlGroup_GetObject(const HTML_GROUP *g)
89 {
90   assert(g);
91   return g->object;
92 }
93 
94 
95 
HtmlGroup_SetObject(HTML_GROUP * g,HTML_OBJECT * o)96 void HtmlGroup_SetObject(HTML_GROUP *g, HTML_OBJECT *o)
97 {
98   assert(g);
99   g->object=o;
100 }
101 
102 
103 
HtmlGroup_GetProperties(const HTML_GROUP * g)104 HTML_PROPS *HtmlGroup_GetProperties(const HTML_GROUP *g)
105 {
106   assert(g);
107   return g->properties;
108 }
109 
110 
111 
HtmlGroup_SetProperties(HTML_GROUP * g,HTML_PROPS * pr)112 void HtmlGroup_SetProperties(HTML_GROUP *g, HTML_PROPS *pr)
113 {
114   assert(g);
115 
116   HtmlProps_Attach(pr);
117   HtmlProps_free(g->properties);
118   g->properties=pr;
119 }
120 
121 
122 
123 
124 
125 
126 
127 
HtmlGroup_SetStartTagFn(HTML_GROUP * g,HTML_GROUP_STARTTAG_FN f)128 HTML_GROUP_STARTTAG_FN HtmlGroup_SetStartTagFn(HTML_GROUP *g,
129                                                HTML_GROUP_STARTTAG_FN f)
130 {
131   HTML_GROUP_STARTTAG_FN oldFn;
132 
133   assert(g);
134   oldFn=g->startTagFn;
135   g->startTagFn=f;
136   return oldFn;
137 }
138 
139 
140 
HtmlGroup_SetEndTagFn(HTML_GROUP * g,HTML_GROUP_ENDTAG_FN f)141 HTML_GROUP_ENDTAG_FN HtmlGroup_SetEndTagFn(HTML_GROUP *g,
142                                            HTML_GROUP_ENDTAG_FN f)
143 {
144   HTML_GROUP_ENDTAG_FN oldFn;
145 
146   assert(g);
147   oldFn=g->endTagFn;
148   g->endTagFn=f;
149   return oldFn;
150 }
151 
152 
153 
HtmlGroup_SetAddDataFn(HTML_GROUP * g,HTML_GROUP_ADDDATA_FN f)154 HTML_GROUP_ADDDATA_FN HtmlGroup_SetAddDataFn(HTML_GROUP *g,
155                                              HTML_GROUP_ADDDATA_FN f)
156 {
157   HTML_GROUP_ADDDATA_FN oldFn;
158 
159   assert(g);
160   oldFn=g->addDataFn;
161   g->addDataFn=f;
162   return oldFn;
163 }
164 
165 
166 
HtmlGroup_SetEndSubGroupFn(HTML_GROUP * g,HTML_GROUP_ENDSUBGROUP_FN f)167 HTML_GROUP_ENDSUBGROUP_FN HtmlGroup_SetEndSubGroupFn(HTML_GROUP *g,
168                                                      HTML_GROUP_ENDSUBGROUP_FN f)
169 {
170   HTML_GROUP_ENDSUBGROUP_FN oldFn;
171 
172   assert(g);
173   oldFn=g->endSubGroupFn;
174   g->endSubGroupFn=f;
175   return oldFn;
176 }
177 
178 
179 
180 
181 
HtmlGroup_StartTag(HTML_GROUP * g,const char * tagName)182 int HtmlGroup_StartTag(HTML_GROUP *g,
183                        const char *tagName)
184 {
185   assert(g);
186   if (g->startTagFn)
187     return g->startTagFn(g, tagName);
188   else
189     return GWEN_ERROR_NOT_IMPLEMENTED;
190 }
191 
192 
193 
HtmlGroup_EndTag(HTML_GROUP * g,const char * tagName)194 int HtmlGroup_EndTag(HTML_GROUP *g,
195                      const char *tagName)
196 {
197   assert(g);
198   if (g->endTagFn)
199     return g->endTagFn(g, tagName);
200   else
201     return GWEN_ERROR_NOT_IMPLEMENTED;
202 }
203 
204 
205 
HtmlGroup_AddData(HTML_GROUP * g,const char * data)206 int HtmlGroup_AddData(HTML_GROUP *g,
207                       const char *data)
208 {
209   assert(g);
210   if (g->addDataFn)
211     return g->addDataFn(g, data);
212   else
213     return GWEN_ERROR_NOT_IMPLEMENTED;
214 }
215 
216 
217 
HtmlGroup_EndSubGroup(HTML_GROUP * g,HTML_GROUP * sg)218 int HtmlGroup_EndSubGroup(HTML_GROUP *g, HTML_GROUP *sg)
219 {
220   assert(g);
221   if (g->endSubGroupFn)
222     return g->endSubGroupFn(g, sg);
223   else
224     return GWEN_ERROR_NOT_IMPLEMENTED;
225 }
226 
227 
228 
229 
230 
231