Root/
Source at commit 1322 created 12 years 7 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 "mainhandler.h"␊ |
17 | #include "compoundhandler.h"␊ |
18 | #include "sectionhandler.h"␊ |
19 | #include "memberhandler.h"␊ |
20 | #include "dochandler.h"␊ |
21 | #include "debug.h"␊ |
22 | ␊ |
23 | class SectionTypeMap␊ |
24 | {␊ |
25 | public:␊ |
26 | SectionTypeMap() : m_map(37)␊ |
27 | {␊ |
28 | m_map.setAutoDelete(TRUE);␊ |
29 | m_map.insert("user-defined",new int(ISection::UserDefined));␊ |
30 | m_map.insert("public-type",new int(ISection::PubTypes));␊ |
31 | m_map.insert("public-func",new int(ISection::PubFuncs));␊ |
32 | m_map.insert("public-attrib",new int(ISection::PubAttribs));␊ |
33 | m_map.insert("public-slot",new int(ISection::PubSlots));␊ |
34 | m_map.insert("signal",new int(ISection::Signals));␊ |
35 | m_map.insert("dcop-func",new int(ISection::DCOPFuncs));␊ |
36 | m_map.insert("property",new int(ISection::Properties));␊ |
37 | m_map.insert("event",new int(ISection::Events));␊ |
38 | m_map.insert("public-static-func",new int(ISection::PubStatFuncs));␊ |
39 | m_map.insert("public-static-attrib",new int(ISection::PubStatAttribs));␊ |
40 | m_map.insert("protected-type",new int(ISection::ProTypes));␊ |
41 | m_map.insert("protected-func",new int(ISection::ProFuncs));␊ |
42 | m_map.insert("protected-attrib",new int(ISection::ProAttribs));␊ |
43 | m_map.insert("protected-slot",new int(ISection::ProSlots));␊ |
44 | m_map.insert("protected-static-func",new int(ISection::ProStatFuncs));␊ |
45 | m_map.insert("protected-static-attrib",new int(ISection::ProStatAttribs));␊ |
46 | m_map.insert("package-type",new int(ISection::PacTypes));␊ |
47 | m_map.insert("package-func",new int(ISection::PacFuncs));␊ |
48 | m_map.insert("package-attrib",new int(ISection::PacAttribs));␊ |
49 | m_map.insert("package-static-func",new int(ISection::PacStatFuncs));␊ |
50 | m_map.insert("package-static-attrib",new int(ISection::PacStatAttribs));␊ |
51 | m_map.insert("private-type",new int(ISection::PriTypes));␊ |
52 | m_map.insert("private-func",new int(ISection::PriFuncs));␊ |
53 | m_map.insert("private-attrib",new int(ISection::PriAttribs));␊ |
54 | m_map.insert("private-slot",new int(ISection::PriSlots));␊ |
55 | m_map.insert("private-static-func",new int(ISection::PriStatFuncs));␊ |
56 | m_map.insert("private-static-attrib",new int(ISection::PriStatAttribs));␊ |
57 | m_map.insert("friend",new int(ISection::Friend));␊ |
58 | m_map.insert("related",new int(ISection::Related));␊ |
59 | m_map.insert("define",new int(ISection::Defines));␊ |
60 | m_map.insert("prototype",new int(ISection::Prototypes));␊ |
61 | m_map.insert("typedef",new int(ISection::Typedefs));␊ |
62 | m_map.insert("enum",new int(ISection::Enums));␊ |
63 | m_map.insert("func",new int(ISection::Functions));␊ |
64 | m_map.insert("var",new int(ISection::Variables));␊ |
65 | }␊ |
66 | ISection::SectionKind map(const QString &s)␊ |
67 | {␊ |
68 | int *val = m_map.find(s);␊ |
69 | if (val==0) ␊ |
70 | {␊ |
71 | debug(1,"Warning: `%s' is an invalid section type\n",s.data());␊ |
72 | return ISection::Invalid;␊ |
73 | }␊ |
74 | else return (ISection::SectionKind)*val;␊ |
75 | }␊ |
76 | private: ␊ |
77 | QDict<int> m_map;␊ |
78 | };␊ |
79 | ␊ |
80 | static SectionTypeMap *s_typeMap;␊ |
81 | ␊ |
82 | void sectionhandler_init()␊ |
83 | {␊ |
84 | s_typeMap = new SectionTypeMap;␊ |
85 | }␊ |
86 | ␊ |
87 | void sectionhandler_exit()␊ |
88 | {␊ |
89 | delete s_typeMap;␊ |
90 | }␊ |
91 | ␊ |
92 | SectionHandler::SectionHandler(IBaseHandler *parent) : m_parent(parent)␊ |
93 | {␊ |
94 | //printf("SectionHandler::SectionHandler()\n");␊ |
95 | m_members.setAutoDelete(TRUE);␊ |
96 | addEndHandler("sectiondef",this,&SectionHandler::endSection);␊ |
97 | addStartHandler("memberdef",this,&SectionHandler::startMember);␊ |
98 | addStartHandler("header",this,&SectionHandler::startHeader);␊ |
99 | addEndHandler("header",this,&SectionHandler::endHeader);␊ |
100 | addStartHandler("description",this,&SectionHandler::startDescription);␊ |
101 | }␊ |
102 | ␊ |
103 | SectionHandler::~SectionHandler()␊ |
104 | {␊ |
105 | debug(2,"SectionHandler::~SectionHandler()\n");␊ |
106 | }␊ |
107 | ␊ |
108 | void SectionHandler::startSection(const QXmlAttributes& attrib)␊ |
109 | {␊ |
110 | m_parent->setDelegate(this);␊ |
111 | m_kindString = attrib.value("kind");␊ |
112 | m_kind = s_typeMap->map(m_kindString);␊ |
113 | debug(2,"section kind=`%s'\n",m_kindString.data());␊ |
114 | }␊ |
115 | ␊ |
116 | void SectionHandler::startDescription(const QXmlAttributes& attrib)␊ |
117 | {␊ |
118 | DocHandler *docHandler = new DocHandler(this);␊ |
119 | docHandler->startDoc(attrib);␊ |
120 | m_description = docHandler;␊ |
121 | }␊ |
122 | ␊ |
123 | void SectionHandler::endSection()␊ |
124 | {␊ |
125 | m_parent->setDelegate(0);␊ |
126 | }␊ |
127 | ␊ |
128 | void SectionHandler::startMember(const QXmlAttributes& attrib)␊ |
129 | {␊ |
130 | MemberHandler *memHandler = new MemberHandler(this);␊ |
131 | memHandler->startMember(attrib);␊ |
132 | m_members.append(memHandler);␊ |
133 | }␊ |
134 | ␊ |
135 | void SectionHandler::startHeader(const QXmlAttributes&)␊ |
136 | {␊ |
137 | m_header="";␊ |
138 | m_curString="";␊ |
139 | }␊ |
140 | ␊ |
141 | void SectionHandler::endHeader()␊ |
142 | {␊ |
143 | m_header = m_curString.stripWhiteSpace();␊ |
144 | debug(2,"member header=`%s'\n",m_header.data());␊ |
145 | }␊ |
146 | ␊ |
147 | void SectionHandler::initialize(CompoundHandler *ch)␊ |
148 | {␊ |
149 | QListIterator<MemberHandler> mli(m_members);␊ |
150 | MemberHandler *mh;␊ |
151 | for (;(mh=mli.current());++mli)␊ |
152 | {␊ |
153 | mh->setCompoundHandler(ch);␊ |
154 | ch->insertMember(mh);␊ |
155 | mh->setSectionHandler(this);␊ |
156 | }␊ |
157 | }␊ |
158 | ␊ |
159 | IDocRoot *SectionHandler::description() const ␊ |
160 | { ␊ |
161 | return m_description; ␊ |
162 | }␊ |
163 | ␊ |
164 | IMemberIterator *SectionHandler::members() const ␊ |
165 | { ␊ |
166 | return new MemberIterator(m_members); ␊ |
167 | }␊ |
168 | ␊ |
169 |