CMS 3D CMS Logo

Functions
edm::friendlyname Namespace Reference

Functions

static std::string const emptyString ("")
 
std::string friendlyName (std::string const &iFullName)
 
std::string handleNamespaces (std::string const &iIn)
 
std::string handleTemplateArguments (std::string const &)
 
static std::regex const reAIKR (", *edm::helper::AssociationIdenticalKeyReference")
 
static std::regex const reAllSpaces (" +")
 
static std::regex const reArray ("\\[\\]")
 
static std::regex const reBeginSpace ("^ +")
 
static std::regex const reclangabi ("std::__1::")
 
static std::regex const reColons ("::")
 
static std::regex const reComma (",")
 
static std::regex const reCXX11 ("std::__cxx11::")
 
static std::regex const reEndSpace (" +$")
 
static std::regex const reLong ("long ")
 
static std::regex const reLongLong ("Long64_t")
 
std::string removeAllSpaces (std::string const &iIn)
 
std::string removeExtraSpaces (std::string const &iIn)
 
static std::regex const reOneToMany ("edm::AssociationMap< *edm::OneToMany<(.*?),(.*?), *u[a-z]*> >")
 
static std::regex const reOneToManyWithQuality ("edm::AssociationMap<edm::OneToManyWithQuality<(.*?), *(.*?), *(.*?), *u[a-z]*> >")
 
static std::regex const reOneToOne ("edm::AssociationMap< *edm::OneToOne<(.*?),(.*?), *u[a-z]*> >")
 
static std::regex const reOneToValue ("edm::AssociationMap< *edm::OneToValue<(.*?),(.*?), *u[a-z]*> >")
 
static std::regex const reOwnVector ("edm::OwnVector<(.*), *edm::ClonePolicy<\\1 *> >")
 
static std::regex const rePointer ("\\*")
 
static std::regex const reSharedPtr ("std::shared_ptr")
 
static std::regex const reSorted ("edm::SortedCollection<(.*), *edm::StrictWeakOrdering<\\1 *> >")
 
static std::regex const reString ("std::basic_string<char>")
 
static std::regex const reString2 ("std::string")
 
static std::regex const reString3 ("std::basic_string<char,std::char_traits<char> >")
 
static std::regex const reTemplateArgs ("[^<]*<(.*)>$")
 
static std::regex const reToRangeMap ("edm::RangeMap< *(.*), *(.*), *edm::ClonePolicy<([^>]*)> >")
 
static std::regex const reToRefs1 ("edm::RefVector< *(.*)< *(.*) *>, *\\2 *, *edm::refhelper::FindUsingAdvance< *\\1< *\\2 *> *, *\\2 *> *>")
 
static std::regex const reToRefs2 ("edm::RefVector< *(.*) *, *(.*) *, *edm::refhelper::FindUsingAdvance< *\\1, *\\2 *> *>")
 
static std::regex const reToRefsAssoc ("edm::RefVector< *Association(.*) *, *edm::helper(.*), *Association(.*)::Find>")
 
static std::regex const reToVector ("edm::AssociationVector<(.*), *(.*), *edm::Ref.*,.*>")
 
static std::regex const reULongLong ("ULong64_t")
 
static std::regex const reUniquePtr ("^std::unique_ptr")
 
static std::regex const reUniquePtrDeleter ("^std::unique_ptr< *(.*), *std::default_delete<\\1> *>")
 
static std::regex const reUnsigned ("unsigned ")
 
static std::regex const reVector ("std::vector")
 
static std::regex const reWrapper ("edm::Wrapper<(.*)>")
 
std::string standardRenames (std::string const &iIn)
 
std::string subFriendlyName (std::string const &iFullName)
 

Function Documentation

static std::string const edm::friendlyname::emptyString ( ""  )
static
std::string edm::friendlyname::friendlyName ( std::string const &  iFullName)

Definition at line 233 of file FriendlyName.cc.

References constexpr, gather_cfg::cout, debug, handleNamespaces(), ZMuMuAnalysisNtupler_cff::prefix, standardRenames(), and subFriendlyName().

