linkedtexthandler.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 #include "linkedtexthandler.h"
16 #include "debug.h"
17 #include <doxmlintf.h>
18 #include "stringimpl.h"
19 
20 class LT_Text : public LinkedTextImpl, public ILT_Text
21 {
22  public:
23  LT_Text(const QString &text) : m_text(text) {}
24  virtual ~LT_Text() {}
25 
26  // ILT_Text
27  virtual const IString *text() const { return &m_text; }
28  virtual Kind kind() const { return LinkedTextImpl::Kind_Text; }
29  private:
31 };
32 
33 class LT_Ref : public LinkedTextImpl, public ILT_Ref
34 {
35  public:
36  LT_Ref() {}
37  virtual ~LT_Ref() {}
38  void setRefId(const QString &refId) { m_refId=refId; }
39  void setText(const QString &text) { m_text=text; }
40  void setExtId(const QString &extId) { m_extId=extId; }
41  void setTargetKind(TargetKind k) { m_targetKind=k; }
42 
43  // ILT_Ref
44  virtual const IString *text() const { return &m_text; }
45  virtual const IString * id() const { return &m_refId; }
46  virtual TargetKind targetKind() const { return m_targetKind; }
47  virtual const IString *external() const { return &m_extId; }
48  virtual Kind kind() const { return LinkedTextImpl::Kind_Ref; }
49 
50  private:
55 };
56 
58  QList<LinkedTextImpl> &children
59  )
60  : m_parent(parent), m_children(children)
61 {
65  m_ref=0;
66 }
67 
69 {
70 }
71 
72 void LinkedTextHandler::start(const char *endTag)
73 {
75  m_parent->setDelegate(this);
76  m_curString="";
77 }
78 
80 {
81  if (!m_curString.isEmpty())
82  {
84  debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data());
85  m_curString="";
86  }
88 }
89 
91 {
92  if (!m_curString.isEmpty())
93  {
95  debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data());
96  m_curString="";
97  }
98  ASSERT(m_ref==0);
99  m_ref = new LT_Ref;
100  m_ref->setRefId(attrib.value("refid"));
101  m_ref->setExtId(attrib.value("external"));
102  ASSERT(attrib.value("kindref")=="compound" || attrib.value("kindref")=="member");
103  m_ref->setTargetKind(attrib.value("kindref")=="compound" ? ILT_Ref::Compound : ILT_Ref::Member);
104 }
105 
107 {
110  debug(2,"LinkedTextHandler: add ref `%s'\n",m_ref->text()->latin1());
111  m_ref=0;
112 }
113 
115 {
117  QString result;
118  LinkedTextImpl *lt;
119  for (li.toFirst();(lt=li.current());++li)
120  {
121  switch(lt->kind())
122  {
124  result+=dynamic_cast<ILT_Text*>(lt)->text()->latin1();
125  break;
127  result+=dynamic_cast<ILT_Ref *>(lt)->text()->latin1();
128  break;
129  }
130  }
131  return result;
132 }
133 
virtual const IString * text() const
QList< LinkedTextImpl > & m_children
Read only interface to a string.
Definition: doxmlintf.h:42
bool isEmpty() const
Definition: qstring.h:682
virtual ~LT_Ref()
IBaseHandler * m_parent
static QCString result
StringImpl m_text
void append(const type *d)
Definition: qlist.h:73
TargetKind m_targetKind
virtual const char * latin1() const =0
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
virtual const IString * id() const
QString value(int index) const
Definition: qxml.cpp:664
void setTargetKind(TargetKind k)
virtual void start(const char *endTag)
void setText(const QString &text)
static QString toString(const QList< LinkedTextImpl > &list)
const char * data() const
Definition: qstring.h:542
StringImpl m_extId
virtual void setDelegate(QXmlDefaultHandler *delegate)=0
Reference to an object.
Definition: doxmlintf.h:84
virtual Kind kind() const
LinkedTextHandler(IBaseHandler *parent, QList< LinkedTextImpl > &children)
type * current() const
Definition: qlist.h:146
virtual TargetKind targetKind() const
virtual ~LT_Text()
virtual const IString * external() const
void setRefId(const QString &refId)
StringImpl m_refId
StringImpl m_text
void setExtId(const QString &extId)
virtual Kind kind() const
The QXmlAttributes class provides XML attributes.
Definition: qxml.h:128
void addStartHandler(const char *key)
Definition: basehandler.h:91
LT_Text(const QString &text)
Plain text fragment.
Definition: doxmlintf.h:75
void setAutoDelete(bool enable)
Definition: qlist.h:99
virtual const IString * text() const
virtual Kind kind() const =0
virtual void startRef(const QXmlAttributes &attrib)
def parent(G, child, parent_type)
Definition: graph.py:67
const bool TRUE
Definition: qglobal.h:371
The interface to the object model provided by the XML parser library.
void addEndHandler(const char *key)
Definition: basehandler.h:101
TargetKind
Definition: doxmlintf.h:88
#define ASSERT(x)
Definition: qglobal.h:590
type * toFirst()
Definition: qlist.h:135