Chameleon

Chameleon Svn Source Tree

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

Source at commit 1322 created 9 years 5 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id: doxygen.cpp,v 1.87 2001/03/19 19:27:40 root Exp $
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#include "linkedtexthandler.h"
16#include "debug.h"
17#include <doxmlintf.h>
18#include "stringimpl.h"
19
20class 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:
30 StringImpl m_text;
31};
32
33class 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:
51 StringImpl m_refId;
52 StringImpl m_extId;
53 StringImpl m_text;
54 TargetKind m_targetKind;
55};
56
57LinkedTextHandler::LinkedTextHandler(IBaseHandler *parent,
58 QList<LinkedTextImpl> &children
59 )
60 : m_parent(parent), m_children(children)
61{
62 addStartHandler("ref",this,&LinkedTextHandler::startRef);
63 addEndHandler("ref",this,&LinkedTextHandler::endRef);
64 m_children.setAutoDelete(TRUE);
65 m_ref=0;
66}
67
68LinkedTextHandler::~LinkedTextHandler()
69{
70}
71
72void LinkedTextHandler::start(const char *endTag)
73{
74 addEndHandler(endTag,this,&LinkedTextHandler::end);
75 m_parent->setDelegate(this);
76 m_curString="";
77}
78
79void LinkedTextHandler::end()
80{
81 if (!m_curString.isEmpty())
82 {
83 m_children.append(new LT_Text(m_curString));
84 debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data());
85 m_curString="";
86 }
87 m_parent->setDelegate(0);
88}
89
90void LinkedTextHandler::startRef(const QXmlAttributes& attrib)
91{
92 if (!m_curString.isEmpty())
93 {
94 m_children.append(new LT_Text(m_curString));
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
106void LinkedTextHandler::endRef()
107{
108 m_ref->setText(m_curString);
109 m_children.append(m_ref);
110 debug(2,"LinkedTextHandler: add ref `%s'\n",m_ref->text()->latin1());
111 m_ref=0;
112}
113
114QString LinkedTextHandler::toString(const QList<LinkedTextImpl> &list)
115{
116 QListIterator<LinkedTextImpl> li(list);
117 QString result;
118 LinkedTextImpl *lt;
119 for (li.toFirst();(lt=li.current());++li)
120 {
121 switch(lt->kind())
122 {
123 case ILinkedText::Kind_Text:
124 result+=dynamic_cast<ILT_Text*>(lt)->text()->latin1();
125 break;
126 case ILinkedText::Kind_Ref:
127 result+=dynamic_cast<ILT_Ref *>(lt)->text()->latin1();
128 break;
129 }
130 }
131 return result;
132}
133
134

Archive Download this file

Revision: 1322