Referenced by edm::EventContentAnalyzer::analyze(), edm::MixingModule::beginJob(), gen::FortranInstance::enter(), edm::CFWriter::fctTest(), edm::TypeID::friendlyClassName(), edm::TypeWithDict::friendlyClassName(), gen::FortranInstance::leave(), main(), edm::RootFile::RootFile(), TFWLiteSelectorBasic::setupNewFile(), edm::BranchDescription::updateFriendlyClassName(), gen::FortranInstance::upEvnt(), gen::FortranInstance::upInit(), and gen::FortranInstance::~FortranInstance().

233  {
234  if constexpr (debug) {
235  std::cout << "\nfriendlyName for " << iFullName << std::endl;
236  prefix = " ";
237  }
238  typedef tbb::concurrent_unordered_map<std::string, std::string> Map;
239  static Map s_fillToFriendlyName;
240  auto itFound = s_fillToFriendlyName.find(iFullName);
241  if (s_fillToFriendlyName.end() == itFound) {
242  itFound = s_fillToFriendlyName
243  .insert(Map::value_type(iFullName, handleNamespaces(subFriendlyName(standardRenames(iFullName)))))
244  .first;
245  }
246  if constexpr (debug) {
247  std::cout << "result " << itFound->second << std::endl;
248  }
249  return itFound->second;
250  }
std::string subFriendlyName(std::string const &iFullName)
std::string handleNamespaces(std::string const &iIn)
Definition: FriendlyName.cc:38
#define debug
Definition: HDRShower.cc:19
std::string standardRenames(std::string const &iIn)
Definition: FriendlyName.cc:83
#define constexpr
std::string edm::friendlyname::handleNamespaces ( std::string const &  iIn)

Definition at line 38 of file FriendlyName.cc.

References emptyString(), and reColons().

Referenced by friendlyName().

38 { return std::regex_replace(iIn, reColons, emptyString); }
static std::regex const reColons("::")
static std::string const emptyString("")
std::string edm::friendlyname::handleTemplateArguments ( std::string const &  iIn)

Definition at line 162 of file FriendlyName.cc.

References begin, constexpr, gather_cfg::cout, debug, mps_fire::i, or, ZMuMuAnalysisNtupler_cff::prefix, reComma(), removeExtraSpaces(), mps_fire::result, findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and subFriendlyName().

Referenced by standardRenames(), and subFriendlyName().

