Code::Blocks  SVN r11506
token.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  */
5 
6 #ifndef TOKEN_H
7 #define TOKEN_H
8 
9 #include <wx/arrstr.h>
10 #include <wx/string.h>
11 
12 #include <set>
13 #include <map>
14 
15 class Token;
16 class TokenTree;
17 
18 typedef std::set< int, std::less<int> > TokenIdxSet;
19 typedef std::set< size_t, std::less<size_t> > TokenFileSet;
20 
22 {
27 };
28 
30 {
31  // changed in order to reflect the priority
32 
34  tkNamespace = 0x0001,
35 
37  tkClass = 0x0002,
38 
40  tkEnum = 0x0004,
41 
45  tkTypedef = 0x0008,
46 
48  tkConstructor = 0x0010,
49 
51  tkDestructor = 0x0020,
52 
54  tkFunction = 0x0040,
55 
57  tkVariable = 0x0080,
58 
60  tkEnumerator = 0x0100,
61 
63  tkMacroDef = 0x0200,
64 
66  tkMacroUse = 0x0400,
67 
68  // convenient masks
71 
74 
76  tkUndefined = 0xFFFF
77 };
82 class Token
83 {
84 friend class TokenTree;
85 public:
86 
93  Token(const wxString& name, unsigned int file, unsigned int line, size_t ticket);
94 
96  ~Token();
97 
102  bool AddChild(int childIdx);
103 
108  bool DeleteAllChildren();
109 
113  bool HasChildren() const { return !m_Children.empty(); }
114 
121  wxString GetNamespace() const;
122 
130  bool InheritsFrom(int idx) const;
131 
135  wxString DisplayName() const;
136 
139 
142 
144  wxString GetFilename() const;
145 
149  wxString GetImplFilename() const;
150 
152  wxString GetFormattedArgs() const;
153 
158  wxString GetStrippedArgs() const;
159 
161  size_t GetTicket() const { return m_Ticket; }
162 
168  bool MatchesFiles(const TokenFileSet& files);
169 
173  TokenTree* GetTree() const { return m_TokenTree; }
174 
179  bool IsValidAncestor(const wxString& ancestor);
180 
183 
186 
189 
195 
198 
205 
207  unsigned int m_FileIdx;
208 
210  unsigned int m_Line;
211 
214 
216  unsigned int m_ImplFileIdx;
217 
219  unsigned int m_ImplLine;
220 
222  unsigned int m_ImplLineStart;
223 
225  unsigned int m_ImplLineEnd;
226 
229 
232 
235 
238 
242  bool m_IsLocal;
243 
245  bool m_IsTemp;
246 
248  bool m_IsConst;
249 
252 
255 
262  int m_Index;
263 
266 
269 
272 
275 
278 
281 
284 
289 
291  std::map<wxString, wxString> m_TemplateMap;
292 
295 
300  void* m_UserData;
301 
302 protected:
303 
306 
311  size_t m_Ticket;
312 };
313 
314 #endif // TOKEN_H
TokenTree * GetTree() const
get the TokenTree associated with the current Token
Definition: token.h:173
std::map< wxString, wxString > m_TemplateMap
a string to string map from formal template argument to actual template argument
Definition: token.h:291
destructor class member function
Definition: token.h:51
variable
Definition: token.h:57
namespace
Definition: token.h:34
int m_ParentIndex
Parent Token index.
Definition: token.h:265
constructor class member function
Definition: token.h:48
class or struct
Definition: token.h:37
wxString GetFormattedArgs() const
remove all &#39; &#39; in the original function argument string
Definition: token.cpp:199
wxString m_BaseType
this is what the parser believes is the actual return value: e.g.
Definition: token.h:185
bool m_IsAnonymous
Is anonymous token? (e.g.
Definition: token.h:254
wxString m_Name
Token&#39;s name, it can be searched in the TokenTree.
Definition: token.h:188
std::set< size_t, std::less< size_t > > TokenFileSet
Definition: token.h:19
unsigned int m_ImplLine
function implementation line index
Definition: token.h:219
bool IsValidAncestor(const wxString &ancestor)
build in types are not valid ancestors for a type define token
Definition: token.cpp:133
typedef, note typedefs are stored as classes inheriting from the typedef&#39;d type, this takes advantage...
Definition: token.h:45
container like tokens, those tokens can have children tokens
Definition: token.h:70
wxString GetFilename() const
get a full path of the file which contains the current Token
Definition: token.cpp:185
wxString m_BaseArgs
stripped arguments e.g.
Definition: token.h:197
a container class to hold all the Tokens getting from parsing stage
Definition: tokentree.h:37
TokenIdxSet m_Children
if it is a class kind token, then it contains all the member tokens
Definition: token.h:268
unsigned int m_ImplLineStart
if token is impl, opening brace line
Definition: token.h:222
void * m_UserData
custom user-data (the classbrowser expects it to be a pointer to a cbProject), this field is used whe...
Definition: token.h:300
TokenIdxSet m_Ancestors
all the ancestors in the inheritance hierarchy
Definition: token.h:271
unsigned int m_Line
Line index where the token was met, which is 1 based.
Definition: token.h:210
int m_Index
current Token index in the tree, it is index of the std::vector<Token*>, so use the index...
Definition: token.h:262
unsigned int m_ImplLineEnd
if token is impl, closing brace line
Definition: token.h:225
wxString GetNamespace() const
get a literal string presentation of the namespace.
Definition: token.cpp:253
bool m_IsNoExcept
the member method is noexcept (yes/no)
Definition: token.h:251
wxArrayString m_Aliases
used for namespace aliases
Definition: token.h:280
bool m_IsTemp
local (automatic) variable
Definition: token.h:245
TokenScope m_Scope
public? private? protected?
Definition: token.h:231
wxArrayString m_TemplateType
for a class template, this is the formal template argument list, but for a variable Token...
Definition: token.h:288
wxString m_AncestorsString
all ancestors comma-separated list, e.g.
Definition: token.h:204
wxString DisplayName() const
a short simple string to show the token information, this usually generate for show the tip message w...
Definition: token.cpp:80
bool m_IsOperator
is operator overload function?
Definition: token.h:237
bool MatchesFiles(const TokenFileSet &files)
see whether the current token belong to any files in the file set, both m_FileIdx and m_ImplFileIdx i...
Definition: token.cpp:239
unsigned int m_FileIdx
File index in TokenTree.
Definition: token.h:207
wxString GetStrippedArgs() const
remove all default value of the function argument string, e.g.
Definition: token.cpp:206
wxString m_Doc
doxygen style comments
Definition: token.h:213
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
Definition: token.h:82
std::set< int, std::less< int > > TokenIdxSet
Definition: token.h:16
wxString m_TemplateAlias
alias for templates, e.g.
Definition: token.h:294
bool m_IsConst
the member method is const (yes/no)
Definition: token.h:248
bool InheritsFrom(int idx) const
check to see the current token is inherited from a specified token
Definition: token.cpp:289
TokenScope
Definition: token.h:21
bool HasChildren() const
check if the token has any child tokens.
Definition: token.h:113
wxString m_Args
If it is a function Token, then this value is function arguments, e.g.
Definition: token.h:194
wxString GetTokenScopeString() const
the access kind string, e.g.
Definition: token.cpp:333
unsigned int m_ImplFileIdx
function implementation file index
Definition: token.h:216
wxString m_TemplateArgument
template argument list, comma separated list string
Definition: token.h:283
undefined or just "all"
Definition: token.h:76
enum
Definition: token.h:40
TokenIdxSet m_Descendants
all the descendants in the inheritance hierarchy
Definition: token.h:277
TokenTree * m_TokenTree
a pointer to TokenTree
Definition: token.h:305
enumerator
Definition: token.h:60
any kind of functions
Definition: token.h:73
bool DeleteAllChildren()
delete all the child tokens of the current token, not only remove the relation, but also delete the T...
Definition: token.cpp:275
TokenKind m_TokenKind
See TokenKind class.
Definition: token.h:234
general function, not constructor nor destructor
Definition: token.h:54
~Token()
destructor
Definition: token.cpp:73
size_t m_Ticket
This is used in class browser to avoid duplication nodes in the class browser tree.
Definition: token.h:311
macro definition, such as: #define AAA(x,y) f(x,y), where AAA is a token of tkMacroDef ...
Definition: token.h:63
wxString GetImplFilename() const
get a full path of the file which contains the function implementation.
Definition: token.cpp:192
wxString m_ImplDoc
doxygen style comments in the Impl file
Definition: token.h:228
Definition: token.h:26
wxString m_FullType
this is the full return value (if any): e.g.
Definition: token.h:182
size_t GetTicket() const
get the ticket value of the current token
Definition: token.h:161
wxString GetTokenKindString() const
the token kind string, e.g.
Definition: token.cpp:311
bool m_IsLocal
if true, means the token belong to a C::B project, it exists in the project&#39;s source/header files...
Definition: token.h:242
TokenIdxSet m_DirectAncestors
the nearest ancestors
Definition: token.h:274
TokenKind
Definition: token.h:29
the usage of the macro, for example: AAA(1,2)
Definition: token.h:66
bool AddChild(int childIdx)
add a child token
Definition: token.cpp:267