Doxygen
symbolresolver.h
浏览该文件的文档.
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 
24 class Definition;
25 class FileDef;
26 class MemberDef;
27 
28 //! Helper class to find a class definition or check if
29 //! A symbol is accessible in a given scope.
31 {
32  public:
33  explicit SymbolResolver(const FileDef *fileScope = 0);
35 
36  // actions
37 
38  /** Find the class definition matching name within
39  * the scope set.
40  * @param scope The scope to search from.
41  * @param name The name of the symbol.
42  * @param maybeUnlinkable include unlinkable symbols in the search.
43  * @param mayBeHidden include hidden symbols in the search.
44  * @note As a result of this call the getters getTypedef(),
45  * getTemplateSpec(), and getResolvedType() are set as well.
46  */
47  const ClassDef *resolveClass(const Definition *scope,
48  const QCString &name,
49  bool maybeUnlinkable=false,
50  bool mayBeHidden=false);
51 
52  /** Wrapper around resolveClass that returns a mutable interface to
53  * the class object or a nullptr if the symbol is immutable.
54  */
56  const QCString &name,
57  bool mayBeUnlinkable=false,
58  bool mayBeHidden=false)
59  {
60  return toClassDefMutable(resolveClass(scope,name,mayBeUnlinkable,mayBeHidden));
61  }
62 
63  /** Checks if symbol \a item is accessible from within \a scope.
64  * @returns -1 if \a item is not accessible or a number indicating how
65  * many scope levels up the nearest match was found.
66  */
67  int isAccessibleFrom(const Definition *scope,
68  const Definition *item);
69 
70  /** Check if symbol \a item is accessible from within \a scope,
71  * where it has to match the \a explicitScopePart.
72  * @returns -1 if \a item is not accessible or a number indicating how
73  * many scope levels up the nearest match was found.
74  */
76  const Definition *item,
77  const QCString &explicitScopePart
78  );
79 
80  /** Sets or updates the file scope using when resolving symbols. */
81  void setFileScope(const FileDef *fd);
82 
83  // getters
84 
85  /** In case a call to resolveClass() resolves to a type member (e.g. an enum)
86  * this method will return it.
87  */
88  const MemberDef *getTypedef() const;
89 
90  /** In case a call to resolveClass() points to a template specialization, the
91  * template part is return via this method.
92  */
93  QCString getTemplateSpec() const;
94 
95  /** In case a call to resolveClass() points to a typedef or using declaration.
96  * The type name it resolved to is returned via this method.
97  */
98  QCString getResolvedType() const;
99 
100  private:
101  struct Private;
102  std::unique_ptr<Private> p;
103 };
104 
105 #endif
SymbolResolver::getTemplateSpec
QCString getTemplateSpec() const
In case a call to resolveClass() points to a template specialization, the template part is return via...
Definition: symbolresolver.cpp:1108
ClassDefMutable
Definition: classdef.h:384
SymbolResolver::setFileScope
void setFileScope(const FileDef *fd)
Sets or updates the file scope using when resolving symbols.
Definition: symbolresolver.cpp:1098
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
SymbolResolver::isAccessibleFromWithExpScope
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.
Definition: symbolresolver.cpp:1089
SymbolResolver
Helper class to find a class definition or check if A symbol is accessible in a given scope.
Definition: symbolresolver.h:30
SymbolResolver::~SymbolResolver
~SymbolResolver()
Definition: symbolresolver.cpp:1028
SymbolResolver::resolveClassMutable
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 ...
Definition: symbolresolver.h:55
qcstring.h
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
SymbolResolver::SymbolResolver
SymbolResolver(const FileDef *fileScope=0)
Definition: symbolresolver.cpp:1023
ClassDef
A abstract class representing of a compound symbol.
Definition: classdef.h:103
SymbolResolver::p
std::unique_ptr< Private > p
Definition: symbolresolver.h:101
SymbolResolver::isAccessibleFrom
int isAccessibleFrom(const Definition *scope, const Definition *item)
Checks if symbol item is accessible from within scope.
Definition: symbolresolver.cpp:1082
SymbolResolver::getTypedef
const MemberDef * getTypedef() const
In case a call to resolveClass() resolves to a type member (e.g.
Definition: symbolresolver.cpp:1103
SymbolResolver::getResolvedType
QCString getResolvedType() const
In case a call to resolveClass() points to a typedef or using declaration.
Definition: symbolresolver.cpp:1113
classdef.h
FileDef
A model of a file symbol.
Definition: filedef.h:73
toClassDefMutable
ClassDefMutable * toClassDefMutable(Definition *d)
Definition: classdef.cpp:4944
SymbolResolver::resolveClass
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.
Definition: symbolresolver.cpp:1033
SymbolResolver::Private
Definition: symbolresolver.cpp:86
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108