12 #ifndef R__BASESELECTIONRULE_H
13 #define R__BASESELECTIONRULE_H
26 #include <unordered_map>
39 class BaseSelectionRule
42 typedef std::unordered_map<std::string, std::string> AttributesMap_t;
59 std::string fSelFileName=
"";
60 AttributesMap_t fAttributes;
62 std::list<std::string> fSubPatterns;
63 std::list<std::string> fFileSubPatterns;
65 const clang::CXXRecordDecl *fCXXRecordDecl;
66 const clang::Type *fRequestedType;
67 cling::Interpreter *fInterp;
70 std::string fName =
"";
71 std::string fPattern =
"";
72 std::string fProtoName =
"";
73 std::string fProtoPattern =
"";
74 std::string fFileName =
"";
75 std::string fFilePattern =
"";
76 std::string fNArgsToKeep =
"";
77 bool fHasNameAttribute =
false;
78 bool fHasProtoNameAttribute =
false;
79 bool fHasPatternAttribute =
false;
80 bool fHasProtoPatternAttribute =
false;
81 bool fHasFileNameAttribute =
false;
82 bool fHasFilePatternAttribute =
false;
83 bool fHasFromTypedefAttribute =
false;
84 bool fIsFromTypedef =
false;
88 BaseSelectionRule(ESelect sel) : fIndex(-1),fIsSelected(sel),fMatchFound(false),fCXXRecordDecl(NULL),fRequestedType(NULL),fInterp(NULL) {}
90 BaseSelectionRule(
long index, cling::Interpreter &interp,
const char* selFileName =
"",
long lineno=-1) : fIndex(index),fLineNumber(lineno),fSelFileName(selFileName),fIsSelected(kNo),fMatchFound(false),fCXXRecordDecl(0),fRequestedType(0),fInterp(&interp) {}
92 BaseSelectionRule(
long index, ESelect sel,
const std::string& attributeName,
const std::string& attributeValue, cling::Interpreter &interp,
const char* selFileName =
"",
long lineno=-1);
94 virtual ~BaseSelectionRule() =
default;
96 virtual void DebugPrint()
const;
97 virtual void Print(std::ostream &out)
const = 0;
99 long GetIndex()
const {
return fIndex; }
100 void SetIndex(
long index) { fIndex=index; }
102 long GetLineNumber()
const {
return fLineNumber; }
103 const char* GetSelFileName()
const {
return fSelFileName.c_str(); }
105 bool HasAttributeWithName(
const std::string& attributeName)
const;
109 bool GetAttributeValue(
const std::string& attributeName, std::string& returnValue)
const;
111 inline const std::string& GetAttributeName()
const {
return fName;};
112 inline bool HasAttributeName()
const {
return fHasNameAttribute;};
114 inline const std::string& GetAttributeProtoName()
const {
return fProtoName;};
115 inline bool HasAttributeProtoName()
const {
return fHasProtoNameAttribute;};
117 inline const std::string& GetAttributePattern()
const {
return fPattern;};
118 inline bool HasAttributePattern()
const {
return fHasPatternAttribute;};
120 inline const std::string& GetAttributeProtoPattern()
const {
return fProtoPattern;};
121 inline bool HasAttributeProtoPattern()
const {
return fHasProtoPatternAttribute;};
123 inline const std::string& GetAttributeFileName()
const {
return fFileName;};
124 inline bool HasAttributeFileName()
const {
return fHasFileNameAttribute;};
126 inline const std::string& GetAttributeFilePattern()
const {
return fFilePattern;};
127 inline bool HasAttributeFilePattern()
const {
return fHasFilePatternAttribute;};
129 inline bool IsFromTypedef()
const {
return fIsFromTypedef;};
130 inline bool HasAttributeFromTypedef()
const {
return fHasFromTypedefAttribute;};
132 inline const std::string& GetAttributeNArgsToKeep()
const {
return fNArgsToKeep;};
134 void SetAttributeValue(
const std::string& attributeName,
const std::string& attributeValue);
136 ESelect GetSelected()
const;
137 void SetSelected(ESelect sel);
139 bool HasInterpreter()
const {
return fInterp!=NULL; };
140 void SetInterpreter(cling::Interpreter& interp) {fInterp=&interp; };
142 const AttributesMap_t& GetAttributes()
const;
143 void PrintAttributes(
int level)
const;
144 void PrintAttributes(std::ostream &out,
int level)
const;
146 EMatchType Match(
const clang::NamedDecl *decl,
const std::string& name,
const std::string& prototype,
bool isLinkdef)
const;
148 void SetMatchFound(
bool match);
149 bool GetMatchFound()
const;
151 const clang::Type *GetRequestedType()
const;
152 inline const clang::CXXRecordDecl *GetCXXRecordDecl()
const {
return fCXXRecordDecl;} ;
153 void SetCXXRecordDecl(
const clang::CXXRecordDecl *decl,
const clang::Type *typeptr);
159 inline bool CheckPattern(
const std::string& test,
const std::string& pattern,
const std::list<std::string>& patterns_list,
bool isLinkdef)
const;
161 inline void ProcessPattern(
const std::string& pattern, std::list<std::string>& out)
const;
164 inline std::ostream &operator<<(std::ostream& out,
const BaseSelectionRule &obj)