CppParser
Loading...
Searching...
No Matches
CppVisitorMatcher Class Reference

#include <cppvisitormatcher.h>

Inheritance diagram for CppVisitorMatcher:
Inheritance graph
Collaboration diagram for CppVisitorMatcher:
Collaboration graph

Public Member Functions

 CppVisitorMatcher (const std::vector< CppObjType > &typesToMatch)
 The only ctor of the class. More...
 
 CppVisitorMatcher (const std::vector< CppObjType > &typesToMatch, MatchedFuncType &&matchedFunc)
 
virtual bool matched (CppObj *p)
 The virtual method to be called when a tree node is matched. More...
 
 ~CppVisitorMatcher () override=default
 
- Public Member Functions inherited from CppVisitorBase
virtual ~CppVisitorBase ()=default
 
virtual bool visit (CppVarType *p)=0
 The visitor pattern's visit methods for the given types. More...
 
virtual bool visit (CppCompound *p)=0
 
virtual bool visit (CppUnRecogPrePro *p)=0
 
virtual bool visit (CppUndef *p)=0
 
virtual bool visit (CppUsingDecl *p)=0
 
virtual bool visit (CppUsingNamespaceDecl *p)=0
 
virtual bool visit (CppVar *p)=0
 
virtual bool visit (CppVarList *p)=0
 
virtual bool visit (CppCommonBlock< CppObjType::kIfBlock > *p)=0
 
virtual bool visit (CppCommonBlock< CppObjType::kWhileBlock > *p)=0
 
virtual bool visit (CppCommonBlock< CppObjType::kDoWhileBlock > *p)=0
 
virtual bool visit (CppAsmBlock *p)=0
 
virtual bool visit (CppBlob *p)=0
 
virtual bool visit (CppDefine *p)=0
 
virtual bool visit (CppDocComment *p)=0
 
virtual bool visit (CppEnum *p)=0
 
virtual bool visit (CppExpr *p)=0
 
virtual bool visit (CppForBlock *p)=0
 
virtual bool visit (CppLambda *p)=0
 
virtual bool visit (CppDestructor *p)=0
 
virtual bool visit (CppConstructor *p)=0
 
virtual bool visit (CppFunction *p)=0
 
virtual bool visit (CppFunctionPointer *p)=0
 
virtual bool visit (CppTypeConverter *p)=0
 
virtual bool visit (CppFwdClsDecl *p)=0
 
virtual bool visit (CppHashError *p)=0
 
virtual bool visit (CppHashIf *p)=0
 
virtual bool visit (CppHashWarning *p)=0
 
virtual bool visit (CppImport *p)=0
 
virtual bool visit (CppInclude *p)=0
 
virtual bool visit (CppLabel *p)=0
 
virtual bool visit (CppMacroCall *p)=0
 
virtual bool visit (CppNamespaceAlias *p)=0
 
virtual bool visit (CppPragma *p)=0
 
virtual bool visit (CppRangeForBlock *p)=0
 
virtual bool visit (CppSwitchBlock *p)=0
 
virtual bool visit (CppTryBlock *p)=0
 
virtual bool visit (CppTypedefList *p)=0
 
virtual bool visit (CppTypedefName *p)=0
 

Protected Member Functions

bool visit (CppVarType *p) override
 The visitor pattern's visit methods for the given types. More...
 
bool visit (CppCompound *p) override
 
bool visit (CppUnRecogPrePro *p) override
 
bool visit (CppUndef *p) override
 
bool visit (CppUsingDecl *p) override
 
bool visit (CppUsingNamespaceDecl *p) override
 
bool visit (CppVar *p) override
 
bool visit (CppVarList *p) override
 
bool visit (CppCommonBlock< CppObjType::kIfBlock > *p) override
 
bool visit (CppCommonBlock< CppObjType::kWhileBlock > *p) override
 
bool visit (CppCommonBlock< CppObjType::kDoWhileBlock > *p) override
 
bool visit (CppAsmBlock *p) override
 
bool visit (CppBlob *p) override
 
