memberhandler.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * $Id$
4  *
5  *
6  * Copyright (C) 1997-2015 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 
28 {
29  public:
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  }
47  {
48  int *val = m_map.find(s.utf8());
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 
61 
63 {
64  s_typeMap = new MemberTypeMap;
65 }
66 
68 {
69  delete s_typeMap;
70 }
71 
72 //------------------------------------------------------------------------------
73 
75 {
76  m_mainHandler = mh;
77 }
78 
80 {
81  //return m_mainHandler->memberById(m_memId);
82  return 0;
83 }
84 
85 //------------------------------------------------------------------------------
86 
87 
88 #if 0
89 EnumValueHandler::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 
105 EnumValueHandler::~EnumValueHandler()
106 {
107  delete m_brief;
108  delete m_detailed;
109  delete m_linkedTextHandler;
110 }
111 
112 void EnumValueHandler::startEnumValue(const QXmlAttributes& /*attrib*/)
113 {
114  m_parent->setDelegate(this);
115 }
116 
117 void EnumValueHandler::endEnumValue()
118 {
119  m_parent->setDelegate(0);
120 }
121 
122 void EnumValueHandler::startName(const QXmlAttributes& /*attrib*/)
123 {
124  m_curString="";
125 }
126 
127 void EnumValueHandler::endName()
128 {
129  m_name = m_curString;
130 }
131 
132 void 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 
139 void EnumValueHandler::startBriefDesc(const QXmlAttributes& attrib)
140 {
141  DocHandler *docHandler = new DocHandler(this);
142  docHandler->startDoc(attrib);
143  m_brief = docHandler;
144 }
145 
146 void 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 
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 
167 
169  addEndHandler("definition",this,&MemberHandler::endDefinition);
170 
172  addEndHandler("argsstring",this,&MemberHandler::endArgsString);
173 
176 
179 
181  addEndHandler("write",this,&MemberHandler::endWrite);
182 
184  addEndHandler("reimplements",this,&MemberHandler::endReimplements);
185 
186  addStartHandler("reimplementedby",this,&MemberHandler::startReimplementedBy);
187  addEndHandler("reimplementedby",this,&MemberHandler::endReimplementedBy);
188 
190 
192  addEndHandler("enumvalue",this,&MemberHandler::endMember);
193 
196 
197  addStartHandler("briefdescription",this,&MemberHandler::startBriefDesc);
198 
199  addStartHandler("detaileddescription",this,&MemberHandler::startDetailedDesc);
200 
201  addStartHandler("inbodydescription",this,&MemberHandler::startInbodyDesc);
202 
204  addEndHandler("location");
205 
207  addEndHandler("references",this,&MemberHandler::endReferences);
208 
210  addEndHandler("referencedby",this,&MemberHandler::endReferencedBy);
211 
218  m_reimplements = 0;
222  m_defLine=0;
223  m_bodyStart=0;
224  m_bodyEnd=0;
227 }
228 
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 
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",
259 }
260 
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;
272  m_isInline = FALSE;
273  m_virtualness = "non-virtual";
275  m_isMutable = FALSE;
278  debug(2,"member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n",
280 }
281 
283 {
284  MemberHandler *mh = new MemberHandler(this);
285  mh->startEnumValue(attrib);
286  m_enumValues.append(mh);
287 }
288 
289 
291 {
292  DocHandler *docHandler = new DocHandler(this);
293  docHandler->startDoc(attrib);
294  m_brief = docHandler;
295 }
296 
298 {
299  DocHandler *docHandler = new DocHandler(this);
300  docHandler->startDoc(attrib);
301  m_detailed = docHandler;
302 }
303 
305 {
306  DocHandler *docHandler = new DocHandler(this);
307  docHandler->startDoc(attrib);
308  m_inbody = docHandler;
309 }
310 
312 {
313  m_defFile = attrib.value("file");
314  m_bodyFile = attrib.value("bodyfile");
315  QString 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 
325 {
327  mr->m_memId = attrib.value("refid");
328  m_references.append(mr);
329  m_curString="";
330 }
331 
333 {
335 }
336 
338 {
340  mr->m_memId = attrib.value("refid");
342  m_curString="";
343 }
344 
346 {
348 }
349 
351 {
353  m_reimplements->m_memId = attrib.value("refid");
354  m_curString="";
355 }
356 
358 {
360 }
361 
363 {
365  mr->m_memId = attrib.value("refid");
367  m_curString="";
368 }
369 
371 {
373 }
374 
376 {
377  m_parent->setDelegate(0);
378 }
379 
381 {
382  debug(2,"startType!\n");
383  delete m_linkedTextHandler;
385  m_linkedTextHandler->start("type");
386 }
387 
389 {
390  debug(2,"startInitializer!\n");
391  delete m_linkedTextHandler;
393  m_linkedTextHandler->start("initializer");
394 }
395 
397 {
398  debug(2,"startException!\n");
399  delete m_linkedTextHandler;
401  m_linkedTextHandler->start("exceptions");
402 }
403 
405 {
406  m_curString="";
407 }
408 
410 {
412  debug(2,"member name=`%s'\n",m_name.data());
413 }
414 
416 {
417  m_curString="";
418 }
419 
421 {
423  debug(2,"member read=`%s'\n",m_read.data());
424 }
425 
427 {
428  m_curString="";
429 }
430 
432 {
434  debug(2,"member write=`%s'\n",m_write.data());
435 }
436 
438 {
439  m_curString="";
440 }
441 
443 {
445  debug(2,"definition=%s\n",m_definition.data());
446 }
447 
449 {
450  m_curString="";
451 }
452 
454 {
456  debug(2,"arggstring=%s\n",m_argsstring.data());
457 }
458 
460 {
461  ParamHandler *paramHandler = new ParamHandler(this);
462  paramHandler->startParam(attrib);
464  {
465  m_templateParams.append(paramHandler);
466  }
467  else
468  {
469  m_params.append(paramHandler);
470  }
471 }
472 
474 {
477 }
478 
480 {
482 }
483 
485 {
486  {
488  MemberReference *mr;
489  for (;(mr=mli.current());++mli)
490  {
491  mr->initialize(mh);
492  }
493  }
494  {
496  MemberReference *mr;
497  for (;(mr=mli.current());++mli)
498  {
499  mr->initialize(mh);
500  }
501  }
502  {
504  MemberReference *mr;
505  for (;(mr=mli.current());++mli)
506  {
507  mr->initialize(mh);
508  }
509  }
511 }
512 
514 {
515  m_compound = c;
516 }
517 
519 {
520  m_compound->addref();
521  return m_compound->toICompound();
522 }
523 
525 {
526  m_section = c;
527 }
528 
530 {
531  return m_section;
532 }
533 
535 {
536  return new MemberIterator(m_enumValues);
537 }
538 
540 {
541  return new LinkedTextIterator(m_type);
542 }
543 
545 {
546  MemberHandler *that = (MemberHandler *)this;
548  return &m_typeString;
549 }
550 
552 {
553  return new ParamIterator(m_params);
554 }
555 
557 {
559 }
560 
562 {
564 }
565 
567 {
569 }
570 
572 {
573  return new LinkedTextIterator(m_initializer);
574 }
575 
577 {
578  return new LinkedTextIterator(m_exception);
579 }
580 
582 {
584 }
585 
587 {
588  return m_brief;
589 }
590 
592 {
593  return m_detailed;
594 }
595 
597 {
598  return m_inbody;
599 }
600 
virtual void endRead()
virtual ILinkedTextIterator * type() const
Read only interface to a string.
Definition: doxmlintf.h:42
bool isEmpty() const
Definition: qstring.h:682
virtual void startReimplements(const QXmlAttributes &attrib)
virtual void startTemplateParamList(const QXmlAttributes &attrib)
void memberhandler_exit()
virtual void startType(const QXmlAttributes &attrib)
void initialize(MainHandler *m)
IBaseHandler * m_parent
static MemberTypeMap * s_typeMap
void append(const type *d)
Definition: qlist.h:73
void memberhandler_init()
QList< LinkedTextImpl > m_type
StringImpl m_virtualness
virtual IDocRoot * briefDescription() const
virtual void endName()
virtual void startException(const QXmlAttributes &attrib)
virtual IMemberReferenceIterator * referencedBy() const
virtual void addref()
QList< MemberReference > m_references
const bool FALSE
Definition: qglobal.h:370
bool m_insideTemplateParamList
virtual void startInitializer(const QXmlAttributes &attrib)
bool m_hasTemplateParamList
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
virtual void startMember(const QXmlAttributes &attrib)
virtual void startInbodyDesc(const QXmlAttributes &attrib)
QList< MemberReference > m_reimplementedBy
StringImpl m_protection
QString value(int index) const
Definition: qxml.cpp:664
MemberKind m_kind
ICompound * toICompound() const
QList< ParamHandler > m_params
StringImpl m_typeString
virtual void start(const char *endTag)
virtual IMemberReferenceIterator * references() const
StringImpl m_definition
virtual void endReferences()
StringImpl m_write
QList< MemberHandler > m_enumValues
virtual void startReferences(const QXmlAttributes &attrib)
virtual const IString * typeString() const
static QString toString(const QList< LinkedTextImpl > &list)
virtual void startParam(const QXmlAttributes &attrib)
virtual void endTemplateParamList()
QList< ParamHandler > m_templateParams
virtual void startDetailedDesc(const QXmlAttributes &attrib)
QList< LinkedTextImpl > m_initializer
QDict< int > m_map
const char * data() const
Definition: qstring.h:542
type * getLast() const
Definition: qlist.h:96
virtual void endMember()
IMember::MemberKind map(const QString &s)
virtual IDocRoot * detailedDescription() const
virtual ISection * section() const
virtual void endWrite()
virtual void endArgsString()
virtual void startDoc(const QXmlAttributes &attrib)
void setSectionHandler(SectionHandler *s)
virtual void setDelegate(QXmlDefaultHandler *delegate)=0
virtual void startLocation(const QXmlAttributes &attrib)
DocHandler * m_inbody
Node representing a documentation block.
Definition: dochandler.h:1315
type * current() const
Definition: qlist.h:146
virtual ILinkedTextIterator * exceptions() const
DocHandler * m_brief
virtual IParamIterator * templateParameters() const
virtual IDocRoot * inbodyDescription() const
The interface to a compound in the object model.
Definition: doxmlintf.h:868
virtual void startBriefDesc(const QXmlAttributes &attrib)
virtual ICompound * compound() const
QString stripWhiteSpace() const
Definition: qstring.cpp:13438
The interface to a section in the object model.
Definition: doxmlintf.h:747
virtual void startEnumValue2(const QXmlAttributes &attrib)
Iterates over a list of ILinkedText fragments.
Definition: doxmlintf.h:97
virtual void endReimplements()
MemberHandler(IBaseHandler *parent)
virtual void startWrite(const QXmlAttributes &attrib)
virtual void startParam(const QXmlAttributes &attrib)
virtual void startName(const QXmlAttributes &attrib)
StringImpl m_name
virtual ~MemberHandler()
virtual IMemberIterator * enumValues() const
SectionHandler * m_section
virtual void startDefinition(const QXmlAttributes &attrib)
virtual void startReimplementedBy(const QXmlAttributes &attrib)
int toInt(bool *ok=0, int base=10) const
Definition: qstring.cpp:14045
virtual void endReimplementedBy()
StringImpl m_argsstring
The QXmlAttributes class provides XML attributes.
Definition: qxml.h:128
StringImpl m_name
Definition: memberhandler.h:49
MemberReference * m_reimplements
StringImpl m_defFile
QList< MemberReference > m_referencedBy
LinkedTextHandler * m_linkedTextHandler
void initialize(MainHandler *m)
void addStartHandler(const char *key)
Definition: basehandler.h:91
StringImpl m_read
void setCompoundHandler(CompoundHandler *c)
StringImpl m_kindString
virtual void startReferencedBy(const QXmlAttributes &attrib)
QCString utf8() const
Definition: qstring.cpp:14507
virtual IMemberReferenceIterator * reimplementedBy() const
void setAutoDelete(bool enable)
Definition: qlist.h:99
virtual void startRead(const QXmlAttributes &attrib)
QList< LinkedTextImpl > m_exception
virtual void endReferencedBy()
virtual void startArgsString(const QXmlAttributes &attrib)
static QCString * s
Definition: config.cpp:1042
def parent(G, child, parent_type)
Definition: graph.py:67
const bool TRUE
Definition: qglobal.h:371
virtual IParamIterator * parameters() const
virtual IMember * member() const
DocHandler * m_detailed
virtual void endDefinition()
virtual ILinkedTextIterator * initializer() const
StringImpl m_id
CompoundHandler * m_compound
StringImpl m_bodyFile
void addEndHandler(const char *key)
Definition: basehandler.h:101
virtual void startEnumValue(const QXmlAttributes &attrib)