35 struct ShuttingDownSignaler :
public T {
38 ~ShuttingDownSignaler()
40 if (gInterpreterHelper)
46namespace std {}
using namespace std;
55 if (
name.compare(0,5,
"std::")==0) {
60 if (gInterpreterHelper) {
61 for(
size_t i = 5; i <
name.length(); ++i) {
62 if (
name[i] ==
'<')
break;
65 std::string scope(
name.data(),i);
66 std::string scoperesult;
69 static ShuttingDownSignaler<std::set<std::string>> gInlined;
71 if (gInlined.find(scope) != gInlined.end()) {
73 if (i+1<
name.length() &&
name[i+1]==
':') {
80 gInlined.insert(scope);
82 if (i+1<
name.length() &&
name[i+1]==
':') {
115 name.remove_prefix(len);
123 if (0 == strncmp(clName,
"complex<", 8)) {
124 const char *clNamePlus8 = clName + 8;
125 if (0 == strcmp(
"float>", clNamePlus8)) {
126 return EComplexType::kFloat;
128 if (0 == strcmp(
"double>", clNamePlus8)) {
129 return EComplexType::kDouble;
131 if (0 == strcmp(
"int>", clNamePlus8)) {
132 return EComplexType::kInt;
134 if (0 == strcmp(
"long>", clNamePlus8)) {
135 return EComplexType::kLong;
149 if (
this == gInterpreterHelper)
150 gInterpreterHelper =
nullptr;
157 gInterpreterHelper = helper;
193 if (fElements[0].empty())
return 0;
194 int numb = fElements.size();
195 if (!fElements[numb-1].empty() && fElements[numb-1][0]==
'*') --numb;
197 if ( fNestedLocation ) {
203 int kind =
STLKind(fElements[0]);
208 if (testAlloc && (numb-1 > nargs) && !
IsDefAlloc(fElements[numb-1].c_str(),fElements[1].c_str())) {
220 if (k<0) kind = -kind;
226 if(kind>2) kind = - kind;
246 int narg = fElements.size();
257 if (fElements[narg-1].empty() ==
false &&
258 (fElements[narg-1][0]==
'*'
259 || fElements[narg-1][0]==
'&'
260 || fElements[narg-1][0]==
'['
261 || 0 == fElements[narg-1].compare(0,6,
"const*")
262 || 0 == fElements[narg-1].compare(0,6,
"const&")
263 || 0 == fElements[narg-1].compare(0,6,
"const[")
264 || 0 == fElements[narg-1].compare(
"const")
267 if ((mode&1)==0) tailLoc = narg-1;
269 else { assert(fElements[narg-1].empty()); };
273 if (fNestedLocation) narg--;
278 const int kind =
STLKind(fElements[0]);
279 const int iall =
STLArgs(kind);
283 while(narg-1>iall) { fElements.pop_back(); narg--;}
284 if (!fElements[0].empty() && tailLoc) {
287 fElements[0].clear();
295 bool allocRemoved =
false;
301 if (narg-1 == iall+1) {
303 bool dropAlloc =
false;
318 dropAlloc =
IsDefAlloc(fElements[iall+1].c_str(),fElements[1].c_str());
324 dropAlloc =
IsDefAlloc(fElements[iall+1].c_str(),fElements[1].c_str(),fElements[2].c_str());
342 if (
IsDefComp( fElements[iall].c_str(), fElements[1].c_str() ) ) {
357 if (!allocRemoved && narg-1 == iall+1) {
361 if (narg-1 == iall) narg--;
384 bool predRemoved =
false;
387 if (
IsDefPred( fElements[iall].c_str(), fElements[1].c_str() ) ) {
394 if (
IsDefHash( fElements[iall-1].c_str(), fElements[1].c_str() ) ) {
402 unsigned int offset = (0==strncmp(
"const ",fElements[0].c_str(),6)) ? 6 : 0;
403 offset += (0==strncmp(
"std::",fElements[0].c_str()+offset,5)) ? 5 : 0;
404 if (0 == strcmp(fElements[0].c_str()+offset,
"__shared_ptr"))
407 static const std::string sharedPtrDef = std::to_string(__gnu_cxx::__default_lock_policy);
409 static const std::string sharedPtrDef = std::to_string(2);
411 if (fElements[2] == sharedPtrDef) {
419 for (
int i=1;i<narg; i++) {
420 if (strchr(fElements[i].c_str(),
'<')==0) {
422 unsigned int offset = (0==strncmp(
"const ",fElements[i].c_str(),6)) ? 6 : 0;
436 if (gInterpreterHelper &&
439 if (!typeresult.empty()) fElements[i] = typeresult;
444 unsigned int tailOffset = 0;
445 if (tailLoc && fElements[tailLoc].compare(0,5,
"const") == 0) {
449 if (!fElements[0].empty()) {answ += fElements[0]; answ +=
"<";}
458 int nargNonDefault = 0;
459 std::string nonDefName = answ;
461 std::string nameSuperLong = fName;
462 if (gInterpreterHelper)
464 while (++nargNonDefault < narg) {
467 const char* closeTemplate =
" >";
468 if (nonDefName[nonDefName.length() - 1] !=
'>')
470 string nondef = nonDefName + closeTemplate;
471 if (gInterpreterHelper &&
474 if (nargNonDefault>1) nonDefName +=
",";
475 nonDefName += fElements[nargNonDefault];
477 if (nargNonDefault < narg)
478 narg = nargNonDefault;
482 {
for (
int i=1;i<narg-1; i++) { answ += fElements[i]; answ+=
",";} }
483 if (narg>1) { answ += fElements[narg-1]; }
485 if (!fElements[0].empty()) {
486 if ( answ.at(answ.size()-1) ==
'>') {
492 if (fNestedLocation) {
495 answ += fElements[fNestedLocation];
498 if (tailLoc) answ += fElements[tailLoc].c_str()+tailOffset;
505 return !fElements[0].empty();
515 if (
type.compare(0,6,
"const ")==0) { offset += 6; }
519 static const char *stls[] =
520 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
521 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap", 0};
522 static const size_t stllen[] =
523 { 3, 6, 4, 5, 3, 8, 3, 8, 6,
524 12, 13, 18, 13, 18, 0};
539 auto len =
type.length();
542 for(
int k=1;stls[k];k++) {
543 if (len == stllen[k]) {
544 if (
type.compare(offset,len,stls[k])==0)
return values[k];
548 for(
int k=1;stls[k];k++) {
if (
type.compare(offset,len,stls[k])==0)
return values[k];}
558 static const char stln[] =
560 { 1, 1, 1, 1, 3, 3, 2, 2, 1,
572 for(
size_t i = 0; i < full.length(); ++i) {
574 case '<': { ++level;
break; }
576 if (level == 0)
return i;
581 if (level == 0)
return i;
587 return full.length();
594 return pos +
findNameEnd( {full.data()+pos,full.length()-pos} );
606 if (
a==
"alloc")
return true;
607 if (
a==
"__default_alloc_template<true,0>")
return true;
608 if (
a==
"__malloc_alloc_template<0>")
return true;
610 const static int alloclen = strlen(
"allocator<");
611 if (
a.compare(0,alloclen,
"allocator<") != 0) {
614 a.remove_prefix(alloclen);
621 if (
a.compare(0,k.length(),k) != 0) {
625 std::string valuepart;
628 std::string norm_value;
631 if (valuepart != norm_value) {
634 a.remove_prefix(end);
636 a.remove_prefix(k.length());
639 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
651 const char *keyclassname,
652 const char *valueclassname)
654 if (
IsDefAlloc(allocname,keyclassname))
return true;
659 const static int alloclen = strlen(
"allocator<");
660 if (
a.compare(0,alloclen,
"allocator<") != 0) {
663 a.remove_prefix(alloclen);
667 const static int pairlen = strlen(
"pair<");
668 if (
a.compare(0,pairlen,
"pair<") != 0) {
671 a.remove_prefix(pairlen);
673 const static int constlen = strlen(
"const");
674 if (
a.compare(0,constlen+1,
"const ") == 0) {
675 a.remove_prefix(constlen+1);
682 if (k.compare(0,constlen+1,
"const ") == 0) {
683 k.remove_prefix(constlen+1);
686 if (
a.compare(0,k.length(),k) != 0) {
690 std::string alloc_keypart;
693 std::string norm_key;
696 if (alloc_keypart != norm_key) {
697 if ( norm_key[norm_key.length()-1] ==
'*' ) {
701 norm_key +=
" const";
703 if (alloc_keypart != norm_key) {
707 a.remove_prefix(end);
709 size_t end = k.length();
710 if ( (
a[end-1] ==
'*') ||
a[end]==
' ' ) {
711 size_t skipSpace = (
a[end] ==
' ');
712 if (
a.compare(end+skipSpace,constlen,
"const") == 0) {
713 end += constlen+skipSpace;
716 a.remove_prefix(end);
728 if (
a.compare(0,
v.length(),
v) != 0) {
732 std::string valuepart;
735 std::string norm_value;
738 if (valuepart != norm_value) {
741 a.remove_prefix(end);
743 a.remove_prefix(
v.length());
746 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
757static bool IsDefElement(
const char *elementName,
const char* defaultElementName,
const char *classname)
759 string c = elementName;
763 const int elementlen = strlen(defaultElementName);
764 if (
c.compare(pos,elementlen,defaultElementName) != 0) {
769 string k = classname;
770 if (
c.compare(pos,k.length(),k) != 0) {
777 std::string norm_key;
780 if (keypart != norm_key) {
788 if (
c.compare(pos,1,
">")!=0 &&
c.compare(pos,2,
" >")!=0) {
834 norm_name = std::string(
name);
856 if (norm_name.length()>2 && norm_name[0]==
':' && norm_name[1]==
':') {
857 norm_name.erase(0,2);
860 if (gInterpreterHelper) {
862 std::string typeresult;
866 if (!typeresult.empty()) norm_name = typeresult;
887 static const char* longlong_s =
"long long";
888 static const char* ulonglong_s =
"unsigned long long";
889 static const unsigned int longlong_len = strlen(longlong_s);
890 static const unsigned int ulonglong_len = strlen(ulonglong_s);
892 string result = original;
895 while( (pos = result.find(ulonglong_s,pos) ) >=0 ) {
896 result.replace(pos, ulonglong_len,
"ULong64_t");
899 while( (pos = result.find(longlong_s,pos) ) >=0 ) {
900 result.replace(pos, longlong_len,
"Long64_t");
910 const char *lastPos = original;
913 for(
auto cursor = original; *cursor !=
'\0'; ++cursor) {
914 if ( *cursor ==
'<' || *cursor ==
'(') ++depth;
915 else if ( *cursor ==
'>' || *cursor ==
')' ) --depth;
916 else if ( *cursor ==
':' ) {
917 if (depth==0 && *(cursor+1) ==
':' && *(cursor+2) !=
'\0') {
932 const char *t = full.c_str();
933 const unsigned int tlen( full.size() );
935 const char *starloc = t + tlen - 1;
936 bool hasconst =
false;
938 && (starloc-t) > 4 && 0 == strncmp((starloc-4),
"const",5)
939 && ( (*(starloc-5)) ==
' ' || (*(starloc-5)) ==
'*' || (*(starloc-5)) ==
'&'
940 || (*(starloc-5)) ==
'>' || (*(starloc-5)) ==
']') ) {
943 if ((*starloc-1)==
' ') {
949 if ( hasconst || (*starloc)==
'*' || (*starloc)==
'&' || (*starloc)==
']' ) {
950 bool isArray = ( (*starloc)==
']' );
951 while( t<=(starloc-1) && ((*(starloc-1))==
'*' || (*(starloc-1))==
'&' || (*(starloc-1))==
't' || isArray)) {
954 isArray = ! ( (*starloc)==
'[' );
955 }
else if ( (*(starloc-1))==
't' ) {
956 if ( (starloc-1-t) > 5 && 0 == strncmp((starloc-5),
"const",5)
957 && ( (*(starloc-6)) ==
' ' || (*(starloc-6)) ==
'*' || (*(starloc-6)) ==
'&'
958 || (*(starloc-6)) ==
'>' || (*(starloc-6)) ==
']')) {
969 if ((*(starloc-1))==
' ') {
974 const unsigned int starlen = strlen(starloc);
975 full.erase(tlen-starlen,starlen);
976 }
else if (hasconst) {
978 const unsigned int starlen = strlen(starloc);
979 full.erase(tlen-starlen,starlen);
999 if (strlen(
type)==0)
return 0;
1001 int cleantypeMode = 1 ;
1010 unsigned int const_offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1011 bool isString =
false;
1012 bool isStdString =
false;
1013 size_t std_offset = const_offset;
1014 static const char* basic_string_std =
"std::basic_string<char";
1015 static const unsigned int basic_string_std_len = strlen(basic_string_std);
1017 if (full.compare(const_offset,basic_string_std_len,basic_string_std) == 0
1018 && full.size() > basic_string_std_len) {
1022 }
else if (full.compare(const_offset,basic_string_std_len-5,basic_string_std+5) == 0
1023 && full.size() > (basic_string_std_len-5)) {
1026 }
else if (full.find(
"basic_string") != std::string::npos) {
1027 size_t len =
StdLen(full.c_str() + const_offset);
1028 if (len && len != 5 && full.compare(const_offset + len, basic_string_std_len-5, basic_string_std+5) == 0) {
1035 size_t offset = basic_string_std_len - 5;
1036 offset += std_offset;
1037 if ( full[offset] ==
'>' ) {
1039 }
else if (full[offset] ==
',') {
1041 if (full.compare(offset, 5,
"std::") == 0) {
1044 static const char* char_traits_s =
"char_traits<char>";
1045 static const unsigned int char_traits_len = strlen(char_traits_s);
1046 if (full.compare(offset, char_traits_len, char_traits_s) == 0) {
1047 offset += char_traits_len;
1048 if ( full[offset] ==
'>') {
1050 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1053 }
else if (full[offset] ==
',') {
1055 if (full.compare(offset, 5,
"std::") == 0) {
1058 static const char* allocator_s =
"allocator<char>";
1059 static const unsigned int allocator_len = strlen(allocator_s);
1060 if (full.compare(offset, allocator_len, allocator_s) == 0) {
1061 offset += allocator_len;
1062 if ( full[offset] ==
'>') {
1064 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1085 output.push_back(
string());
1087 if (isStdString && !(mode &
kDropStd)) {
1088 output.push_back(
"const std::string");
1090 output.push_back(
"const string");
1093 if (isStdString && !(mode &
kDropStd)) {
1094 output.push_back(
"std::string");
1096 output.push_back(
"string");
1099 if (offset < full.length()) {
1102 string right( full.substr(offset) );
1105 output.back().append(right.c_str()+1);
1116 unsigned int offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1121 if ( !full.empty() ) {
1125 const char *
c = strchr(full.c_str(),
'<');
1128 output.push_back(
string(full,0,
c - full.c_str()));
1132 int parenthesis = 0;
1133 for(cursor =
c + 1; *cursor !=
'\0' && !(level==0 && *cursor ==
'>'); ++cursor) {
1134 if (*cursor ==
'(') {
1137 }
else if (*cursor ==
')') {
1144 case '<': ++level;
break;
1145 case '>': --level;
break;
1148 output.push_back(std::string(
c+1,cursor));
1155 if (*(cursor-1) ==
' ') {
1156 output.push_back(std::string(
c+1,cursor-1));
1158 output.push_back(std::string(
c+1,cursor));
1161 if (*(cursor+1)==
':') {
1164 nestedLoc =
output.size();
1165 output.push_back((cursor+1));
1167 }
else if (level >= 0) {
1169 output.push_back(std::string(
c+1,cursor));
1173 output.push_back(
string());
1200 static const char* remove[] = {
"class",
"const",
"volatile",0};
1201 static bool isinit =
false;
1202 static std::vector<size_t> lengths;
1204 for (
int k=0; remove[k]; ++k) {
1205 lengths.push_back(strlen(remove[k]));
1211 result.reserve(strlen(typeDesc)*2);
1215 for(
c=typeDesc;*
c;
c++) {
1218 if (!isalnum(
c[ 1]) &&
c[ 1] !=
'_')
continue;
1220 if (kbl && (mode>=2 || lev==0)) {
1222 int n = (mode) ? 999 : 1;
1225 for (
int k=0; k<
n && remove[k]; k++) {
1226 int rlen = lengths[k];
1229 if (strncmp(remove[k],
c,rlen))
continue;
1232 if (isalnum(
c[rlen]) ||
c[rlen]==
'_' ||
c[rlen]==
'$')
continue;
1234 c+=rlen-1; done = 1;
break;
1239 kbl = (!isalnum(
c[ 0]) &&
c[ 0]!=
'_' &&
c[ 0]!=
'$' &&
c[0]!=
'[' &&
c[0]!=
']' &&
c[0]!=
'-' &&
c[0]!=
'@');
1243 if (*
c ==
'<' || *
c ==
'(') lev++;
1244 if (lev==0 && !isalnum(*
c)) {
1245 if (!strchr(
"*&:._$ []-@",*
c))
break;
1249 if (
c[0]==
'>' && result.size() && result[result.size()-1]==
'>') result+=
" ";
1253 if (*
c ==
'>' || *
c ==
')') lev--;
1290 size_t len = strlen(
type);
1291 if (len < 2 || strncmp(
type+len-2,
"_t",2) != 0)
return false;
1293 unsigned char offset = 0;
1294 if (strncmp(
type,
"const ",6)==0) { offset += 6; }
1295 static const char *names[] = {
"CallFunc_t",
"ClassInfo_t",
"BaseClassInfo_t",
1296 "DataMemberInfo_t",
"FuncTempInfo_t",
"MethodInfo_t",
"MethodArgInfo_t",
1297 "TypeInfo_t",
"TypedefInfo_t",0};
1299 for(
int k=1;names[k];k++) {
if (strcmp(
type+offset,names[k])==0)
return true;}
1308 size_t offset =
StdLen(classname);
1309 if ( strncmp(classname+offset,
"bitset<",strlen(
"bitset<"))==0)
return true;
1327 if (
type.compare(0,6,
"const ",6) == 0)
1328 type.remove_prefix(6);
1330 while(
type[
type.length()-1]==
'*' ||
1333 type.remove_suffix(1);
1346 auto pos =
type.find(
'<');
1350 for (
decltype(
type.length()) level = 1;
c <
type.length(); ++
c) {
1351 if (
type[
c] ==
'<') ++level;
1352 if (
type[
c] ==
'>') --level;
1353 if (level == 0)
break;
1355 if (
c != (
type.length()-1) ) {
1375 if (strchr(
type,
'<')==0)
return 0;
1386 classname +=
StdLen( classname );
1387 if ( strcmp(classname,
"string")==0 )
return true;
1388 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1389 if ( strncmp(classname,
"pair<",strlen(
"pair<"))==0)
return true;
1390 if ( strcmp(classname,
"allocator")==0)
return true;
1391 if ( strncmp(classname,
"allocator<",strlen(
"allocator<"))==0)
return true;
1392 if ( strncmp(classname,
"greater<",strlen(
"greater<"))==0)
return true;
1393 if ( strncmp(classname,
"less<",strlen(
"less<"))==0)
return true;
1394 if ( strncmp(classname,
"equal_to<",strlen(
"equal_to<"))==0)
return true;
1395 if ( strncmp(classname,
"hash<",strlen(
"hash<"))==0)
return true;
1396 if ( strncmp(classname,
"auto_ptr<",strlen(
"auto_ptr<"))==0)
return true;
1398 if ( strncmp(classname,
"vector<",strlen(
"vector<"))==0)
return true;
1399 if ( strncmp(classname,
"list<",strlen(
"list<"))==0)
return true;
1400 if ( strncmp(classname,
"forward_list<",strlen(
"forward_list<"))==0)
return true;
1401 if ( strncmp(classname,
"deque<",strlen(
"deque<"))==0)
return true;
1402 if ( strncmp(classname,
"map<",strlen(
"map<"))==0)
return true;
1403 if ( strncmp(classname,
"multimap<",strlen(
"multimap<"))==0)
return true;
1404 if ( strncmp(classname,
"set<",strlen(
"set<"))==0)
return true;
1405 if ( strncmp(classname,
"multiset<",strlen(
"multiset<"))==0)
return true;
1406 if ( strncmp(classname,
"unordered_set<",strlen(
"unordered_set<"))==0)
return true;
1407 if ( strncmp(classname,
"unordered_multiset<",strlen(
"unordered_multiset<"))==0)
return true;
1408 if ( strncmp(classname,
"unordered_map<",strlen(
"unordered_map<"))==0)
return true;
1409 if ( strncmp(classname,
"unordered_multimap<",strlen(
"unordered_multimap<"))==0)
return true;
1410 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1429 unsigned int cursor,
1431 unsigned int start_of_type,
1432 unsigned int end_of_type,
1433 unsigned int mod_start_of_type,
1435 std::string &result)
1437 std::string
type(modified && (mod_start_of_type < result.length()) ?
1438 result.substr(mod_start_of_type, string::npos)
1439 :
string(tname, start_of_type, end_of_type == 0 ? cursor - start_of_type : end_of_type - start_of_type));
1444 if (!typeresult.empty()) {
1447 result.replace(mod_start_of_type, string::npos,
1452 mod_start_of_type = start_of_type;
1453 result += string(tname,0,start_of_type);
1454 if (constprefix && typeresult.compare(0,6,
"const ",6) == 0) {
1455 result += typeresult.substr(6,string::npos);
1457 result += typeresult;
1460 }
else if (modified) {
1461 result.replace(mod_start_of_type, string::npos,
1465 if (end_of_type != 0 && end_of_type!=cursor) {
1466 result += std::string(tname,end_of_type,cursor-end_of_type);
1473 if (end_of_type != 0 && end_of_type!=cursor) {
1474 result += std::string(tname,end_of_type,cursor-end_of_type);
1484 unsigned int &cursor,
1486 std::string &result)
1493 bool constprefix =
false;
1495 if (tname[cursor]==
' ') {
1498 result += string(tname,0,cursor);
1500 while (tname[cursor]==
' ') ++cursor;
1503 if (tname[cursor]==
'c' && (cursor+6<len)) {
1504 if (strncmp(tname+cursor,
"const ",6) == 0) {
1506 if (modified) result +=
"const ";
1512 if (len > 2 && strncmp(tname+cursor,
"::",2) == 0) {
1516 unsigned int start_of_type = cursor;
1517 unsigned int end_of_type = 0;
1518 unsigned int mod_start_of_type = result.length();
1519 unsigned int prevScope = cursor;
1520 for ( ; cursor<len; ++cursor) {
1521 switch (tname[cursor]) {
1523 if ((cursor+1)>=len || tname[cursor+1]!=
':') {
1525 if (modified) result += (tname+prevScope);
1530 scope = result.substr(mod_start_of_type, string::npos);
1531 scope += std::string(tname+prevScope,cursor-prevScope);
1533 scope = std::string(tname, start_of_type, cursor - start_of_type);
1535 std::string scoperesult;
1536 bool isInlined =
false;
1540 if (!scoperesult.empty()) {
1543 if (constprefix && scoperesult.compare(0,6,
"const ",6) != 0) mod_start_of_type -= 6;
1544 result.replace(mod_start_of_type, string::npos,
1549 mod_start_of_type = start_of_type;
1550 result += string(tname,0,start_of_type);
1552 result += scoperesult;
1555 }
else if (modified) {
1556 result += std::string(tname+prevScope,cursor+2-prevScope);
1560 if (modified) result += std::string(tname+prevScope,cursor+2-prevScope);
1561 }
else if (isInlined) {
1565 mod_start_of_type = start_of_type;
1566 result += string(tname,0,start_of_type);
1568 result += string(tname,start_of_type,prevScope - start_of_type);
1570 }
else if (modified) {
1571 result += std::string(tname+prevScope,cursor+2-prevScope);
1575 prevScope = cursor+1;
1581 result += std::string(tname+prevScope,cursor+1-prevScope);
1587 }
while( cursor<len && tname[cursor] ==
',' );
1589 while (cursor<len && tname[cursor+1]==
' ') ++cursor;
1594 if (cursor+2<len && tname[cursor+1]==
':' && tname[cursor+2]==
':') {
1595 if (modified) result +=
"::";
1597 prevScope = cursor+1;
1599 if ( (cursor+1)<len && tname[cursor+1] ==
',') {
1601 if (modified) result +=
',';
1604 if ( (cursor+1)<len && tname[cursor+1] ==
'>') {
1606 if (modified) result +=
" >";
1609 if ( (cursor+1) >= len) {
1612 if (tname[cursor] !=
' ')
break;
1613 if (modified) prevScope = cursor+1;
1620 end_of_type = cursor;
1622 while ((cursor+1)<len && tname[cursor+1] ==
' ') ++cursor;
1624 auto next = cursor+1;
1625 if (strncmp(tname+next,
"const",5) == 0 && ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
']'))
1630 result += string(tname,0,start_of_type);
1632 mod_start_of_type = start_of_type + 6;
1633 result += string(tname,start_of_type,end_of_type-start_of_type);
1634 }
else if (mod_start_of_type < result.length()) {
1635 result.insert(mod_start_of_type,
"const ");
1636 mod_start_of_type += 6;
1639 mod_start_of_type += 6;
1640 result += string(tname,start_of_type,end_of_type-start_of_type);
1643 end_of_type = cursor+1;
1644 prevScope = end_of_type;
1645 if ((next+5)==len || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1648 }
else if (next!=len && tname[next] !=
'*' && tname[next] !=
'&') {
1658 if (tname[cursor] !=
' ') end_of_type = cursor;
1660 auto next = cursor+1;
1661 if (strncmp(tname+next,
"const",5) == 0) {
1662 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1667 (tname[next] ==
' ' || tname[next] ==
'*' || tname[next] ==
'&')) {
1670 if (strncmp(tname+next,
"const",5) == 0) {
1671 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1683 if (modified && prevScope) {
1684 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1688 if (modified) result +=
',';
1692 if (modified && prevScope) {
1693 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1697 if (modified) result +=
'>';
1705 if (prevScope && modified) result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1722 if (tname == 0 || tname[0] == 0)
1724 if (!gInterpreterHelper)
1733 if (result.empty())
return tname;
1737 unsigned int len = strlen(tname);
1739 unsigned int cursor = 0;
1740 bool modified =
false;
1743 if (!modified)
return tname;
1757 static const char* sSTLtypes[] = {
1770 "basic_istringstream",
1773 "basic_ostringstream",
1777 "basic_stringstream",
1806 "istreambuf_iterator",
1815 "localedef utility",
1832 "moneypunct_byname",
1844 "ostreambuf_iterator",
1850 "pointer_to_binary_function",
1851 "pointer_to_unary_function",
1855 "raw_storage_iterator",
1874 "unordered_multimap",
1875 "unordered_multiset",
1881 static ShuttingDownSignaler<set<string>> sSetSTLtypes;
1883 if (tname==0 || tname[0]==0)
return "";
1885 if (sSetSTLtypes.empty()) {
1887 const size_t nSTLtypes =
sizeof(sSTLtypes) /
sizeof(
const char*);
1888 for (
size_t i = 0; i < nSTLtypes; ++i)
1889 sSetSTLtypes.insert(sSTLtypes[i]);
1893 size_t len = strlen(tname);
1895 ret.reserve(len + 20);
1899 bool precScope =
false;
1900 while (!(isalnum(tname[
b]) || tname[
b] ==
'_') &&
b < len) {
1901 precScope = (
b < len - 2) && (tname[
b] ==
':') && (tname[
b + 1] ==
':');
1913 while (
e < len && (isalnum(tname[
e]) || tname[
e] ==
'_'))
1917 set<string>::const_iterator iSTLtype = sSetSTLtypes.find(
id);
1918 if (iSTLtype != sSetSTLtypes.end())
1933class NameCleanerForIO {
1935 std::vector<std::unique_ptr<NameCleanerForIO>> fArgumentNodes = {};
1936 NameCleanerForIO* fMother;
1937 bool fHasChanged =
false;
1938 bool AreAncestorsSTLContOrArray()
1940 NameCleanerForIO* mother = fMother;
1941 if (!mother)
return false;
1942 bool isSTLContOrArray =
true;
1943 while (
nullptr != mother){
1946 mother = mother->fMother;
1949 return isSTLContOrArray;
1953 NameCleanerForIO(
const std::string& clName =
"",
1955 NameCleanerForIO* mother =
nullptr):fMother(mother)
1957 if (clName.back() !=
'>') {
1962 std::vector<std::string>
v;
1967 auto argsEnd =
v.end();
1968 auto argsBeginPlusOne = ++
v.begin();
1969 auto argPos = std::find_if(argsBeginPlusOne, argsEnd,
1970 [](std::string& arg){
return (!arg.empty() && arg.front() ==
':');});
1971 if (argPos != argsEnd) {
1972 const int lenght = clName.size();
1973 int wedgeBalance = 0;
1974 int lastOpenWedge = 0;
1975 for (
int i=lenght-1;i>-1;i--) {
1976 auto&
c = clName.at(i);
1980 }
else if (
c ==
'>') {
1982 }
else if (
c ==
':' && 0 == wedgeBalance) {
1984 auto nameToClean = clName.substr(0,i-1);
1985 NameCleanerForIO node(nameToClean, mode);
1986 auto cleanName = node.ToString();
1987 fHasChanged = node.HasChanged();
1993 cleanName += clName.substr(i+1,lastOpenWedge-i-1);
1996 auto lastTemplate = &clName.data()[i+1];
2008 unsigned int nargs =
v.size() - 2;
2009 for (
unsigned int i=0;i<nargs;++i) {
2010 fArgumentNodes.emplace_back(
new NameCleanerForIO(
v[i+1],mode,
this));
2014 bool HasChanged()
const {
return fHasChanged;}
2018 std::string
name(fName);
2020 if (fArgumentNodes.empty())
return name;
2025 name = fArgumentNodes.front()->ToString();
2028 tst.ShortType(
name, 1);
2034 auto stlContType = AreAncestorsSTLContOrArray();
2036 name = fArgumentNodes.front()->ToString();
2043 for (
auto& node : fArgumentNodes) {
2044 name += node->ToString() +
",";
2045 fHasChanged |= node->HasChanged();
2048 name +=
name.back() ==
'>' ?
" >" :
">";
2052 const std::string&
GetName() {
return fName;}
2053 const std::vector<std::unique_ptr<NameCleanerForIO>>* GetChildNodes()
const {
return &fArgumentNodes;}
2069 NameCleanerForIO node(templateInstanceName, mode);
2070 auto nameForIO = node.ToString();
2072 *hasChanged = node.HasChanged();
2081 std::string& typeNameBuf,
2082 std::array<int, 5>& maxIndices,
2088 NameCleanerForIO node(typeName);
2091 auto childNodes = node.GetChildNodes();
2092 for (ndim = 1;ndim <=5 ; ndim++) {
2093 maxIndices[ndim-1] = std::atoi(childNodes->back()->GetName().c_str());
2094 auto& frontNode = childNodes->front();
2095 typeNameBuf = frontNode->GetName();
2097 typeNameBuf = frontNode->ToString();
2100 childNodes = frontNode->GetChildNodes();
2113 const char* mangled_name = ti.name();
2119struct FunctionSplitInfo {
2121 std::string fReturnType;
2124 std::string fScopeName;
2127 std::string fFunctionName;
2131 std::vector<std::string> fFunctionTemplateArguments;
2134 std::vector<std::string> fFunctionParameters;
2143 std::stack<char> expected;
2144 for (std::size_t pos = 0, end = haystack.length(); pos < end; ++pos) {
2145 char c = haystack[pos];
2146 if (expected.empty()) {
2147 if (needles.find(
c) != std::string_view::npos)
2150 if (
c == expected.top()) {
2156 case '<': expected.emplace(
'>');
break;
2157 case '(': expected.emplace(
')');
break;
2158 case '[': expected.emplace(
']');
break;
2161 return std::string_view::npos;
2167 std::size_t lenHaystack = haystack.length();
2168 std::size_t prevAfterColumn = 0;
2170 std::size_t posColumn = FindNonNestedNeedles(haystack.substr(prevAfterColumn),
":");
2171 if (posColumn == std::string_view::npos)
2172 return std::string_view::npos;
2173 prevAfterColumn += posColumn;
2175 if (prevAfterColumn + 1 >= lenHaystack)
2176 return std::string_view::npos;
2179 if (haystack[prevAfterColumn] ==
':')
2180 return prevAfterColumn - 1;
2184 return std::string_view::npos;
2189 while (!str.empty() && std::isspace(str[0]))
2190 str.remove_prefix(1);
2191 while (!str.empty() && std::isspace(str.back()))
2192 str.remove_suffix(1);
2200 return std::string(sv.data(), sv.length());
2213 std::size_t posArgs = FindNonNestedNeedles(decl,
"(");
2216 std::size_t prevAfterWhiteSpace = 0;
2217 static const char whitespace[] =
" \t\n";
2218 while (declNoArgs.length() > prevAfterWhiteSpace) {
2219 std::size_t posWS = FindNonNestedNeedles(declNoArgs.substr(prevAfterWhiteSpace), whitespace);
2220 if (posWS == std::string_view::npos)
2222 prevAfterWhiteSpace += posWS + 1;
2223 while (declNoArgs.length() > prevAfterWhiteSpace
2224 && strchr(whitespace, declNoArgs[prevAfterWhiteSpace]))
2225 ++prevAfterWhiteSpace;
2229 std::size_t endReturn = prevAfterWhiteSpace;
2230 while (declNoArgs.length() > endReturn
2231 && strchr(
"&* \t \n", declNoArgs[endReturn]))
2238 std::size_t prevAtScope = FindNonNestedDoubleColons(scopeFunctionTmplt);
2239 while (prevAtScope != std::string_view::npos
2240 && scopeFunctionTmplt.length() > prevAtScope + 2) {
2241 std::size_t posScope = FindNonNestedDoubleColons(scopeFunctionTmplt.substr(prevAtScope + 2));
2242 if (posScope == std::string_view::npos)
2244 prevAtScope += posScope + 2;
2247 std::size_t afterScope = prevAtScope + 2;
2248 if (prevAtScope == std::string_view::npos) {
2253 result.
fScopeName =
ToString(StripSurroundingSpace(scopeFunctionTmplt.substr(0, prevAtScope)));
2257 std::size_t posTmpltOpen = FindNonNestedNeedles(funcNameTmplArgs,
"<");
2258 if (posTmpltOpen != std::string_view::npos) {
2263 std::size_t posTmpltClose = FindNonNestedNeedles(tmpltArgs,
">");
2264 if (posTmpltClose != std::string_view::npos) {
2265 tmpltArgs = tmpltArgs.substr(0, posTmpltClose);
2266 std::size_t prevAfterArg = 0;
2267 while (tmpltArgs.length() > prevAfterArg) {
2268 std::size_t posComma = FindNonNestedNeedles(tmpltArgs.substr(prevAfterArg),
",");
2269 if (posComma == std::string_view::npos) {
2273 prevAfterArg += posComma + 1;
2283 if (posArgs != std::string_view::npos) {
2286 std::size_t posEndArgs = FindNonNestedNeedles(params,
")");
2287 if (posEndArgs != std::string_view::npos) {
2288 params = params.substr(0, posEndArgs);
2289 std::size_t prevAfterArg = 0;
2290 while (params.length() > prevAfterArg) {
2291 std::size_t posComma = FindNonNestedNeedles(params.substr(prevAfterArg),
",");
2292 if (posComma == std::string_view::npos) {
2297 prevAfterArg += posComma + 1;
static RooMathCoreReg dummy
static void R__FindTrailing(std::string &full, std::string &stars)
static void ResolveTypedefImpl(const char *tname, unsigned int len, unsigned int &cursor, bool &modified, std::string &result)
static size_t findNameEnd(const std::string_view full)
static bool IsDefElement(const char *elementName, const char *defaultElementName, const char *classname)
return whether or not 'elementName' is the STL default Element for type 'classname'
static void ResolveTypedefProcessType(const char *tname, unsigned int, unsigned int cursor, bool constprefix, unsigned int start_of_type, unsigned int end_of_type, unsigned int mod_start_of_type, bool &modified, std::string &result)
static void RemoveStd(std::string &name, size_t pos=0)
Remove std:: and any potential inline namespace (well compiler detail namespace.
static size_t StdLen(const std::string_view name)
Return the length, if any, taken by std:: and any potential inline namespace (well compiler detail na...
virtual bool GetPartiallyDesugaredNameWithScopeHandling(const std::string &, std::string &, bool=true)=0
virtual ~TInterpreterLookupHelper()
virtual bool IsAlreadyPartiallyDesugaredName(const std::string &, const std::string &)=0
virtual bool IsDeclaredScope(const std::string &, bool &)=0
virtual void ShuttingDownSignal()=0
virtual void GetPartiallyDesugaredName(std::string &)=0
virtual bool ExistingTypeCheck(const std::string &, std::string &)=0
basic_string_view< char > string_view
std::string GetName(const std::string &scope_name)
std::string ToString(const T &val)
Utility function for conversion to strings.
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
bool IsDefComp(const char *comp, const char *classname)
return whether or not 'compare' is the STL default comparator for type 'classname'
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
std::string CleanType(const char *typeDesc, int mode=0, const char **tail=0)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
bool IsStdArray(std::string_view name)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
bool IsDefHash(const char *hashname, const char *classname)
return whether or not 'hashname' is the STL default hash for type 'classname'
bool IsInterpreterDetail(const char *type)
Return true if the type is one the interpreter details which are only forward declared (ClassInfo_t e...
std::string InsertStd(const char *tname)
bool SplitFunction(std::string_view decl, FunctionSplitInfo &result)
Split a function declaration into its different parts.
std::string GetLong64_Name(const char *original)
Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'.
bool IsDefPred(const char *predname, const char *classname)
return whether or not 'predname' is the STL default predicate for type 'classname'
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.
bool IsVectorBool(const char *name)
void Init(TClassEdit::TInterpreterLookupHelper *helper)
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
char * DemangleName(const char *mangled_name, int &errorCode)
bool GetStdArrayProperties(const char *typeName, std::string &typeNameBuf, std::array< int, 5 > &maxIndices, int &ndim)
std::string GetNameForIO(const std::string &templateInstanceName, TClassEdit::EModType mode=TClassEdit::kNone, bool *hasChanged=nullptr)
int STLArgs(int kind)
Return number of arguments for STL container before allocator.
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
bool IsDefAlloc(const char *alloc, const char *classname)
return whether or not 'allocname' is the STL default allocator for type 'classname'
bool IsUniquePtr(std::string_view name)
bool IsSTLBitset(const char *type)
Return true is the name is std::bitset<number> or bitset<number>
ROOT::ESTLType UnderlyingIsSTLCont(std::string_view type)
Return the type of STL collection, if any, that is the underlying type of the given type.
EComplexType GetComplexType(const char *)
static constexpr double second
Result of splitting a function declaration into fReturnType fScopeName::fFunctionName<fFunctionTempla...
std::string fFunctionName
Name of the function.
std::vector< std::string > fFunctionTemplateArguments
Template arguments of the function template specialization, if any; will contain one element "" for f...
std::string fScopeName
Name of the scope qualification of the function, possibly empty.
std::vector< std::string > fFunctionParameters
Function parameters.
std::string fReturnType
Return type of the function, might be empty if the function declaration string did not provide it.
bool IsTemplate()
Check if the type is a template.
int IsSTLCont(int testAlloc=0) const
type : type name: vector<list<classA,allocator>,allocator> testAlloc: if true, we test allocator,...
TSplitType(const char *type2split, EModType mode=TClassEdit::kNone)
default constructor
std::vector< std::string > fElements
ROOT::ESTLType IsInSTL() const
type : type name: vector<list<classA,allocator>,allocator>[::iterator] result: 0 : not stl container ...
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
static void output(int code)