Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/addon/doxmlparser/src/memberhandler.cpp

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id: $
4 *
5 *
6 * Copyright (C) 1997-2006 by Dimitri van Heesch.
7 *
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
13 *
14 */
15
16#include "memberhandler.h"
17#include "sectionhandler.h"
18#include "dochandler.h"
19#include "mainhandler.h"
20#include "linkedtexthandler.h"
21#include "paramhandler.h"
22#include "compoundhandler.h"
23#include "debug.h"
24
25//------------------------------------------------------------------------------
26
27class MemberTypeMap
28{
29 public:
30 MemberTypeMap()
31 {
32 m_map.setAutoDelete(TRUE);
33 m_map.insert("define",new int(IMember::Define));
34 m_map.insert("property",new int(IMember::Property));
35 m_map.insert("variable",new int(IMember::Variable));
36 m_map.insert("typedef",new int(IMember::Typedef));
37 m_map.insert("enum",new int(IMember::Enum));
38 m_map.insert("function",new int(IMember::Function));
39 m_map.insert("signal",new int(IMember::Signal));
40 m_map.insert("prototype",new int(IMember::Prototype));
41 m_map.insert("friend",new int(IMember::Friend));
42 m_map.insert("dcop",new int(IMember::DCOP));
43 m_map.insert("slot",new int(IMember::Slot));
44 m_map.insert("enumvalue",new int(IMember::EnumValue));
45 }
46 IMember::MemberKind map(const QString &s)
47 {
48 int *val = m_map.find(s);
49 if (val==0)
50 {
51 debug(1,"Warning: `%s' is an invalid member type\n",s.data());
52 return IMember::Invalid;
53 }
54 else return (IMember::MemberKind)*val;
55 }
56 private:
57 QDict<int> m_map;
58};
59
60static MemberTypeMap *s_typeMap;
61
62void memberhandler_init()
63{
64 s_typeMap = new MemberTypeMap;
65}
66
67void memberhandler_exit()
68{
69 delete s_typeMap;
70}
71
72//------------------------------------------------------------------------------
73
74void MemberReference::initialize(MainHandler *mh)
75{
76 m_mainHandler = mh;
77}
78
79IMember *MemberReference::member() const
80{
81 //return m_mainHandler->memberById(m_memId);
82 return 0;
83}
84
85//------------------------------------------------------------------------------
86
87
88#if 0
89EnumValueHandler::EnumValueHandler(IBaseHandler *parent) :
90 m_parent(parent), m_brief(0), m_detailed(0), m_linkedTextHandler(0)
91{
92 addEndHandler("enumvalue",this,&EnumValueHandler::endEnumValue);
93
94 addStartHandler("name",this,&EnumValueHandler::startName);
95 addEndHandler("name",this,&EnumValueHandler::endName);
96 addStartHandler("initializer",this,&EnumValueHandler::startInitializer);
97
98 addStartHandler("briefdescription",this,&EnumValueHandler::startBriefDesc);
99
100 addStartHandler("detaileddescription",this,&EnumValueHandler::startDetailedDesc);
101
102 m_initializer.setAutoDelete(TRUE);
103}
104
105EnumValueHandler::~EnumValueHandler()
106{
107 delete m_brief;
108 delete m_detailed;
109 delete m_linkedTextHandler;
110}
111
112void EnumValueHandler::startEnumValue(const QXmlAttributes& /*attrib*/)
113{
114 m_parent->setDelegate(this);
115}
116
117void EnumValueHandler::endEnumValue()
118{
119 m_parent->setDelegate(0);
120}
121
122void EnumValueHandler::startName(const QXmlAttributes& /*attrib*/)
123{
124 m_curString="";
125}
126
127void EnumValueHandler::endName()
128{
129 m_name = m_curString;
130}
131
132void EnumValueHandler::startInitializer(const QXmlAttributes& /*attrib*/)
133{
134 delete m_linkedTextHandler;
135 m_linkedTextHandler = new LinkedTextHandler(this,m_initializer);
136 m_linkedTextHandler->start("initializer");
137}
138
139void EnumValueHandler::startBriefDesc(const QXmlAttributes& attrib)
140{
141 DocHandler *docHandler = new DocHandler(this);
142 docHandler->startDoc(attrib);
143 m_brief = docHandler;
144}
145
146void EnumValueHandler::startDetailedDesc(const QXmlAttributes& attrib)
147{
148 DocHandler *docHandler = new DocHandler(this);
149 docHandler->startDoc(attrib);
150 m_detailed = docHandler;
151}
152#endif
153
154//------------------------------------------------------------------------------
155
156MemberHandler::MemberHandler(IBaseHandler *parent)
157 : m_brief(0), m_detailed(0), m_inbody(0),
158 m_compound(0), m_section(0), m_parent(parent)
159{
160 //printf("MemberHandler::MemberHandler() %p\n",this);
161 addEndHandler("memberdef",this,&MemberHandler::endMember);
162
163 addStartHandler("templateparamlist",this,&MemberHandler::startTemplateParamList);
164 addEndHandler("templateparamlist",this,&MemberHandler::endTemplateParamList);
165
166 addStartHandler("type",this,&MemberHandler::startType);
167
168 addStartHandler("definition",this,&MemberHandler::startDefinition);
169 addEndHandler("definition",this,&MemberHandler::endDefinition);
170
171 addStartHandler("argsstring",this,&MemberHandler::startArgsString);
172 addEndHandler("argsstring",this,&MemberHandler::endArgsString);
173
174 addStartHandler("name",this,&MemberHandler::startName);
175 addEndHandler("name",this,&MemberHandler::endName);
176
177 addStartHandler("read",this,&MemberHandler::startRead);
178 addEndHandler("read",this,&MemberHandler::endRead);
179
180 addStartHandler("write",this,&MemberHandler::startWrite);
181 addEndHandler("write",this,&MemberHandler::endWrite);
182
183 addStartHandler("reimplements",this,&MemberHandler::startReimplements);
184 addEndHandler("reimplements",this,&MemberHandler::endReimplements);
185
186 addStartHandler("reimplementedby",this,&MemberHandler::startReimplementedBy);
187 addEndHandler("reimplementedby",this,&MemberHandler::endReimplementedBy);
188
189 addStartHandler("param",this,&MemberHandler::startParam);
190
191 addStartHandler("enumvalue",this,&MemberHandler::startEnumValue2);
192 addEndHandler("enumvalue",this,&MemberHandler::endMember);
193
194 addStartHandler("initializer",this,&MemberHandler::startInitializer);
195 addStartHandler("exceptions",this,&MemberHandler::startException);
196
197 addStartHandler("briefdescription",this,&MemberHandler::startBriefDesc);
198
199 addStartHandler("detaileddescription",this,&MemberHandler::startDetailedDesc);
200
201 addStartHandler("inbodydescription",this,&MemberHandler::startInbodyDesc);
202
203 addStartHandler("location",this,&MemberHandler::startLocation);
204 addEndHandler("location");
205
206 addStartHandler("references",this,&MemberHandler::startReferences);
207 addEndHandler("references",this,&MemberHandler::endReferences);
208
209 addStartHandler("referencedby",this,&MemberHandler::startReferencedBy);
210 addEndHandler("referencedby",this,&MemberHandler::endReferencedBy);
211
212 m_type.setAutoDelete(TRUE);
213 m_initializer.setAutoDelete(TRUE);
214 m_exception.setAutoDelete(TRUE);
215 m_params.setAutoDelete(TRUE);
216 m_references.setAutoDelete(TRUE);
217 m_referencedBy.setAutoDelete(TRUE);
218 m_reimplements = 0;
219 m_reimplementedBy.setAutoDelete(TRUE);
220 m_enumValues.setAutoDelete(TRUE);
221 m_linkedTextHandler = 0;
222 m_defLine=0;
223 m_bodyStart=0;
224 m_bodyEnd=0;
225 m_insideTemplateParamList=FALSE;
226 m_hasTemplateParamList=FALSE;
227}
228
229MemberHandler::~MemberHandler()
230{
231 debug(2,"MemberHandler::~MemberHandler() %p\n",this);
232 delete m_brief;
233 delete m_detailed;
234 delete m_inbody;
235 delete m_linkedTextHandler;
236 delete m_reimplements;
237}
238
239void MemberHandler::startMember(const QXmlAttributes& attrib)
240{
241 m_parent->setDelegate(this);
242 m_kindString = attrib.value("kind");
243 //printf("startMember kindString=`%s'\n",m_kindString.data());
244 m_kind = s_typeMap->map(m_kindString);
245 m_id = attrib.value("id");
246 m_protection = attrib.value("prot");
247 m_isStatic = attrib.value("static")=="yes";
248 m_isConst = attrib.value("const")=="yes";
249 m_isExplicit = attrib.value("explicit")=="yes";
250 m_isInline = attrib.value("inline")=="yes";
251 m_virtualness = attrib.value("virt");
252 m_isVolatile = attrib.value("volatile")=="yes";
253 m_isMutable = attrib.value("mutable")=="yes";
254 m_isReadable = attrib.value("readable")=="yes";
255 m_isWritable = attrib.value("writable")=="yes";
256
257 debug(2,"member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n",
258 m_kindString.data(),m_id.data(),m_protection.data(),m_virtualness.data());
259}
260
261void MemberHandler::startEnumValue(const QXmlAttributes& attrib)
262{
263 m_parent->setDelegate(this);
264 m_kindString = "enumvalue";
265 //printf("startEnumValue kindString=`%s'\n",m_kindString.data());
266 m_kind = s_typeMap->map(m_kindString);
267 m_id = attrib.value("id");
268 m_protection = attrib.value("prot");
269 m_isStatic = FALSE;
270 m_isConst = FALSE;
271 m_isExplicit = FALSE;
272 m_isInline = FALSE;
273 m_virtualness = "non-virtual";
274 m_isVolatile = FALSE;
275 m_isMutable = FALSE;
276 m_isReadable = FALSE;
277 m_isWritable = FALSE;
278 debug(2,"member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n",
279 m_kindString.data(),m_id.data(),m_protection.data(),m_virtualness.data());
280}
281
282void MemberHandler::startEnumValue2(const QXmlAttributes& attrib)
283{
284 MemberHandler *mh = new MemberHandler(this);
285 mh->startEnumValue(attrib);
286 m_enumValues.append(mh);
287}
288
289
290void MemberHandler::startBriefDesc(const QXmlAttributes& attrib)
291{
292 DocHandler *docHandler = new DocHandler(this);
293 docHandler->startDoc(attrib);
294 m_brief = docHandler;
295}
296
297void MemberHandler::startDetailedDesc(const QXmlAttributes& attrib)
298{
299 DocHandler *docHandler = new DocHandler(this);
300 docHandler->startDoc(attrib);
301 m_detailed = docHandler;
302}
303
304void MemberHandler::startInbodyDesc(const QXmlAttributes& attrib)
305{
306 DocHandler *docHandler = new DocHandler(this);
307 docHandler->startDoc(attrib);
308 m_inbody = docHandler;
309}
310
311void MemberHandler::startLocation(const QXmlAttributes& attrib)
312{
313 m_defFile = attrib.value("file");
314 m_bodyFile = attrib.value("bodyfile");
315 QCString s;
316 s = attrib.value("line");
317 if (!s.isEmpty()) m_defLine=s.toInt();
318 s = attrib.value("bodystart");
319 if (!s.isEmpty()) m_bodyStart=s.toInt();
320 s = attrib.value("bodyend");
321 if (!s.isEmpty()) m_bodyEnd=s.toInt();
322}
323
324void MemberHandler::startReferences(const QXmlAttributes& attrib)
325{
326 MemberReference *mr = new MemberReference;
327 mr->m_memId = attrib.value("refid");
328 m_references.append(mr);
329 m_curString="";
330}
331
332void MemberHandler::endReferences()
333{
334 m_references.getLast()->m_name = m_curString;
335}
336
337void MemberHandler::startReferencedBy(const QXmlAttributes& attrib)
338{
339 MemberReference *mr = new MemberReference;
340 mr->m_memId = attrib.value("refid");
341 m_referencedBy.append(mr);
342 m_curString="";
343}
344
345void MemberHandler::endReferencedBy()
346{
347 m_referencedBy.getLast()->m_name = m_curString;
348}
349
350void MemberHandler::startReimplements(const QXmlAttributes& attrib)
351{
352 m_reimplements = new MemberReference;
353 m_reimplements->m_memId = attrib.value("refid");
354 m_curString="";
355}
356
357void MemberHandler::endReimplements()
358{
359 m_reimplements->m_name = m_curString;
360}
361
362void MemberHandler::startReimplementedBy(const QXmlAttributes& attrib)
363{
364 MemberReference *mr = new MemberReference;
365 mr->m_memId = attrib.value("refid");
366 m_reimplementedBy.append(mr);
367 m_curString="";
368}
369
370void MemberHandler::endReimplementedBy()
371{
372 m_reimplementedBy.getLast()->m_name = m_curString;
373}
374
375void MemberHandler::endMember()
376{
377 m_parent->setDelegate(0);
378}
379
380void MemberHandler::startType(const QXmlAttributes &)
381{
382 debug(2,"startType!\n");
383 delete m_linkedTextHandler;
384 m_linkedTextHandler = new LinkedTextHandler(this,m_type);
385 m_linkedTextHandler->start("type");
386}
387
388void MemberHandler::startInitializer(const QXmlAttributes &)
389{
390 debug(2,"startInitializer!\n");
391 delete m_linkedTextHandler;
392 m_linkedTextHandler = new LinkedTextHandler(this,m_initializer);
393 m_linkedTextHandler->start("initializer");
394}
395
396void MemberHandler::startException(const QXmlAttributes &)
397{
398 debug(2,"startException!\n");
399 delete m_linkedTextHandler;
400 m_linkedTextHandler = new LinkedTextHandler(this,m_exception);
401 m_linkedTextHandler->start("exceptions");
402}
403
404void MemberHandler::startName(const QXmlAttributes &)
405{
406 m_curString="";
407}
408
409void MemberHandler::endName()
410{
411 m_name = m_curString.stripWhiteSpace();
412 debug(2,"member name=`%s'\n",m_name.data());
413}
414
415void MemberHandler::startRead(const QXmlAttributes &)
416{
417 m_curString="";
418}
419
420void MemberHandler::endRead()
421{
422 m_read = m_curString.stripWhiteSpace();
423 debug(2,"member read=`%s'\n",m_read.data());
424}
425
426void MemberHandler::startWrite(const QXmlAttributes &)
427{
428 m_curString="";
429}
430
431void MemberHandler::endWrite()
432{
433 m_write = m_curString.stripWhiteSpace();
434 debug(2,"member write=`%s'\n",m_write.data());
435}
436
437void MemberHandler::startDefinition(const QXmlAttributes&)
438{
439 m_curString="";
440}
441
442void MemberHandler::endDefinition()
443{
444 m_definition = m_curString.stripWhiteSpace();
445 debug(2,"definition=%s\n",m_definition.data());
446}
447
448void MemberHandler::startArgsString(const QXmlAttributes&)
449{
450 m_curString="";
451}
452
453void MemberHandler::endArgsString()
454{
455 m_argsstring = m_curString.stripWhiteSpace();
456 debug(2,"arggstring=%s\n",m_argsstring.data());
457}
458
459void MemberHandler::startParam(const QXmlAttributes& attrib)
460{
461 ParamHandler *paramHandler = new ParamHandler(this);
462 paramHandler->startParam(attrib);
463 if (m_insideTemplateParamList)
464 {
465 m_templateParams.append(paramHandler);
466 }
467 else
468 {
469 m_params.append(paramHandler);
470 }
471}
472
473void MemberHandler::startTemplateParamList(const QXmlAttributes&)
474{
475 m_insideTemplateParamList = TRUE;
476 m_hasTemplateParamList = TRUE;
477}
478
479void MemberHandler::endTemplateParamList()
480{
481 m_insideTemplateParamList = FALSE;
482}
483
484void MemberHandler::initialize(MainHandler *mh)
485{
486 {
487 QListIterator<MemberReference> mli(m_references);
488 MemberReference *mr;
489 for (;(mr=mli.current());++mli)
490 {
491 mr->initialize(mh);
492 }
493 }
494 {
495 QListIterator<MemberReference> mli(m_referencedBy);
496 MemberReference *mr;
497 for (;(mr=mli.current());++mli)
498 {
499 mr->initialize(mh);
500 }
501 }
502 {
503 QListIterator<MemberReference> mli(m_reimplementedBy);
504 MemberReference *mr;
505 for (;(mr=mli.current());++mli)
506 {
507 mr->initialize(mh);
508 }
509 }
510 if (m_reimplements) m_reimplements->initialize(mh);
511}
512
513void MemberHandler::setCompoundHandler(CompoundHandler *c)
514{
515 m_compound = c;
516}
517
518ICompound *MemberHandler::compound() const
519{
520 m_compound->addref();
521 return m_compound->toICompound();
522}
523
524void MemberHandler::setSectionHandler(SectionHandler *c)
525{
526 m_section = c;
527}
528
529ISection *MemberHandler::section() const
530{
531 return m_section;
532}
533
534IMemberIterator *MemberHandler::enumValues() const
535{
536 return new MemberIterator(m_enumValues);
537}
538
539ILinkedTextIterator *MemberHandler::type() const
540{
541 return new LinkedTextIterator(m_type);
542}
543
544const IString *MemberHandler::typeString() const
545{
546 MemberHandler *that = (MemberHandler *)this;
547 that->m_typeString = LinkedTextHandler::toString(m_type);
548 return &m_typeString;
549}
550
551IParamIterator *MemberHandler::parameters() const
552{
553 return new ParamIterator(m_params);
554}
555
556IParamIterator *MemberHandler::templateParameters() const
557{
558 return m_hasTemplateParamList ? new ParamIterator(m_templateParams) : 0;
559}
560
561IMemberReferenceIterator *MemberHandler::references() const
562{
563 return new MemberReferenceIterator(m_references);
564}
565
566IMemberReferenceIterator *MemberHandler::referencedBy() const
567{
568 return new MemberReferenceIterator(m_referencedBy);
569}
570
571ILinkedTextIterator *MemberHandler::initializer() const
572{
573 return new LinkedTextIterator(m_initializer);
574}
575
576ILinkedTextIterator *MemberHandler::exceptions() const
577{
578 return new LinkedTextIterator(m_exception);
579}
580
581IMemberReferenceIterator *MemberHandler::reimplementedBy() const
582{
583 return new MemberReferenceIterator(m_reimplementedBy);
584}
585
586IDocRoot *MemberHandler::briefDescription() const
587{
588 return m_brief;
589}
590
591IDocRoot *MemberHandler::detailedDescription() const
592{
593 return m_detailed;
594}
595
596IDocRoot *MemberHandler::inbodyDescription() const
597{
598 return m_inbody;
599}
600
601

Archive Download this file

Revision: 1322