bool visit (CppDefine *p) override
 
bool visit (CppDocComment *p) override
 
bool visit (CppEnum *p) override
 
bool visit (CppExpr *p) override
 
bool visit (CppForBlock *p) override
 
bool visit (CppLambda *p) override
 
bool visit (CppDestructor *p) override
 
bool visit (CppConstructor *p) override
 
bool visit (CppFunction *p) override
 
bool visit (CppFunctionPointer *p) override
 
bool visit (CppTypeConverter *p) override
 
bool visit (CppFwdClsDecl *p) override
 
bool visit (CppHashError *p) override
 
bool visit (CppHashIf *p) override
 
bool visit (CppHashWarning *p) override
 
bool visit (CppImport *p) override
 
bool visit (CppInclude *p) override
 
bool visit (CppLabel *p) override
 
bool visit (CppMacroCall *p) override
 
bool visit (CppNamespaceAlias *p) override
 
bool visit (CppPragma *p) override
 
bool visit (CppRangeForBlock *p) override
 
bool visit (CppSwitchBlock *p) override
 
bool visit (CppTryBlock *p) override
 
bool visit (CppTypedefList *p) override
 
bool visit (CppTypedefName *p) override
 

Private Types

using MatchedFuncType = std::function< bool(CppObj *p)>
 

Private Member Functions

bool check (CppObj *p)
 Checks the given pointer to the current AST node against the node types that are to be matched. More...
 

Private Attributes

const std::vector< CppObjTypetypesToMatch
 
MatchedFuncType matchedFunc
 

Detailed Description

Definition at line 19 of file cppvisitormatcher.h.

Member Typedef Documentation

◆ MatchedFuncType

using CppVisitorMatcher::MatchedFuncType = std::function<bool(CppObj* p)>
private

Definition at line 21 of file cppvisitormatcher.h.

Constructor & Destructor Documentation

◆ CppVisitorMatcher() [1/2]

CppVisitorMatcher::CppVisitorMatcher ( const std::vector< CppObjType > &  typesToMatch)
inlineexplicit

The only ctor of the class.

Parameters
typesToMatchA vector of the AST node types that are to be matched.

Definition at line 30 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ CppVisitorMatcher() [2/2]

CppVisitorMatcher::CppVisitorMatcher ( const std::vector< CppObjType > &  typesToMatch,
MatchedFuncType &&  matchedFunc 
)
inlineexplicit

Definition at line 38 of file cppvisitormatcher.h.

◆ ~CppVisitorMatcher()

CppVisitorMatcher::~CppVisitorMatcher ( )
overridedefault

Member Function Documentation

◆ check()

bool CppVisitorMatcher::check ( CppObj p)
inlineprivate

Checks the given pointer to the current AST node against the node types that are to be matched.

Calls the match method when a node is matched and returns the value returned by that method to enforce user's choice for an early abortion of traversing the rest of the AST.

Parameters
pA pointer to an AST node.
Returns
true if the node did not match, otherwise, returns the value returned by CppVisitorMatcher::match.

Definition at line 66 of file cppvisitormatcher.h.

Here is the caller graph for this function:

◆ matched()

virtual bool CppVisitorMatcher::matched ( CppObj p)
inlinevirtual

The virtual method to be called when a tree node is matched.

Override this method to implement your very own AST-matcher.

Parameters
pA pointer to the matched AST node.
Returns
Return true if you want continue traversing the tree, false otherwise.

Definition at line 50 of file cppvisitormatcher.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ visit() [1/39]

