9 #include <boost/regex.hpp>
12 #include "boost/thread/tss.hpp"
20 namespace friendlyname {
24 static boost::regex
const reColons(
"::");
25 static boost::regex
const reComma(
",");
43 static boost::regex
const reWrapper(
"edm::Wrapper<(.*)>");
44 static boost::regex
const reString(
"std::basic_string<char>");
45 static boost::regex
const reSorted(
"edm::SortedCollection<(.*), *edm::StrictWeakOrdering<\\1 *> >");
46 static boost::regex
const reUnsigned(
"unsigned ");
47 static boost::regex
const reLong(
"long ");
48 static boost::regex
const reVector(
"std::vector");
49 static boost::regex
const reAIKR(
", *edm::helper::AssociationIdenticalKeyReference");
52 static boost::regex
const reOwnVector(
"edm::OwnVector<(.*), *edm::ClonePolicy<\\1 *> >");
56 static boost::regex
const reOneToOne(
"edm::AssociationMap< *edm::OneToOne<(.*?),(.*?), *u[a-z]*> >");
57 static boost::regex
const reOneToMany(
"edm::AssociationMap< *edm::OneToMany<(.*?),(.*?), *u[a-z]*> >");
58 static boost::regex
const reOneToValue(
"edm::AssociationMap< *edm::OneToValue<(.*?),(.*?), *u[a-z]*> >");
59 static boost::regex
const reOneToManyWithQuality(
"edm::AssociationMap<edm::OneToManyWithQuality<(.*?), *(.*?), *(.*?), *u[a-z]*> >");
60 static boost::regex
const reToVector(
"edm::AssociationVector<(.*), *(.*), *edm::Ref.*,.*>");
62 static boost::regex
const reToRangeMap(
"edm::RangeMap< *(.*), *(.*), *edm::ClonePolicy<([^>]*)> >");
64 static boost::regex
const reToRefs1(
"edm::RefVector< *(.*)< *(.*) *>, *\\2 *, *edm::refhelper::FindUsingAdvance< *\\1< *\\2 *> *, *\\2 *> *>");
65 static boost::regex
const reToRefs2(
"edm::RefVector< *(.*) *, *(.*) *, *edm::refhelper::FindUsingAdvance< *\\1, *\\2 *> *>");
66 static boost::regex
const reToRefsAssoc(
"edm::RefVector< *Association(.*) *, *edm::helper(.*), *Association(.*)::Find>");
69 using boost::regex_replace;
72 name = regex_replace(name,
reAIKR,
"");
73 name = regex_replace(name,
reString,
"String");
74 name = regex_replace(name,
reSorted,
"sSorted<$1>");
76 name = regex_replace(name,
reLong,
"l");
77 name = regex_replace(name,
reVector,
"s");
78 name = regex_replace(name,
reOwnVector,
"sOwned<$1>");
79 name = regex_replace(name,
reToVector,
"AssociationVector<$1,To,$2>");
80 name = regex_replace(name,
reOneToOne,
"Association<$1,ToOne,$2>");
81 name = regex_replace(name,
reOneToMany,
"Association<$1,ToMany,$2>");
82 name = regex_replace(name,
reOneToValue,
"Association<$1,ToValue,$2>");
84 name = regex_replace(name,
reToRangeMap,
"RangeMap<$1,$2>");
85 name = regex_replace(name,
reToRefs1,
"Refs<$1<$2>>");
86 name = regex_replace(name,
reToRefs2,
"Refs<$1,$2>");
87 name = regex_replace(name,
reToRefsAssoc,
"Refs<Association$1>");
94 using namespace boost;
104 regex
const eMatch(
std::string(
"(^[^<]*)<")+aMatch+
">");
111 using namespace boost;
113 bool shouldStop =
false;
115 if(std::string::npos !=
result.find_first_of(
"<")) {
122 result = regex_replace(
result, regex(templateClass),friendlierName);
127 assert(0 ==
"failed to find a match for template class");
137 typedef std::map<std::string, std::string> Map;
138 static boost::thread_specific_ptr<Map> s_fillToFriendlyName;
139 if(0 == s_fillToFriendlyName.get()){
140 s_fillToFriendlyName.reset(
new Map);
142 Map::const_iterator itFound = s_fillToFriendlyName->find(iFullName);
143 if(s_fillToFriendlyName->end()==itFound) {
146 return itFound->second;
static boost::regex const reOneToValue("edm::AssociationMap< *edm::OneToValue<(.*?),(.*?), *u[a-z]*> >")
static boost::regex const reTemplateArgs("[^<]*<(.*)>$")
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 reOneToMany("edm::AssociationMap< *edm::OneToMany<(.*?),(.*?), *u[a-z]*> >")
static boost::regex const reOneToOne("edm::AssociationMap< *edm::OneToOne<(.*?),(.*?), *u[a-z]*> >")
static boost::regex const reVector("std::vector")
static boost::regex const reToVector("edm::AssociationVector<(.*), *(.*), *edm::Ref.*,.*>")
static boost::regex const reOneToManyWithQuality("edm::AssociationMap<edm::OneToManyWithQuality<(.*?), *(.*?), *(.*?), *u[a-z]*> >")
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)
Container::value_type value_type
static boost::regex const reAIKR(", *edm::helper::AssociationIdenticalKeyReference")
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 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<(.*)>")
std::string removeExtraSpaces(std::string const &iIn)
static boost::regex const reToRefsAssoc("edm::RefVector< *Association(.*) *, *edm::helper(.*), *Association(.*)::Find>")