162  {
163  using namespace std;
165  if constexpr (debug) {
166  std::cout << prefix << "handleTemplateArguments " << iIn << " removeExtraSpaces " << result << std::endl;
167  }
168 
169  // Trick to have every full class name to end with comma to
170  // avoid treating the end as a special case
171  result += ",";
172 
173  std::string result2;
174  result2.reserve(iIn.size());
175  unsigned int openTemplate = 0;
176  bool hadTemplate = false;
177  size_t begin = 0;
178  for (size_t i = 0, size = result.size(); i < size; ++i) {
179  if (result[i] == '<') {
180  ++openTemplate;
181  hadTemplate = true;
182  continue;
183  } else if (result[i] == '>') {
184  --openTemplate;
185  }
186  // If we are not within the template arguments of a class template
187  // - encountering comma means that we are within a template
188  // argument of some other class template, and we've reached
189  // a point when we should translate the argument class name
190  // - encountering colon, but only if the class name so far
191  // itself was a template, we've reached a point when we
192  // should translate the class name
193  if (const bool hasComma = result[i] == ',', hasColon = hadTemplate and result[i] == ':';
194  openTemplate == 0 and (hasComma or hasColon)) {
195  std::string templateClass = result.substr(begin, i - begin);
196  if constexpr (debug) {
197  std::cout << prefix << " templateClass " << templateClass << std::endl;
198  }
199  if (hadTemplate) {
200  if constexpr (debug) {
201  prefix += " ";
202  }
203  std::string friendlierName = subFriendlyName(templateClass);
204  if constexpr (debug) {
205  prefix.pop_back();
206  prefix.pop_back();
207  std::cout << prefix << " friendlierName " << friendlierName << std::endl;
208  }
209  result2 += friendlierName;
210  } else {
211  result2 += templateClass;
212  }
213  if constexpr (debug) {
214  std::cout << prefix << " result2 " << result2 << std::endl;
215  }
216  // reset counters
217  hadTemplate = false;
218  begin = i + 1;
219  // With colon we need to eat the second colon as well
220  if (hasColon) {
221  assert(result[begin] == ':');
222  ++begin;
223  }
224  }
225  }
226 
227  result = regex_replace(result2, reComma, "");
228  if constexpr (debug) {
229  std::cout << prefix << " reComma " << result << std::endl;
230  }
231  return result;
232  }
size
Write out results.
std::string subFriendlyName(std::string const &iFullName)
static std::regex const reComma(",")
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
#define debug
Definition: HDRShower.cc:19
#define begin
Definition: vmac.h:32
#define constexpr
std::string removeExtraSpaces(std::string const &iIn)
Definition: FriendlyName.cc:40
static std::regex const edm::friendlyname::reAIKR ( ,
*edm::helper::AssociationIdenticalKeyReference  
)
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reAllSpaces ( " +"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reArray ( "\\"  [\\])
static

Referenced by standardRenames().

static std::regex const edm::friendlyname::reBeginSpace ( "^ +"  )
static

Referenced by removeExtraSpaces().

static std::regex const edm::friendlyname::reclangabi ( "std::__1::"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reColons ( "::"  )
static

Referenced by handleNamespaces().

static std::regex const edm::friendlyname::reComma ( ,
 
)
static

Referenced by handleTemplateArguments().

static std::regex const edm::friendlyname::reCXX11 ( "std::__cxx11::"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reEndSpace ( " +$"  )
static

Referenced by removeExtraSpaces().

static std::regex const edm::friendlyname::reLong ( "long "  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reLongLong ( "Long64_t"  )
static

Referenced by removeAllSpaces().

std::string edm::friendlyname::removeAllSpaces ( std::string const &  iIn)
std::string edm::friendlyname::removeExtraSpaces ( std::string const &  iIn)

Definition at line 40 of file FriendlyName.cc.

References emptyString(), reBeginSpace(), and reEndSpace().

Referenced by handleTemplateArguments(), and subFriendlyName().

40  {
41  return std::regex_replace(std::regex_replace(iIn, reBeginSpace, emptyString), reEndSpace, emptyString);
42  }
static std::regex const reEndSpace(" +$")
static std::string const emptyString("")
static std::regex const reBeginSpace("^ +")
static std::regex const edm::friendlyname::reOneToMany ( "edm::AssociationMap< *edm::OneToMany<(.*?),(.*?), *u[a-z]*> >"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reOneToManyWithQuality ( "edm::AssociationMap<edm::OneToManyWithQuality<(.*?), *(.*?), *(.*?), *u[a-z]*> >"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reOneToOne ( "edm::AssociationMap< *edm::OneToOne<(.*?),(.*?), *u[a-z]*> >"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reOneToValue ( "edm::AssociationMap< *edm::OneToValue<(.*?),(.*?), *u[a-z]*> >"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reOwnVector ( "edm::OwnVector<(.*), *edm::ClonePolicy<\\1 *> >"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::rePointer ( "\\*"  )
static

Referenced by standardRenames().

static std::regex const edm::friendlyname::reSharedPtr ( "std::shared_ptr"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reSorted ( "edm::SortedCollection<(.*), *edm::StrictWeakOrdering<\\1 *> >"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reString ( "std::basic_string<char>"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reString2 ( "std::string"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reString3 ( "std::basic_string<char,std::char_traits<char> >"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reTemplateArgs ( "*<(.*)>$"  [^<])
static

Referenced by subFriendlyName().

static std::regex const edm::friendlyname::reToRangeMap ( "edm::RangeMap< *(.*), *(.*), *edm::ClonePolicy<([^>]*)>  ,
 
)
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reToRefs1 ( "edm::RefVector< *(.*)< *(.*) *>, *\\2 *, *edm::refhelper::FindUsingAdvance< *\\1< *\\2 *> *, *\\2 *> *>"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reToRefs2 ( "edm::RefVector< *(.*) *, *(.*) *, *edm::refhelper::FindUsingAdvance< *\\1, *\\2 *> *>"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reToRefsAssoc ( "edm::RefVector< *Association(.*) *, *edm::helper(.*), *Association(.*)::Find>"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reToVector ( "edm::AssociationVector<(.*), *(.*), *edm::Ref.*,.*>"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reULongLong ( "ULong64_t"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reUniquePtr ( "^std::unique_ptr"  )
static

Referenced by subFriendlyName().

static std::regex const edm::friendlyname::reUniquePtrDeleter ( "^std::unique_ptr< *(.*), *std::default_delete<\\1> *>"  )
static

Referenced by subFriendlyName().

static std::regex const edm::friendlyname::reUnsigned ( "unsigned "  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reVector ( "std::vector"  )
static

Referenced by removeAllSpaces().

static std::regex const edm::friendlyname::reWrapper ( "edm::Wrapper<(.*)>"  )
static

Referenced by removeAllSpaces().

std::string edm::friendlyname::standardRenames ( std::string const &  iIn)

Definition at line 83 of file FriendlyName.cc.

References handleTemplateArguments(), Skims_PA_cff::name, reArray(), rePointer(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by friendlyName().

83  {
84  using std::regex;
85  using std::regex_replace;
86  std::string name = regex_replace(iIn, reWrapper, "$1");
87  name = regex_replace(name, rePointer, "ptr");
88  name = regex_replace(name, reArray, "As");
89  name = regex_replace(name, reAIKR, "");
90  name = regex_replace(name, reclangabi, "std::");
91  name = regex_replace(name, reCXX11, "std::");
92  name = regex_replace(name, reString, "String");
93  name = regex_replace(name, reString2, "String");
94  name = regex_replace(name, reString3, "String");
95  name = regex_replace(name, reSorted, "sSorted<$1>");
96  name = regex_replace(name, reULongLong, "ull");
97  name = regex_replace(name, reLongLong, "ll");
98  name = regex_replace(name, reUnsigned, "u");
99  name = regex_replace(name, reLong, "l");
100  name = regex_replace(name, reVector, "s");
101  name = regex_replace(name, reSharedPtr, "SharedPtr");
102  name = regex_replace(name, reOwnVector, "sOwned<$1>");
103  name = regex_replace(name, reToVector, "AssociationVector<$1,To,$2>");
104  name = regex_replace(name, reOneToOne, "Association<$1,ToOne,$2>");
105  name = regex_replace(name, reOneToMany, "Association<$1,ToMany,$2>");
106  name = regex_replace(name, reOneToValue, "Association<$1,ToValue,$2>");
107  name = regex_replace(name, reOneToManyWithQuality, "Association<$1,ToMany,$2,WithQuantity,$3>");
108  name = regex_replace(name, reToRangeMap, "RangeMap<$1,$2>");
109  name = regex_replace(name, reToRefs1, "Refs<$1<$2>>");
110  name = regex_replace(name, reToRefs2, "Refs<$1,$2>");
111  name = regex_replace(name, reToRefsAssoc, "Refs<Association$1>");
112  //std::cout <<"standardRenames '"<<name<<"'"<<std::endl;
113  return name;
114  }
static std::regex const reToRefs1("edm::RefVector< *(.*)< *(.*) *>, *\\2 *, *edm::refhelper::FindUsingAdvance< *\\1< *\\2 *> *, *\\2 *> *>")
static std::regex const reToRangeMap("edm::RangeMap< *(.*), *(.*), *edm::ClonePolicy<([^>]*)> >")
static std::regex const reCXX11("std::__cxx11::")
static std::regex const reAIKR(", *edm::helper::AssociationIdenticalKeyReference")
static std::regex const reString3("std::basic_string<char,std::char_traits<char> >")
static std::regex const reUnsigned("unsigned ")
static std::regex const reSharedPtr("std::shared_ptr")
static std::regex const rePointer("\\*")
static std::regex const reOneToManyWithQuality("edm::AssociationMap<edm::OneToManyWithQuality<(.*?), *(.*?), *(.*?), *u[a-z]*> >")
static std::regex const reToVector("edm::AssociationVector<(.*), *(.*), *edm::Ref.*,.*>")
static std::regex const reLong("long ")
static std::regex const reOneToMany("edm::AssociationMap< *edm::OneToMany<(.*?),(.*?), *u[a-z]*> >")
static std::regex const reOwnVector("edm::OwnVector<(.*), *edm::ClonePolicy<\\1 *> >")
static std::regex const reSorted("edm::SortedCollection<(.*), *edm::StrictWeakOrdering<\\1 *> >")
static std::regex const reLongLong("Long64_t")
static std::regex const reOneToOne("edm::AssociationMap< *edm::OneToOne<(.*?),(.*?), *u[a-z]*> >")
static std::regex const reWrapper("edm::Wrapper<(.*)>")
static std::regex const reArray("\\[\\]")
static std::regex const reToRefsAssoc("edm::RefVector< *Association(.*) *, *edm::helper(.*), *Association(.*)::Find>")
static std::regex const reULongLong("ULong64_t")
static std::regex const reVector("std::vector")
static std::regex const reclangabi("std::__1::")
static std::regex const reString2("std::string")
static std::regex const reString("std::basic_string<char>")
static std::regex const reOneToValue("edm::AssociationMap< *edm::OneToValue<(.*?),(.*?), *u[a-z]*> >")
static std::regex const reToRefs2("edm::RefVector< *(.*) *, *(.*) *, *edm::refhelper::FindUsingAdvance< *\\1, *\\2 *> *>")
std::string edm::friendlyname::subFriendlyName ( std::string const &  iFullName)

Definition at line 117 of file FriendlyName.cc.

References constexpr, gather_cfg::cout, debug, handleTemplateArguments(), eostools::move(), ZMuMuAnalysisNtupler_cff::prefix, removeAllSpaces(), removeExtraSpaces(), mps_fire::result, reTemplateArgs(), reUniquePtr(), reUniquePtrDeleter(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by friendlyName(), and handleTemplateArguments().

117  {
118  using namespace std;
119  std::string result = removeExtraSpaces(iFullName);
120 
121  // temporarily remove leading const
122  std::string leadingConst;
123  if (std::string_view{result}.substr(0, 5) == "const") {
124  leadingConst = "const";
125  result = removeExtraSpaces(result.substr(5));
126  }
127 
128  if constexpr (debug) {
129  std::cout << prefix << "subFriendlyName iFullName " << iFullName << " result " << result << std::endl;
130  }
131  // Handle unique_ptr, which may contain the deleter (but handle only std::default_delete)
132  {
133  auto result2 =
134  regex_replace(result, reUniquePtrDeleter, "UniquePtr<$1>", std::regex_constants::format_first_only);
135  if (result2 == result) {
136  result2 = regex_replace(result, reUniquePtr, "UniquePtr", std::regex_constants::format_first_only);
137  }
138  result = std::move(result2);
139  }
140  // insert the leading const back if it was there
141  result = leadingConst + result;
142  if (smatch theMatch; regex_match(result, theMatch, reTemplateArgs)) {
143  //std::cout <<"found match \""<<theMatch.str(1) <<"\"" <<std::endl;
144  //static regex const templateClosing(">$");
145  //std::string aMatch = regex_replace(theMatch.str(1),templateClosing,"");
146  std::string aMatch = theMatch.str(1);
147  if constexpr (debug) {
148  prefix += " ";
149  }
150  std::string theSub = handleTemplateArguments(aMatch);
151  if constexpr (debug) {
152  prefix.pop_back();
153  prefix.pop_back();
154  std::cout << prefix << " aMatch " << aMatch << " theSub " << theSub << std::endl;
155  }
156  regex const eMatch(std::string("(^[^<]*)<") + aMatch + ">");
157  result = regex_replace(result, eMatch, theSub + "$1");
158  }
159  return removeAllSpaces(result);
160  }
std::string removeAllSpaces(std::string const &iIn)
Definition: FriendlyName.cc:44
static std::regex const reUniquePtrDeleter("^std::unique_ptr< *(.*), *std::default_delete<\\1> *>")
static std::regex const reTemplateArgs("[^<]*<(.*)>$")
#define debug
Definition: HDRShower.cc:19
std::string handleTemplateArguments(std::string const &)
static std::regex const reUniquePtr("^std::unique_ptr")
def move(src, dest)
Definition: eostools.py:511
#define constexpr
std::string removeExtraSpaces(std::string const &iIn)
Definition: FriendlyName.cc:40