12#ifndef R__SELECTIONRULES_H
13#define R__SELECTIONRULES_H
23#include "clang/AST/Decl.h"
39 template <
class ASSOCIATIVECONTAINER>
40 inline bool areEqualAttributes(
const ASSOCIATIVECONTAINER &
c1,
const ASSOCIATIVECONTAINER &
c2,
bool moduloNameOrPattern)
42 auto skipAttr = [](
const std::string &s) {
43 return "pattern" == s ||
"name" == s ||
"file_name" == s;
45 if (
c1.size() !=
c2.size()) {
47 auto skipSizeCheck =
true;
48 for (
auto &&coll : {
c1,
c2})
50 for (
auto &&keyValPair : coll) {
51 skipSizeCheck = skipSizeCheck && skipAttr(keyValPair.first);
58 if (moduloNameOrPattern) {
59 for (
auto &&keyValPairC1 :
c1) {
60 auto keyC1 = keyValPairC1.first;
63 auto valC1 = keyValPairC1.second;
64 auto C2It =
c2.find(keyC1);
65 if (C2It ==
c2.end() || valC1 != C2It->second)
75 inline bool areEqual(
const RULE* r1,
const RULE* r2,
bool moduloNameOrPattern =
false){
76 return areEqualAttributes(r1->GetAttributes(), r2->GetAttributes(), moduloNameOrPattern);
79 template<
class RULESCOLLECTION>
81 const RULESCOLLECTION& r2,
82 bool moduloNameOrPattern =
false){
83 if (r1.size() != r2.size())
return false;
84 auto rIt1 = r1.begin();
85 auto rIt2 = r2.begin();
86 for (;rIt1!=r1.cend();++rIt1,++rIt2){
87 if (!
areEqual(&(*rIt1),&(*rIt2), moduloNameOrPattern))
return false;
94 bool moduloNameOrPattern){
121 const std::vector<std::pair<std::string,std::string>>& namesForExclusion):
128 for (
auto& attrValPair : namesForExclusion){
212 bool IsParentClass(
const clang::Decl* D, std::string& parent_name, std::string& parent_qual_name)
const;
215 bool GetParentName(
const clang::Decl* D, std::string& parent_name, std::string& parent_qual_name)
const;
222 bool GetDeclName(
const clang::Decl* D, std::string&
name, std::string& qual_name)
const;
225 void GetDeclQualName(
const clang::Decl* D, std::string& qual_name)
const;
VariableSelectionRule EnumSelectionRule
VariableSelectionRule FunctionSelectionRule
void SetAttributeValue(const std::string &attributeName, const std::string &attributeValue)
void SetSelected(ESelect sel)
const AttributesMap_t & GetAttributes() const
const std::list< FunctionSelectionRule > & GetMethodSelectionRules() const
const std::list< VariableSelectionRule > & GetFieldSelectionRules() const
SelectionRules(cling::Interpreter &interp, ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, const std::vector< std::pair< std::string, std::string > > &namesForExclusion)
bool HasFunctionSelectionRules() const
const BaseSelectionRule * IsLinkdefVarSelected(const clang::VarDecl *D, const std::string &qual_name) const
const std::list< ClassSelectionRule > & GetClassSelectionRules() const
void GetDeclQualName(const clang::Decl *D, std::string &qual_name) const
const BaseSelectionRule * IsVarSelected(const clang::VarDecl *D, const std::string &qual_name) const
const BaseSelectionRule * IsFunSelected(const clang::FunctionDecl *D, const std::string &qual_name) const
void AddVariableSelectionRule(const VariableSelectionRule &varSel)
bool HasEnumSelectionRules() const
void AddClassSelectionRule(const ClassSelectionRule &classSel)
std::list< VariableSelectionRule > fVariableSelectionRules
List of the global variables selection rules.
bool AreAllSelectionRulesUsed() const
ESelectionFileTypes fSelectionFileType
bool GetFunctionPrototype(const clang::FunctionDecl *F, std::string &prototype) const
bool SearchNames(cling::Interpreter &interp)
bool GetParentName(const clang::Decl *D, std::string &parent_name, std::string &parent_qual_name) const
std::list< FunctionSelectionRule > fFunctionSelectionRules
List of the global functions selection rules.
const BaseSelectionRule * IsLinkdefFunSelected(const clang::FunctionDecl *D, const std::string &qual_name) const
std::list< EnumSelectionRule > fEnumSelectionRules
List of the enums selection rules.
void PrintSelectionRules() const
bool GetHasFileNameRule() const
ROOT::TMetaUtils::TNormalizedCtxt & fNormCtxt
bool HasClassSelectionRules() const
bool IsLinkdefFile() const
bool GetDeclName(const clang::Decl *D, std::string &name, std::string &qual_name) const
const std::list< FunctionSelectionRule > & GetFunctionSelectionRules() const
unsigned int Size() const
bool fHasFileNameRule
if we have a file name rule, this should be set to true
ESelectionFileTypes
Type of selection file.
void AddEnumSelectionRule(const EnumSelectionRule &enumSel)
const std::list< EnumSelectionRule > & GetEnumSelectionRules() const
const BaseSelectionRule * IsMemberSelected(const clang::Decl *D, const std::string &str_name) const
bool IsSelectionXMLFile() const
const std::list< VariableSelectionRule > & GetVariableSelectionRules() const
void ClearSelectionRules()
bool IsParentClass(const clang::Decl *D) const
const BaseSelectionRule * IsLinkdefEnumSelected(const clang::EnumDecl *D, const std::string &qual_name) const
void AddFunctionSelectionRule(const FunctionSelectionRule &funcSel)
bool HasVariableSelectionRules() const
const BaseSelectionRule * IsEnumSelected(const clang::EnumDecl *D, const std::string &qual_name) const
const ClassSelectionRule * IsDeclSelected(const clang::RecordDecl *D, bool includeTypedefRule) const
const ClassSelectionRule * IsNamespaceSelected(const clang::Decl *D, const std::string &qual_name) const
std::list< ClassSelectionRule > fClassSelectionRules
List of the class selection rules.
cling::Interpreter & fInterp
void SetHasFileNameRule(bool file_rule)
void SetSelectionFileType(ESelectionFileTypes fileType)
const BaseSelectionRule * IsLinkdefMethodSelected(const clang::Decl *D, const std::string &qual_name) const
const ClassSelectionRule * IsClassSelected(const clang::Decl *D, const std::string &qual_name, bool includeTypedefRule) const
bool areEqualColl(const RULESCOLLECTION &r1, const RULESCOLLECTION &r2, bool moduloNameOrPattern=false)
bool areEqual(const RULE *r1, const RULE *r2, bool moduloNameOrPattern=false)
bool areEqualAttributes(const ASSOCIATIVECONTAINER &c1, const ASSOCIATIVECONTAINER &c2, bool moduloNameOrPattern)
bool areEqual< ClassSelectionRule >(const ClassSelectionRule *r1, const ClassSelectionRule *r2, bool moduloNameOrPattern)