bool CppVisitorMatcher::visit ( CppAsmBlock p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 120 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [2/39]

bool CppVisitorMatcher::visit ( CppBlob p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 124 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [3/39]

bool CppVisitorMatcher::visit ( CppCommonBlock< CppObjType::kDoWhileBlock > *  p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 116 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [4/39]

bool CppVisitorMatcher::visit ( CppCommonBlock< CppObjType::kIfBlock > *  p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 108 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [5/39]

bool CppVisitorMatcher::visit ( CppCommonBlock< CppObjType::kWhileBlock > *  p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 112 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [6/39]

bool CppVisitorMatcher::visit ( CppCompound p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 80 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [7/39]

bool CppVisitorMatcher::visit ( CppConstructor p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 156 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [8/39]

bool CppVisitorMatcher::visit ( CppDefine p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 128 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [9/39]

bool CppVisitorMatcher::visit ( CppDestructor p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 152 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [10/39]

bool CppVisitorMatcher::visit ( CppDocComment p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 132 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [11/39]

bool CppVisitorMatcher::visit ( CppEnum p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 136 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [12/39]

bool CppVisitorMatcher::visit ( CppExpr p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 140 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [13/39]

bool CppVisitorMatcher::visit ( CppForBlock p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 144 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [14/39]

bool CppVisitorMatcher::visit ( CppFunction p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 160 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [15/39]

bool CppVisitorMatcher::visit ( CppFunctionPointer p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 164 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [16/39]

bool CppVisitorMatcher::visit ( CppFwdClsDecl p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 172 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [17/39]

bool CppVisitorMatcher::visit ( CppHashError p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 176 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [18/39]

bool CppVisitorMatcher::visit ( CppHashIf p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 180 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [19/39]

bool CppVisitorMatcher::visit ( CppHashWarning p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 184 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [20/39]

bool CppVisitorMatcher::visit ( CppImport p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 188 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [21/39]

bool CppVisitorMatcher::visit ( CppInclude p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 192 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [22/39]

bool CppVisitorMatcher::visit ( CppLabel p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 196 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [23/39]

bool CppVisitorMatcher::visit ( CppLambda p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 148 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [24/39]

bool CppVisitorMatcher::visit ( CppMacroCall p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 200 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [25/39]

bool CppVisitorMatcher::visit ( CppNamespaceAlias p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 204 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [26/39]

bool CppVisitorMatcher::visit ( CppPragma p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 208 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [27/39]

bool CppVisitorMatcher::visit ( CppRangeForBlock p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 212 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [28/39]

bool CppVisitorMatcher::visit ( CppSwitchBlock p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 216 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [29/39]

bool CppVisitorMatcher::visit ( CppTryBlock p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 220 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [30/39]

bool CppVisitorMatcher::visit ( CppTypeConverter p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 168 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [31/39]

bool CppVisitorMatcher::visit ( CppTypedefList p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 224 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [32/39]

bool CppVisitorMatcher::visit ( CppTypedefName p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 228 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [33/39]

bool CppVisitorMatcher::visit ( CppUndef p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 88 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [34/39]

bool CppVisitorMatcher::visit ( CppUnRecogPrePro p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 84 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [35/39]

bool CppVisitorMatcher::visit ( CppUsingDecl p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 92 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [36/39]

bool CppVisitorMatcher::visit ( CppUsingNamespaceDecl p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 96 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [37/39]

bool CppVisitorMatcher::visit ( CppVar p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 100 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [38/39]

bool CppVisitorMatcher::visit ( CppVarList p)
inlineoverrideprotectedvirtual

Implements CppVisitorBase.

Definition at line 104 of file cppvisitormatcher.h.

Here is the call graph for this function:

◆ visit() [39/39]

bool CppVisitorMatcher::visit ( CppVarType p)
inlineoverrideprotectedvirtual

The visitor pattern's visit methods for the given types.

Parameters
pA pointer to the matched AST node.
Returns
Return true if you want continue traversing the tree, false otherwise.

Implements CppVisitorBase.

Definition at line 76 of file cppvisitormatcher.h.

Here is the call graph for this function:

Member Data Documentation

◆ matchedFunc

MatchedFuncType CppVisitorMatcher::matchedFunc
private

Definition at line 23 of file cppvisitormatcher.h.

◆ typesToMatch

const std::vector<CppObjType> CppVisitorMatcher::typesToMatch
private

Definition at line 22 of file cppvisitormatcher.h.


The documentation for this class was generated from the following file: