9 #include <boost/regex.hpp> 11 #include "tbb/concurrent_unordered_map.h" 19 namespace friendlyname {
23 static boost::regex
const reColons(
"::");
24 static boost::regex
const reComma(
",");
42 static boost::regex
const reWrapper(
"edm::Wrapper<(.*)>");
43 static boost::regex
const reString(
"std::basic_string<char>");
44 static boost::regex
const reString2(
"std::string");
45 static boost::regex
const reString3(
"std::basic_string<char,std::char_traits<char> >");
47 static boost::regex
const reCXX11(
"std::__cxx11::");
48 static boost::regex
const reSorted(
"edm::SortedCollection<(.*), *edm::StrictWeakOrdering<\\1 *> >");
49 static boost::regex
const reclangabi(
"std::__1::");
51 static boost::regex
const reLongLong(
"Long64_t");
52 static boost::regex
const reUnsigned(
"unsigned ");
53 static boost::regex
const reLong(
"long ");
54 static boost::regex
const reVector(
"std::vector");
55 static boost::regex
const reSharedPtr(
"std::shared_ptr");
56 static boost::regex
const reUniquePtr(
"std::unique_ptr");
57 static boost::regex
const reAIKR(
", *edm::helper::AssociationIdenticalKeyReference");
60 static boost::regex
const reOwnVector(
"edm::OwnVector<(.*), *edm::ClonePolicy<\\1 *> >");
64 static boost::regex
const reOneToOne(
"edm::AssociationMap< *edm::OneToOne<(.*?),(.*?), *u[a-z]*> >");
65 static boost::regex
const reOneToMany(
"edm::AssociationMap< *edm::OneToMany<(.*?),(.*?), *u[a-z]*> >");
66 static boost::regex
const reOneToValue(
"edm::AssociationMap< *edm::OneToValue<(.*?),(.*?), *u[a-z]*> >");
67 static boost::regex
const reOneToManyWithQuality(
"edm::AssociationMap<edm::OneToManyWithQuality<(.*?), *(.*?), *(.*?), *u[a-z]*> >");
68 static boost::regex
const reToVector(
"edm::AssociationVector<(.*), *(.*), *edm::Ref.*,.*>");
70 static boost::regex
const reToRangeMap(
"edm::RangeMap< *(.*), *(.*), *edm::ClonePolicy<([^>]*)> >");
72 static boost::regex
const reToRefs1(
"edm::RefVector< *(.*)< *(.*) *>, *\\2 *, *edm::refhelper::FindUsingAdvance< *\\1< *\\2 *> *, *\\2 *> *>");
73 static boost::regex
const reToRefs2(
"edm::RefVector< *(.*) *, *(.*) *, *edm::refhelper::FindUsingAdvance< *\\1, *\\2 *> *>");
74 static boost::regex
const reToRefsAssoc(
"edm::RefVector< *Association(.*) *, *edm::helper(.*), *Association(.*)::Find>");
78 using boost::regex_replace;
81 name = regex_replace(name,reAIKR,
"");
82 name = regex_replace(name,reclangabi,
"std::");
83 name = regex_replace(name,reCXX11,
"std::");
84 name = regex_replace(name,reString,
"String");
85 name = regex_replace(name,reString2,
"String");
86 name = regex_replace(name,reString3,
"String");
87 name = regex_replace(name,reSorted,
"sSorted<$1>");
88 name = regex_replace(name,reULongLong,
"ull");
89 name = regex_replace(name,reLongLong,
"ll");
90 name = regex_replace(name,reUnsigned,
"u");
91 name = regex_replace(name,reLong,
"l");
92 name = regex_replace(name,reVector,
"s");
93 name = regex_replace(name,reSharedPtr,
"SharedPtr");
94 name = regex_replace(name,reUniquePtr,
"UniquePtr");
95 name = regex_replace(name,reOwnVector,
"sOwned<$1>");
96 name = regex_replace(name,reToVector,
"AssociationVector<$1,To,$2>");
97 name = regex_replace(name,reOneToOne,
"Association<$1,ToOne,$2>");
98 name = regex_replace(name,reOneToMany,
"Association<$1,ToMany,$2>");
99 name = regex_replace(name,reOneToValue,
"Association<$1,ToValue,$2>");
100 name = regex_replace(name,reOneToManyWithQuality,
"Association<$1,ToMany,$2,WithQuantity,$3>");
101 name = regex_replace(name,reToRangeMap,
"RangeMap<$1,$2>");
102 name = regex_replace(name,reToRefs1,
"Refs<$1<$2>>");
103 name = regex_replace(name,reToRefs2,
"Refs<$1,$2>");
104 name = regex_replace(name,reToRefsAssoc,
"Refs<Association$1>");
111 using namespace boost;
121 regex
const eMatch(
std::string(
"(^[^<]*)<")+aMatch+
">");
122 result = regex_replace(result,eMatch,theSub+
"$1");
128 using namespace boost;
130 bool shouldStop =
false;
132 if(std::string::npos != result.find_first_of(
"<")) {
139 result = regex_replace(result, regex(templateClass),friendlierName);
143 std::cout <<
" no template match for \""<<result<<
"\""<<std::endl;
144 assert(0 ==
"failed to find a match for template class");
150 result = regex_replace(result,
reComma,
"");
154 typedef tbb::concurrent_unordered_map<std::string, std::string> Map;
155 static Map s_fillToFriendlyName;
156 auto itFound = s_fillToFriendlyName.find(iFullName);
157 if(s_fillToFriendlyName.end()==itFound) {
160 return itFound->second;
static boost::regex const reOneToValue("edm::AssociationMap< *edm::OneToValue<(.*?),(.*?), *u[a-z]*> >")
static boost::regex const reTemplateArgs("[^<]*<(.*)>$")
static boost::regex const reSharedPtr("std::shared_ptr")
static boost::regex const reOwnVector("edm::OwnVector<(.*), *edm::ClonePolicy<\\1 *> >")
static boost::regex const reLong("long ")
static boost::regex const reUnsigned("unsigned ")
static boost::regex const reToRangeMap("edm::RangeMap< *(.*), *(.*), *edm::ClonePolicy<([^>]*)> >")
static boost::regex const reSorted("edm::SortedCollection<(.*), *edm::StrictWeakOrdering<\\1 *> >")
static boost::regex const reToRefs2("edm::RefVector< *(.*) *, *(.*) *, *edm::refhelper::FindUsingAdvance< *\\1, *\\2 *> *>")
static boost::regex const reAllSpaces(" +")
std::string removeAllSpaces(std::string const &iIn)
std::string subFriendlyName(std::string const &iFullName)
static boost::regex const reTemplateClass("([^<>,]+<[^<>]*>)")
static boost::regex const reCXX11("std::__cxx11::")
static boost::regex const reOneToMany("edm::AssociationMap< *edm::OneToMany<(.*?),(.*?), *u[a-z]*> >")
static boost::regex const reString3("std::basic_string<char,std::char_traits<char> >")
static boost::regex const reOneToOne("edm::AssociationMap< *edm::OneToOne<(.*?),(.*?), *u[a-z]*> >")
static boost::regex const reVector("std::vector")
static boost::regex const reLongLong("Long64_t")
static boost::regex const reToVector("edm::AssociationVector<(.*), *(.*), *edm::Ref.*,.*>")
static boost::regex const reOneToManyWithQuality("edm::AssociationMap<edm::OneToManyWithQuality<(.*?), *(.*?), *(.*?), *u[a-z]*> >")
Container::value_type value_type
std::string friendlyName(std::string const &iFullName)
static boost::regex const reToRefs1("edm::RefVector< *(.*)< *(.*) *>, *\\2 *, *edm::refhelper::FindUsingAdvance< *\\1< *\\2 *> *, *\\2 *> *>")
std::string handleNamespaces(std::string const &iIn)
static boost::regex const reAIKR(", *edm::helper::AssociationIdenticalKeyReference")
static boost::regex const reULongLong("ULong64_t")
static boost::regex const reBeginSpace("^ +")
std::string standardRenames(std::string const &iIn)
std::string handleTemplateArguments(std::string const &)
static boost::regex const reComma(",")
static boost::regex const reColons("::")
static boost::regex const reclangabi("std::__1::")
static std::string const emptyString("")
static boost::regex const reString("std::basic_string<char>")
static boost::regex const reEndSpace(" +$")
static boost::regex const reWrapper("edm::Wrapper<(.*)>")
static boost::regex const reUniquePtr("std::unique_ptr")
static boost::regex const reString2("std::string")
std::string removeExtraSpaces(std::string const &iIn)
static boost::regex const reToRefsAssoc("edm::RefVector< *Association(.*) *, *edm::helper(.*), *Association(.*)::Find>")