Doxygen
Loading...
Searching...
No Matches
symbolresolver.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2020 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef SYMBOLRESOLVER_H
17#define SYMBOLRESOLVER_H
18
19#include <memory>
20
21#include "qcstring.h"
22#include "classdef.h"
23#include "construct.h"
24
25class Definition;
26class FileDef;
27class MemberDef;
28
29//! Helper class to find a class definition or check if
30//! A symbol is accessible in a given scope.
32{
33 public:
34 explicit SymbolResolver(const FileDef *fileScope = nullptr);
37
38 // actions
39
40 /** Find the class definition matching name within
41 * the scope set.
42 * @param scope The scope to search from.
43 * @param name The name of the symbol.
44 * @param maybeUnlinkable include unlinkable symbols in the search.
45 * @param mayBeHidden include hidden symbols in the search.
46 * @note As a result of this call the getters getTypedef(),
47 * getTemplateSpec(), and getResolvedType() are set as well.
48 */
49 const ClassDef *resolveClass(const Definition *scope,
50 const QCString &name,
51 bool maybeUnlinkable=false,
52 bool mayBeHidden=false);
53
54 /** Wrapper around resolveClass that returns a mutable interface to
55 * the class object or a nullptr if the symbol is immutable.
56 */
57 ClassDefMutable *resolveClassMutable(const Definition *scope,
58 const QCString &name,
59 bool mayBeUnlinkable=false,
60 bool mayBeHidden=false)
61 {
62 return toClassDefMutable(const_cast<ClassDef*>(resolveClass(scope,name,mayBeUnlinkable,mayBeHidden)));
63 }
64
65 /** Find the symbool definition matching name within the scope set.
66 * @param scope The scope to search from.
67 * @param name The name of the symbol.
68 * @param args Argument list associated with the symbol (for functions)
69 * @param checkCV Check const/volatile qualifiers (for methods)
70 * @param insideCode Is the symbol found in a code fragment
71 */
72 const Definition *resolveSymbol(const Definition *scope,
73 const QCString &name,
74 const QCString &args=QCString(),
75 bool checkCV=false,
76 bool insideCode=false
77 );
78
79 /** Checks if symbol \a item is accessible from within \a scope.
80 * @returns -1 if \a item is not accessible or a number indicating how
81 * many scope levels up the nearest match was found.
82 */
83 int isAccessibleFrom(const Definition *scope,
84 const Definition *item);
85
86 /** Check if symbol \a item is accessible from within \a scope,
87 * where it has to match the \a explicitScopePart.
88 * @returns -1 if \a item is not accessible or a number indicating how
89 * many scope levels up the nearest match was found.
90 */
91 int isAccessibleFromWithExpScope(const Definition *scope,
92 const Definition *item,
93 const QCString &explicitScopePart
94 );
95
96 /** Sets or updates the file scope using when resolving symbols. */
97 void setFileScope(const FileDef *fd);
98
99 // getters
100
101 /** In case a call to resolveClass() resolves to a type member (e.g. an enum)
102 * this method will return it.
103 */
104 const MemberDef *getTypedef() const;
105
106 /** In case a call to resolveClass() points to a template specialization, the
107 * template part is return via this method.
108 */
109 QCString getTemplateSpec() const;
110
111 /** In case a call to resolveClass() points to a typedef or using declaration.
112 * The type name it resolved to is returned via this method.
113 */
114 QCString getResolvedType() const;
115
116 private:
117 struct Private;
118 std::unique_ptr<Private> p;
119};
120
121#endif
The common base class of all entity definitions found in the sources.
Definition definition.h:76
A model of a file symbol.
Definition filedef.h:99
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
const Definition * resolveSymbol(const Definition *scope, const QCString &name, const QCString &args=QCString(), bool checkCV=false, bool insideCode=false)
Find the symbool definition matching name within the scope set.
int isAccessibleFrom(const Definition *scope, const Definition *item)
Checks if symbol item is accessible from within scope.
int isAccessibleFromWithExpScope(const Definition *scope, const Definition *item, const QCString &explicitScopePart)
Check if symbol item is accessible from within scope, where it has to match the explicitScopePart.
QCString getResolvedType() const
In case a call to resolveClass() points to a typedef or using declaration.
std::unique_ptr< Private > p
const ClassDef * resolveClass(const Definition *scope, const QCString &name, bool maybeUnlinkable=false, bool mayBeHidden=false)
Find the class definition matching name within the scope set.
SymbolResolver(const FileDef *fileScope=nullptr)
QCString getTemplateSpec() const
In case a call to resolveClass() points to a template specialization, the template part is return via...
ClassDefMutable * resolveClassMutable(const Definition *scope, const QCString &name, bool mayBeUnlinkable=false, bool mayBeHidden=false)
Wrapper around resolveClass that returns a mutable interface to the class object or a nullptr if the ...
void setFileScope(const FileDef *fd)
Sets or updates the file scope using when resolving symbols.
const MemberDef * getTypedef() const
In case a call to resolveClass() resolves to a type member (e.g.
ClassDefMutable * toClassDefMutable(Definition *d)
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37