• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • TDevelop Catalog Library
 

TDevelop Catalog Library

  • lib
  • catalog
tag.h
1/* This file is part of TDevelop
2 Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef TAG_H
21#define TAG_H
22
23#include <tqmap.h>
24#include <tqvariant.h>
25#include <tqshared.h>
26
27class TQDataStream;
28
29union TagFlags
30{
31 unsigned long flags;
32 struct
33 {
34 unsigned long access:
35 3;
36 unsigned long isVirtual:
37 1;
38 }
39 data;
40} ;
41
42class Tag
43{
44public:
45 enum Kind
46 {
47 Kind_Unknown,
48
49 Kind_Typedef = 1000,
50 Kind_Namespace,
51 Kind_UsingDirective,
52 Kind_Base_class,
53 Kind_Enum,
54 Kind_Enumerator,
55 Kind_Class,
56 Kind_Struct,
57 Kind_Union,
58 Kind_VariableDeclaration,
59 Kind_Variable,
60 Kind_FunctionDeclaration,
61 Kind_Function,
62 Kind_NamespaceAlias,
63 Kind_TranslationUnit,
64
65 // ...
66
67 Kind_Custom = 2000
68 };
69
70public:
71 Tag();
72 Tag( const Tag& source );
73 ~Tag();
74
75 operator bool() const {
76 return kind() != Kind_Unknown && kind() != 0;
77 }
78
79 Tag& operator = ( const Tag& source );
80
81 TQCString id() const
82 {
83 return data->id;
84 }
85
86 void setId( const TQCString& id )
87 {
88 detach();
89 data->id = id;
90 }
91
92 int kind() const
93 {
94 return data->kind;
95 }
96
97 void setKind( int kind )
98 {
99 detach();
100 data->kind = kind;
101 }
102
103 unsigned long flags() const
104 {
105 return data->flags;
106 }
107
108 void setFlags( unsigned long flags )
109 {
110 detach();
111 data->flags = flags;
112 }
113
114 TQString fileName() const
115 {
116 return data->fileName;
117 }
118
119 void setFileName( const TQString& fileName )
120 {
121 detach();
122 data->fileName = fileName;
123 }
124
125 TQString path( const TQString& sep = TQString::fromLatin1("::") ) const
126 {
127 TQString s = scope().join( sep );
128 if( s.isNull() )
129 return name();
130 return s + sep + name();
131 }
132
133 TQString name() const
134 {
135 return data->name;
136 }
137
138 TQString comment() const {
139 if( hasAttribute( "cmt" ) ) {
140 return attribute( "cmt" ).asString();
141 } else {
142 return "";
143 }
144 }
145
146 void setComment( const TQString& comment ) {
147 setAttribute( "cmt", comment );
148 }
149
150 void setName( const TQString& name )
151 {
152 detach();
153 data->name = name;
154 }
155
156 TQStringList scope() const
157 {
158 return data->scope;
159 }
160
161 void setScope( const TQStringList& scope )
162 {
163 detach();
164 data->scope = scope;
165 }
166
167 void getStartPosition( int* line, int* column ) const
168 {
169 if( line ) *line = data->startLine;
170 if( column ) *column = data->startColumn;
171 }
172
173 void setStartPosition( int line, int column )
174 {
175 detach();
176 data->startLine = line;
177 data->startColumn = column;
178 }
179
180 void getEndPosition( int* line, int* column ) const
181 {
182 if( line ) *line = data->endLine;
183 if( column ) *column = data->endColumn;
184 }
185
186 void setEndPosition( int line, int column )
187 {
188 detach();
189 data->endLine = line;
190 data->endColumn = column;
191 }
192
193 TQString getSpecializationDeclaration() const {
194 if( hasAttribute( "spc" ) )
195 return data->attributes["spc"].asString();
196 else
197 return TQString();
198 }
199
200 bool hasSpecializationDeclaration() const {
201 return data->attributes.contains( "spc" );
202 }
203
204 void setSpecializationDeclaration( const TQString& str ) {
205 data->attributes["spc"] = str;
206 }
207
208 bool hasAttribute( const TQCString& name ) const
209 {
210 if( name == "kind" ||
211 name == "name" ||
212 name == "scope" ||
213 name == "fileName" ||
214 name == "startLine" ||
215 name == "startColumn" ||
216 name == "endLine" ||
217 name == "endColumn" )
218 return true;
219 return data->attributes.contains( name );
220 }
221
222 TQVariant attribute( const TQCString& name ) const
223 {
224 if( name == "id" )
225 return data->id;
226 else if( name == "kind" )
227 return data->kind;
228 else if( name == "name" )
229 return data->name;
230 else if( name == "scope" )
231 return data->scope;
232 else if( name == "fileName" )
233 return data->fileName;
234 else if( name == "startLine" )
235 return data->startLine;
236 else if( name == "startColumn" )
237 return data->startColumn;
238 else if( name == "endLine" )
239 return data->endLine;
240 else if( name == "endColumn" )
241 return data->endColumn;
242 else if( name == "prefix" )
243 return data->name.left( 2 );
244 return data->attributes[ name ];
245 }
246
247 void setAttribute( const TQCString& name, const TQVariant& value )
248 {
249 detach();
250 if( name == "id" )
251 data->id = value.toCString();
252 else if( name == "kind" )
253 data->kind = value.toInt();
254 else if( name == "name" )
255 data->name = value.toString();
256 else if( name == "scope" )
257 data->scope = value.toStringList();
258 else if( name == "fileName" )
259 data->fileName = value.toString();
260 else if( name == "startLine" )
261 data->startLine = value.toInt();
262 else if( name == "startColumn" )
263 data->startColumn = value.toInt();
264 else if( name == "endLine" )
265 data->endLine = value.toInt();
266 else if( name == "endColumn" )
267 data->endColumn = value.toInt();
268 else
269 data->attributes[ name ] = value;
270 }
271
272 void addTemplateParam( const TQString& param , const TQString& def = "" ) {
273 TQMap<TQCString, TQVariant>::iterator it = data->attributes.find( "tpl" );
274 if( it != data->attributes.end() && (*it).type() == TQVariant::StringList ) {
275 }else{
276 it = data->attributes.insert( "tpl", TQVariant( TQStringList() ) );
277 }
278
279 TQStringList& l( (*it).asStringList() );
280 l << param;
281 l << def;
282 }
283
284 void load( TQDataStream& stream );
285 void store( TQDataStream& stream ) const;
286
287private:
288 Tag copy();
289 void detach();
290
291private:
292 struct TagData: public TQShared
293 {
294 TQCString id;
295 int kind;
296 unsigned long flags;
297 TQString name;
298 TQStringList scope;
299 TQString fileName;
300 int startLine, startColumn;
301 int endLine, endColumn;
302 TQMap<TQCString, TQVariant> attributes;
303 } *data;
304};
305
306TQDataStream& operator << ( TQDataStream&, const Tag& );
307TQDataStream& operator >> ( TQDataStream&, Tag& );
308
309#endif

TDevelop Catalog Library

Skip menu "TDevelop Catalog Library"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

TDevelop Catalog Library

Skip menu "TDevelop Catalog Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for TDevelop Catalog Library by doxygen 1.15.0
This website is maintained by Timothy Pearson.