24 struct ShuttingDownSignaler :
public T {
27 ~ShuttingDownSignaler()
29 if (gInterpreterHelper)
35namespace std {}
using namespace std;
44 if (
name.compare(0,5,
"std::")==0) {
49 if (gInterpreterHelper) {
50 for(
size_t i = 5; i <
name.length(); ++i) {
51 if (
name[i] ==
'<')
break;
54 std::string scope(
name.data(),i);
55 std::string scoperesult;
58 static ShuttingDownSignaler<std::set<std::string>> gInlined;
60 if (gInlined.find(scope) != gInlined.end()) {
62 if (i+1<
name.length() &&
name[i+1]==
':') {
69 gInlined.insert(scope);
71 if (i+1<
name.length() &&
name[i+1]==
':') {
104 name.remove_prefix(len);
112 if (0 == strncmp(clName,
"complex<", 8)) {
113 const char *clNamePlus8 = clName + 8;
114 if (0 == strcmp(
"float>", clNamePlus8)) {
115 return EComplexType::kFloat;
117 if (0 == strcmp(
"double>", clNamePlus8)) {
118 return EComplexType::kDouble;
120 if (0 == strcmp(
"int>", clNamePlus8)) {
121 return EComplexType::kInt;
123 if (0 == strcmp(
"long>", clNamePlus8)) {
124 return EComplexType::kLong;
138 if (
this == gInterpreterHelper)
139 gInterpreterHelper =
nullptr;
146 gInterpreterHelper = helper;
182 if (fElements[0].empty())
return 0;
183 int numb = fElements.size();
184 if (!fElements[numb-1].empty() && fElements[numb-1][0]==
'*') --numb;
186 if ( fNestedLocation ) {
192 int kind =
STLKind(fElements[0]);
197 if (testAlloc && (numb-1 > nargs) && !
IsDefAlloc(fElements[numb-1].c_str(),fElements[1].c_str())) {
209 if (k<0) kind = -kind;
215 if(kind>2) kind = - kind;
235 int narg = fElements.size();
246 if (fElements[narg-1].empty() ==
false &&
247 (fElements[narg-1][0]==
'*'
248 || fElements[narg-1][0]==
'&'
249 || fElements[narg-1][0]==
'['
250 || 0 == fElements[narg-1].compare(0,6,
"const*")
251 || 0 == fElements[narg-1].compare(0,6,
"const&")
252 || 0 == fElements[narg-1].compare(0,6,
"const[")
253 || 0 == fElements[narg-1].compare(
"const")
256 if ((mode&1)==0) tailLoc = narg-1;
258 else { assert(fElements[narg-1].empty()); };
262 if (fNestedLocation) narg--;
267 const int kind =
STLKind(fElements[0]);
268 const int iall =
STLArgs(kind);
272 while(narg-1>iall) { fElements.pop_back(); narg--;}
273 if (!fElements[0].empty() && tailLoc) {
276 fElements[0].clear();
284 bool allocRemoved =
false;
290 if (narg-1 == iall+1) {
292 bool dropAlloc =
false;
307 dropAlloc =
IsDefAlloc(fElements[iall+1].c_str(),fElements[1].c_str());
313 dropAlloc =
IsDefAlloc(fElements[iall+1].c_str(),fElements[1].c_str(),fElements[2].c_str());
331 if (
IsDefComp( fElements[iall].c_str(), fElements[1].c_str() ) ) {
346 if (!allocRemoved && narg-1 == iall+1) {
350 if (narg-1 == iall) narg--;
373 bool predRemoved =
false;
376 if (
IsDefPred( fElements[iall].c_str(), fElements[1].c_str() ) ) {
383 if (
IsDefHash( fElements[iall-1].c_str(), fElements[1].c_str() ) ) {
391 unsigned int offset = (0==strncmp(
"const ",fElements[0].c_str(),6)) ? 6 : 0;
392 offset += (0==strncmp(
"std::",fElements[0].c_str()+offset,5)) ? 5 : 0;
393 if (0 == strcmp(fElements[0].c_str()+offset,
"__shared_ptr"))
396 static const std::string sharedPtrDef = std::to_string(__gnu_cxx::__default_lock_policy);
398 static const std::string sharedPtrDef = std::to_string(2);
400 if (fElements[2] == sharedPtrDef) {
408 for (
int i=1;i<narg; i++) {
409 if (strchr(fElements[i].c_str(),
'<')==0) {
411 unsigned int offset = (0==strncmp(
"const ",fElements[i].c_str(),6)) ? 6 : 0;
425 if (gInterpreterHelper &&
428 if (!typeresult.empty()) fElements[i] = typeresult;
433 unsigned int tailOffset = 0;
434 if (tailLoc && fElements[tailLoc].compare(0,5,
"const") == 0) {
438 if (!fElements[0].empty()) {answ += fElements[0]; answ +=
"<";}
447 int nargNonDefault = 0;
448 std::string nonDefName = answ;
450 std::string nameSuperLong = fName;
451 if (gInterpreterHelper)
453 while (++nargNonDefault < narg) {
456 const char* closeTemplate =
" >";
457 if (nonDefName[nonDefName.length() - 1] !=
'>')
459 string nondef = nonDefName + closeTemplate;
460 if (gInterpreterHelper &&
463 if (nargNonDefault>1) nonDefName +=
",";
464 nonDefName += fElements[nargNonDefault];
466 if (nargNonDefault < narg)
467 narg = nargNonDefault;
471 {
for (
int i=1;i<narg-1; i++) { answ += fElements[i]; answ+=
",";} }
472 if (narg>1) { answ += fElements[narg-1]; }
474 if (!fElements[0].empty()) {
475 if ( answ.at(answ.size()-1) ==
'>') {
481 if (fNestedLocation) {
484 answ += fElements[fNestedLocation];
487 if (tailLoc) answ += fElements[tailLoc].c_str()+tailOffset;
494 return !fElements[0].empty();
504 if (
type.compare(0,6,
"const ")==0) { offset += 6; }
508 static const char *stls[] =
509 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
510 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap", 0};
511 static const size_t stllen[] =
512 { 3, 6, 4, 5, 3, 8, 3, 8, 6,
513 12, 13, 18, 13, 18, 0};
528 auto len =
type.length();
531 for(
int k=1;stls[k];k++) {
532 if (len == stllen[k]) {
533 if (
type.compare(offset,len,stls[k])==0)
return values[k];
537 for(
int k=1;stls[k];k++) {
if (
type.compare(offset,len,stls[k])==0)
return values[k];}
547 static const char stln[] =
549 { 1, 1, 1, 1, 3, 3, 2, 2, 1,
561 for(
size_t i = 0; i < full.length(); ++i) {
563 case '<': { ++level;
break; }
565 if (level == 0)
return i;
570 if (level == 0)
return i;
576 return full.length();
583 return pos +
findNameEnd( {full.data()+pos,full.length()-pos} );
595 if (
a==
"alloc")
return true;
596 if (
a==
"__default_alloc_template<true,0>")
return true;
597 if (
a==
"__malloc_alloc_template<0>")
return true;
599 const static int alloclen = strlen(
"allocator<");
600 if (
a.compare(0,alloclen,
"allocator<") != 0) {
603 a.remove_prefix(alloclen);
610 if (
a.compare(0,k.length(),k) != 0) {
614 std::string valuepart;
617 std::string norm_value;
620 if (valuepart != norm_value) {
623 a.remove_prefix(end);
625 a.remove_prefix(k.length());
628 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
640 const char *keyclassname,
641 const char *valueclassname)
643 if (
IsDefAlloc(allocname,keyclassname))
return true;
648 const static int alloclen = strlen(
"allocator<");
649 if (
a.compare(0,alloclen,
"allocator<") != 0) {
652 a.remove_prefix(alloclen);
656 const static int pairlen = strlen(
"pair<");
657 if (
a.compare(0,pairlen,
"pair<") != 0) {
660 a.remove_prefix(pairlen);
662 const static int constlen = strlen(
"const");
663 if (
a.compare(0,constlen+1,
"const ") == 0) {
664 a.remove_prefix(constlen+1);
671 if (k.compare(0,constlen+1,
"const ") == 0) {
672 k.remove_prefix(constlen+1);
675 if (
a.compare(0,k.length(),k) != 0) {
679 std::string alloc_keypart;
682 std::string norm_key;
685 if (alloc_keypart != norm_key) {
686 if ( norm_key[norm_key.length()-1] ==
'*' ) {
690 norm_key +=
" const";
692 if (alloc_keypart != norm_key) {
696 a.remove_prefix(end);
698 size_t end = k.length();
699 if ( (
a[end-1] ==
'*') ||
a[end]==
' ' ) {
700 size_t skipSpace = (
a[end] ==
' ');
701 if (
a.compare(end+skipSpace,constlen,
"const") == 0) {
702 end += constlen+skipSpace;
705 a.remove_prefix(end);
717 if (
a.compare(0,
v.length(),
v) != 0) {
721 std::string valuepart;
724 std::string norm_value;
727 if (valuepart != norm_value) {
730 a.remove_prefix(end);
732 a.remove_prefix(
v.length());
735 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
746static bool IsDefElement(
const char *elementName,
const char* defaultElementName,
const char *classname)
748 string c = elementName;
752 const int elementlen = strlen(defaultElementName);
753 if (
c.compare(pos,elementlen,defaultElementName) != 0) {
758 string k = classname;
759 if (
c.compare(pos,k.length(),k) != 0) {
766 std::string norm_key;
769 if (keypart != norm_key) {
777 if (
c.compare(pos,1,
">")!=0 &&
c.compare(pos,2,
" >")!=0) {
823 norm_name = std::string(
name);
845 if (norm_name.length()>2 && norm_name[0]==
':' && norm_name[1]==
':') {
846 norm_name.erase(0,2);
849 if (gInterpreterHelper) {
851 std::string typeresult;
855 if (!typeresult.empty()) norm_name = typeresult;
876 static const char* longlong_s =
"long long";
877 static const char* ulonglong_s =
"unsigned long long";
878 static const unsigned int longlong_len = strlen(longlong_s);
879 static const unsigned int ulonglong_len = strlen(ulonglong_s);
881 string result = original;
884 while( (pos = result.find(ulonglong_s,pos) ) >=0 ) {
885 result.replace(pos, ulonglong_len,
"ULong64_t");
888 while( (pos = result.find(longlong_s,pos) ) >=0 ) {
889 result.replace(pos, longlong_len,
"Long64_t");
899 const char *lastPos = original;
902 for(
auto cursor = original; *cursor !=
'\0'; ++cursor) {
903 if ( *cursor ==
'<' || *cursor ==
'(') ++depth;
904 else if ( *cursor ==
'>' || *cursor ==
')' ) --depth;
905 else if ( *cursor ==
':' ) {
906 if (depth==0 && *(cursor+1) ==
':' && *(cursor+2) !=
'\0') {
921 const char *t = full.c_str();
922 const unsigned int tlen( full.size() );
924 const char *starloc = t + tlen - 1;
925 bool hasconst =
false;
927 && (starloc-t) > 4 && 0 == strncmp((starloc-4),
"const",5)
928 && ( (*(starloc-5)) ==
' ' || (*(starloc-5)) ==
'*' || (*(starloc-5)) ==
'&'
929 || (*(starloc-5)) ==
'>' || (*(starloc-5)) ==
']') ) {
932 if ((*starloc-1)==
' ') {
938 if ( hasconst || (*starloc)==
'*' || (*starloc)==
'&' || (*starloc)==
']' ) {
939 bool isArray = ( (*starloc)==
']' );
940 while( t<=(starloc-1) && ((*(starloc-1))==
'*' || (*(starloc-1))==
'&' || (*(starloc-1))==
't' || isArray)) {
943 isArray = ! ( (*starloc)==
'[' );
944 }
else if ( (*(starloc-1))==
't' ) {
945 if ( (starloc-1-t) > 5 && 0 == strncmp((starloc-5),
"const",5)
946 && ( (*(starloc-6)) ==
' ' || (*(starloc-6)) ==
'*' || (*(starloc-6)) ==
'&'
947 || (*(starloc-6)) ==
'>' || (*(starloc-6)) ==
']')) {
958 if ((*(starloc-1))==
' ') {
963 const unsigned int starlen = strlen(starloc);
964 full.erase(tlen-starlen,starlen);
965 }
else if (hasconst) {
967 const unsigned int starlen = strlen(starloc);
968 full.erase(tlen-starlen,starlen);
988 if (strlen(
type)==0)
return 0;
990 int cleantypeMode = 1 ;
999 unsigned int const_offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1000 bool isString =
false;
1001 bool isStdString =
false;
1002 size_t std_offset = const_offset;
1003 static const char* basic_string_std =
"std::basic_string<char";
1004 static const unsigned int basic_string_std_len = strlen(basic_string_std);
1006 if (full.compare(const_offset,basic_string_std_len,basic_string_std) == 0
1007 && full.size() > basic_string_std_len) {
1011 }
else if (full.compare(const_offset,basic_string_std_len-5,basic_string_std+5) == 0
1012 && full.size() > (basic_string_std_len-5)) {
1015 }
else if (full.find(
"basic_string") != std::string::npos) {
1016 size_t len =
StdLen(full.c_str() + const_offset);
1017 if (len && len != 5 && full.compare(const_offset + len, basic_string_std_len-5, basic_string_std+5) == 0) {
1024 size_t offset = basic_string_std_len - 5;
1025 offset += std_offset;
1026 if ( full[offset] ==
'>' ) {
1028 }
else if (full[offset] ==
',') {
1030 if (full.compare(offset, 5,
"std::") == 0) {
1033 static const char* char_traits_s =
"char_traits<char>";
1034 static const unsigned int char_traits_len = strlen(char_traits_s);
1035 if (full.compare(offset, char_traits_len, char_traits_s) == 0) {
1036 offset += char_traits_len;
1037 if ( full[offset] ==
'>') {
1039 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1042 }
else if (full[offset] ==
',') {
1044 if (full.compare(offset, 5,
"std::") == 0) {
1047 static const char* allocator_s =
"allocator<char>";
1048 static const unsigned int allocator_len = strlen(allocator_s);
1049 if (full.compare(offset, allocator_len, allocator_s) == 0) {
1050 offset += allocator_len;
1051 if ( full[offset] ==
'>') {
1053 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1074 output.push_back(
string());
1076 if (isStdString && !(mode &
kDropStd)) {
1077 output.push_back(
"const std::string");
1079 output.push_back(
"const string");
1082 if (isStdString && !(mode &
kDropStd)) {
1083 output.push_back(
"std::string");
1085 output.push_back(
"string");
1088 if (offset < full.length()) {
1091 string right( full.substr(offset) );
1094 output.back().append(right.c_str()+1);
1105 unsigned int offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1110 if ( !full.empty() ) {
1114 const char *
c = strchr(full.c_str(),
'<');
1117 output.push_back(
string(full,0,
c - full.c_str()));
1121 for(cursor =
c + 1; *cursor !=
'\0' && !(level==0 && *cursor ==
'>'); ++cursor) {
1123 case '<': ++level;
break;
1124 case '>': --level;
break;
1127 output.push_back(std::string(
c+1,cursor));
1134 if (*(cursor-1) ==
' ') {
1135 output.push_back(std::string(
c+1,cursor-1));
1137 output.push_back(std::string(
c+1,cursor));
1140 if (*(cursor+1)==
':') {
1143 nestedLoc =
output.size();
1144 output.push_back((cursor+1));
1146 }
else if (level >= 0) {
1148 output.push_back(std::string(
c+1,cursor));
1152 output.push_back(
string());
1179 static const char* remove[] = {
"class",
"const",
"volatile",0};
1180 static bool isinit =
false;
1181 static std::vector<size_t> lengths;
1183 for (
int k=0; remove[k]; ++k) {
1184 lengths.push_back(strlen(remove[k]));
1190 result.reserve(strlen(typeDesc)*2);
1194 for(
c=typeDesc;*
c;
c++) {
1197 if (!isalnum(
c[ 1]) &&
c[ 1] !=
'_')
continue;
1199 if (kbl && (mode>=2 || lev==0)) {
1201 int n = (mode) ? 999 : 1;
1204 for (
int k=0; k<
n && remove[k]; k++) {
1205 int rlen = lengths[k];
1208 if (strncmp(remove[k],
c,rlen))
continue;
1211 if (isalnum(
c[rlen]) ||
c[rlen]==
'_' ||
c[rlen]==
'$')
continue;
1213 c+=rlen-1; done = 1;
break;
1218 kbl = (!isalnum(
c[ 0]) &&
c[ 0]!=
'_' &&
c[ 0]!=
'$' &&
c[0]!=
'[' &&
c[0]!=
']' &&
c[0]!=
'-' &&
c[0]!=
'@');
1222 if (*
c ==
'<' || *
c ==
'(') lev++;
1223 if (lev==0 && !isalnum(*
c)) {
1224 if (!strchr(
"*&:._$ []-@",*
c))
break;
1228 if (
c[0]==
'>' && result.size() && result[result.size()-1]==
'>') result+=
" ";
1232 if (*
c ==
'>' || *
c ==
')') lev--;
1269 size_t len = strlen(
type);
1270 if (len < 2 || strncmp(
type+len-2,
"_t",2) != 0)
return false;
1272 unsigned char offset = 0;
1273 if (strncmp(
type,
"const ",6)==0) { offset += 6; }
1274 static const char *names[] = {
"CallFunc_t",
"ClassInfo_t",
"BaseClassInfo_t",
1275 "DataMemberInfo_t",
"FuncTempInfo_t",
"MethodInfo_t",
"MethodArgInfo_t",
1276 "TypeInfo_t",
"TypedefInfo_t",0};
1278 for(
int k=1;names[k];k++) {
if (strcmp(
type+offset,names[k])==0)
return true;}
1287 size_t offset =
StdLen(classname);
1288 if ( strncmp(classname+offset,
"bitset<",strlen(
"bitset<"))==0)
return true;
1306 if (
type.compare(0,6,
"const ",6) == 0)
1307 type.remove_prefix(6);
1309 while(
type[
type.length()-1]==
'*' ||
1312 type.remove_suffix(1);
1325 auto pos =
type.find(
'<');
1329 for (
decltype(
type.length()) level = 1;
c <
type.length(); ++
c) {
1330 if (
type[
c] ==
'<') ++level;
1331 if (
type[
c] ==
'>') --level;
1332 if (level == 0)
break;
1334 if (
c != (
type.length()-1) ) {
1354 if (strchr(
type,
'<')==0)
return 0;
1365 classname +=
StdLen( classname );
1366 if ( strcmp(classname,
"string")==0 )
return true;
1367 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1368 if ( strncmp(classname,
"pair<",strlen(
"pair<"))==0)
return true;
1369 if ( strcmp(classname,
"allocator")==0)
return true;
1370 if ( strncmp(classname,
"allocator<",strlen(
"allocator<"))==0)
return true;
1371 if ( strncmp(classname,
"greater<",strlen(
"greater<"))==0)
return true;
1372 if ( strncmp(classname,
"less<",strlen(
"less<"))==0)
return true;
1373 if ( strncmp(classname,
"equal_to<",strlen(
"equal_to<"))==0)
return true;
1374 if ( strncmp(classname,
"hash<",strlen(
"hash<"))==0)
return true;
1375 if ( strncmp(classname,
"auto_ptr<",strlen(
"auto_ptr<"))==0)
return true;
1377 if ( strncmp(classname,
"vector<",strlen(
"vector<"))==0)
return true;
1378 if ( strncmp(classname,
"list<",strlen(
"list<"))==0)
return true;
1379 if ( strncmp(classname,
"forward_list<",strlen(
"forward_list<"))==0)
return true;
1380 if ( strncmp(classname,
"deque<",strlen(
"deque<"))==0)
return true;
1381 if ( strncmp(classname,
"map<",strlen(
"map<"))==0)
return true;
1382 if ( strncmp(classname,
"multimap<",strlen(
"multimap<"))==0)
return true;
1383 if ( strncmp(classname,
"set<",strlen(
"set<"))==0)
return true;
1384 if ( strncmp(classname,
"multiset<",strlen(
"multiset<"))==0)
return true;
1385 if ( strncmp(classname,
"unordered_set<",strlen(
"unordered_set<"))==0)
return true;
1386 if ( strncmp(classname,
"unordered_multiset<",strlen(
"unordered_multiset<"))==0)
return true;
1387 if ( strncmp(classname,
"unordered_map<",strlen(
"unordered_map<"))==0)
return true;
1388 if ( strncmp(classname,
"unordered_multimap<",strlen(
"unordered_multimap<"))==0)
return true;
1389 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1408 unsigned int cursor,
1410 unsigned int start_of_type,
1411 unsigned int end_of_type,
1412 unsigned int mod_start_of_type,
1414 std::string &result)
1416 std::string
type(modified && (mod_start_of_type < result.length()) ?
1417 result.substr(mod_start_of_type, string::npos)
1418 :
string(tname, start_of_type, end_of_type == 0 ? cursor - start_of_type : end_of_type - start_of_type));
1423 if (!typeresult.empty()) {
1426 result.replace(mod_start_of_type, string::npos,
1431 mod_start_of_type = start_of_type;
1432 result += string(tname,0,start_of_type);
1433 if (constprefix && typeresult.compare(0,6,
"const ",6) == 0) {
1434 result += typeresult.substr(6,string::npos);
1436 result += typeresult;
1439 }
else if (modified) {
1440 result.replace(mod_start_of_type, string::npos,
1444 if (end_of_type != 0 && end_of_type!=cursor) {
1445 result += std::string(tname,end_of_type,cursor-end_of_type);
1452 if (end_of_type != 0 && end_of_type!=cursor) {
1453 result += std::string(tname,end_of_type,cursor-end_of_type);
1463 unsigned int &cursor,
1465 std::string &result)
1472 bool constprefix =
false;
1474 if (tname[cursor]==
' ') {
1477 result += string(tname,0,cursor);
1479 while (tname[cursor]==
' ') ++cursor;
1482 if (tname[cursor]==
'c' && (cursor+6<len)) {
1483 if (strncmp(tname+cursor,
"const ",6) == 0) {
1485 if (modified) result +=
"const ";
1491 if (len > 2 && strncmp(tname+cursor,
"::",2) == 0) {
1495 unsigned int start_of_type = cursor;
1496 unsigned int end_of_type = 0;
1497 unsigned int mod_start_of_type = result.length();
1498 unsigned int prevScope = cursor;
1499 for ( ; cursor<len; ++cursor) {
1500 switch (tname[cursor]) {
1502 if ((cursor+1)>=len || tname[cursor+1]!=
':') {
1504 if (modified) result += (tname+prevScope);
1509 scope = result.substr(mod_start_of_type, string::npos);
1510 scope += std::string(tname+prevScope,cursor-prevScope);
1512 scope = std::string(tname, start_of_type, cursor - start_of_type);
1514 std::string scoperesult;
1515 bool isInlined =
false;
1519 if (!scoperesult.empty()) {
1522 if (constprefix && scoperesult.compare(0,6,
"const ",6) != 0) mod_start_of_type -= 6;
1523 result.replace(mod_start_of_type, string::npos,
1528 mod_start_of_type = start_of_type;
1529 result += string(tname,0,start_of_type);
1531 result += scoperesult;
1534 }
else if (modified) {
1535 result += std::string(tname+prevScope,cursor+2-prevScope);
1539 if (modified) result += (tname+prevScope);
1543 }
else if (isInlined) {
1547 mod_start_of_type = start_of_type;
1548 result += string(tname,0,start_of_type);
1550 result += string(tname,start_of_type,prevScope - start_of_type);
1552 }
else if (modified) {
1553 result += std::string(tname+prevScope,cursor+2-prevScope);
1557 prevScope = cursor+1;
1563 result += std::string(tname+prevScope,cursor+1-prevScope);
1569 }
while( cursor<len && tname[cursor] ==
',' );
1571 while (cursor<len && tname[cursor+1]==
' ') ++cursor;
1576 if (cursor+2<len && tname[cursor+1]==
':' && tname[cursor+2]==
':') {
1577 if (modified) result +=
"::";
1579 prevScope = cursor+1;
1581 if ( (cursor+1)<len && tname[cursor+1] ==
',') {
1583 if (modified) result +=
',';
1586 if ( (cursor+1)<len && tname[cursor+1] ==
'>') {
1588 if (modified) result +=
" >";
1591 if ( (cursor+1) >= len) {
1594 if (tname[cursor] !=
' ')
break;
1595 if (modified) prevScope = cursor+1;
1602 end_of_type = cursor;
1604 while ((cursor+1)<len && tname[cursor+1] ==
' ') ++cursor;
1606 auto next = cursor+1;
1607 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] ==
']'))
1612 result += string(tname,0,start_of_type);
1614 mod_start_of_type = start_of_type + 6;
1615 result += string(tname,start_of_type,end_of_type-start_of_type);
1616 }
else if (mod_start_of_type < result.length()) {
1617 result.insert(mod_start_of_type,
"const ");
1618 mod_start_of_type += 6;
1621 mod_start_of_type += 6;
1622 result += string(tname,start_of_type,end_of_type-start_of_type);
1625 end_of_type = cursor+1;
1626 prevScope = end_of_type;
1627 if ((next+5)==len || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1630 }
else if (next!=len && tname[next] !=
'*' && tname[next] !=
'&') {
1640 if (tname[cursor] !=
' ') end_of_type = cursor;
1642 auto next = cursor+1;
1643 if (strncmp(tname+next,
"const",5) == 0) {
1644 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1649 (tname[next] ==
' ' || tname[next] ==
'*' || tname[next] ==
'&')) {
1652 if (strncmp(tname+next,
"const",5) == 0) {
1653 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1665 if (modified && prevScope) {
1666 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1670 if (modified) result +=
',';
1674 if (modified && prevScope) {
1675 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1679 if (modified) result +=
'>';
1687 if (prevScope && modified) result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1704 if (tname == 0 || tname[0] == 0)
1706 if (!gInterpreterHelper)
1715 if (result.empty())
return tname;
1719 unsigned int len = strlen(tname);
1721 unsigned int cursor = 0;
1722 bool modified =
false;
1725 if (!modified)
return tname;
1739 static const char* sSTLtypes[] = {
1752 "basic_istringstream",
1755 "basic_ostringstream",
1759 "basic_stringstream",
1788 "istreambuf_iterator",
1797 "localedef utility",
1814 "moneypunct_byname",
1826 "ostreambuf_iterator",
1832 "pointer_to_binary_function",
1833 "pointer_to_unary_function",
1837 "raw_storage_iterator",
1856 "unordered_multimap",
1857 "unordered_multiset",
1863 static ShuttingDownSignaler<set<string>> sSetSTLtypes;
1865 if (tname==0 || tname[0]==0)
return "";
1867 if (sSetSTLtypes.empty()) {
1869 const size_t nSTLtypes =
sizeof(sSTLtypes) /
sizeof(
const char*);
1870 for (
size_t i = 0; i < nSTLtypes; ++i)
1871 sSetSTLtypes.insert(sSTLtypes[i]);
1875 size_t len = strlen(tname);
1877 ret.reserve(len + 20);
1881 bool precScope =
false;
1882 while (!(isalnum(tname[
b]) || tname[
b] ==
'_') &&
b < len) {
1883 precScope = (
b < len - 2) && (tname[
b] ==
':') && (tname[
b + 1] ==
':');
1895 while (
e < len && (isalnum(tname[
e]) || tname[
e] ==
'_'))
1899 set<string>::const_iterator iSTLtype = sSetSTLtypes.find(
id);
1900 if (iSTLtype != sSetSTLtypes.end())
1915class NameCleanerForIO {
1917 std::vector<std::unique_ptr<NameCleanerForIO>> fArgumentNodes = {};
1918 NameCleanerForIO* fMother;
1919 bool fHasChanged =
false;
1920 bool AreAncestorsSTLContOrArray()
1922 NameCleanerForIO* mother = fMother;
1923 if (!mother)
return false;
1924 bool isSTLContOrArray =
true;
1925 while (
nullptr != mother){
1928 mother = mother->fMother;
1931 return isSTLContOrArray;
1935 NameCleanerForIO(
const std::string& clName =
"",
1937 NameCleanerForIO* mother =
nullptr):fMother(mother)
1939 if (clName.back() !=
'>') {
1944 std::vector<std::string>
v;
1949 auto argsEnd =
v.end();
1950 auto argsBeginPlusOne = ++
v.begin();
1951 auto argPos = std::find_if(argsBeginPlusOne, argsEnd,
1952 [](std::string& arg){
return (!arg.empty() && arg.front() ==
':');});
1953 if (argPos != argsEnd) {
1954 const int lenght = clName.size();
1955 int wedgeBalance = 0;
1956 int lastOpenWedge = 0;
1957 for (
int i=lenght-1;i>-1;i--) {
1958 auto&
c = clName.at(i);
1962 }
else if (
c ==
'>') {
1964 }
else if (
c ==
':' && 0 == wedgeBalance) {
1966 auto nameToClean = clName.substr(0,i-1);
1967 NameCleanerForIO node(nameToClean, mode);
1968 auto cleanName = node.ToString();
1969 fHasChanged = node.HasChanged();
1975 cleanName += clName.substr(i+1,lastOpenWedge-i-1);
1978 auto lastTemplate = &clName.data()[i+1];
1990 unsigned int nargs =
v.size() - 2;
1991 for (
unsigned int i=0;i<nargs;++i) {
1992 fArgumentNodes.emplace_back(
new NameCleanerForIO(
v[i+1],mode,
this));
1996 bool HasChanged()
const {
return fHasChanged;}
2000 std::string
name(fName);
2002 if (fArgumentNodes.empty())
return name;
2007 name = fArgumentNodes.front()->ToString();
2010 tst.ShortType(
name, 1);
2016 auto stlContType = AreAncestorsSTLContOrArray();
2018 name = fArgumentNodes.front()->ToString();
2025 for (
auto& node : fArgumentNodes) {
2026 name += node->ToString() +
",";
2027 fHasChanged |= node->HasChanged();
2030 name +=
name.back() ==
'>' ?
" >" :
">";
2034 const std::string&
GetName() {
return fName;}
2035 const std::vector<std::unique_ptr<NameCleanerForIO>>* GetChildNodes()
const {
return &fArgumentNodes;}
2051 NameCleanerForIO node(templateInstanceName, mode);
2052 auto nameForIO = node.ToString();
2054 *hasChanged = node.HasChanged();
2063 std::string& typeNameBuf,
2064 std::array<int, 5>& maxIndices,
2070 NameCleanerForIO node(typeName);
2073 auto childNodes = node.GetChildNodes();
2074 for (ndim = 1;ndim <=5 ; ndim++) {
2075 maxIndices[ndim-1] = std::atoi(childNodes->back()->GetName().c_str());
2076 auto& frontNode = childNodes->front();
2077 typeNameBuf = frontNode->GetName();
2079 typeNameBuf = frontNode->ToString();
2082 childNodes = frontNode->GetChildNodes();
2095 const char* mangled_name = ti.name();
2101struct FunctionSplitInfo {
2103 std::string fReturnType;
2106 std::string fScopeName;
2109 std::string fFunctionName;
2113 std::vector<std::string> fFunctionTemplateArguments;
2116 std::vector<std::string> fFunctionParameters;
2125 std::stack<char> expected;
2126 for (std::size_t pos = 0, end = haystack.length(); pos < end; ++pos) {
2127 char c = haystack[pos];
2128 if (expected.empty()) {
2129 if (needles.find(
c) != std::string_view::npos)
2132 if (
c == expected.top()) {
2138 case '<': expected.emplace(
'>');
break;
2139 case '(': expected.emplace(
')');
break;
2140 case '[': expected.emplace(
']');
break;
2143 return std::string_view::npos;
2149 std::size_t lenHaystack = haystack.length();
2150 std::size_t prevAfterColumn = 0;
2152 std::size_t posColumn = FindNonNestedNeedles(haystack.substr(prevAfterColumn),
":");
2153 if (posColumn == std::string_view::npos)
2154 return std::string_view::npos;
2155 prevAfterColumn += posColumn;
2157 if (prevAfterColumn + 1 >= lenHaystack)
2158 return std::string_view::npos;
2161 if (haystack[prevAfterColumn] ==
':')
2162 return prevAfterColumn - 1;
2166 return std::string_view::npos;
2171 while (!str.empty() && std::isspace(str[0]))
2172 str.remove_prefix(1);
2173 while (!str.empty() && std::isspace(str.back()))
2174 str.remove_suffix(1);
2182 return std::string(sv.data(), sv.length());
2195 std::size_t posArgs = FindNonNestedNeedles(decl,
"(");
2198 std::size_t prevAfterWhiteSpace = 0;
2199 static const char whitespace[] =
" \t\n";
2200 while (declNoArgs.length() > prevAfterWhiteSpace) {
2201 std::size_t posWS = FindNonNestedNeedles(declNoArgs.substr(prevAfterWhiteSpace), whitespace);
2202 if (posWS == std::string_view::npos)
2204 prevAfterWhiteSpace += posWS + 1;
2205 while (declNoArgs.length() > prevAfterWhiteSpace
2206 && strchr(whitespace, declNoArgs[prevAfterWhiteSpace]))
2207 ++prevAfterWhiteSpace;
2211 std::size_t endReturn = prevAfterWhiteSpace;
2212 while (declNoArgs.length() > endReturn
2213 && strchr(
"&* \t \n", declNoArgs[endReturn]))
2220 std::size_t prevAtScope = FindNonNestedDoubleColons(scopeFunctionTmplt);
2221 while (prevAtScope != std::string_view::npos
2222 && scopeFunctionTmplt.length() > prevAtScope + 2) {
2223 std::size_t posScope = FindNonNestedDoubleColons(scopeFunctionTmplt.substr(prevAtScope + 2));
2224 if (posScope == std::string_view::npos)
2226 prevAtScope += posScope + 2;
2229 std::size_t afterScope = prevAtScope + 2;
2230 if (prevAtScope == std::string_view::npos) {
2235 result.
fScopeName =
ToString(StripSurroundingSpace(scopeFunctionTmplt.substr(0, prevAtScope)));
2239 std::size_t posTmpltOpen = FindNonNestedNeedles(funcNameTmplArgs,
"<");
2240 if (posTmpltOpen != std::string_view::npos) {
2245 std::size_t posTmpltClose = FindNonNestedNeedles(tmpltArgs,
">");
2246 if (posTmpltClose != std::string_view::npos) {
2247 tmpltArgs = tmpltArgs.substr(0, posTmpltClose);
2248 std::size_t prevAfterArg = 0;
2249 while (tmpltArgs.length() > prevAfterArg) {
2250 std::size_t posComma = FindNonNestedNeedles(tmpltArgs.substr(prevAfterArg),
",");
2251 if (posComma == std::string_view::npos) {
2255 prevAfterArg += posComma + 1;
2265 if (posArgs != std::string_view::npos) {
2268 std::size_t posEndArgs = FindNonNestedNeedles(params,
")");
2269 if (posEndArgs != std::string_view::npos) {
2270 params = params.substr(0, posEndArgs);
2271 std::size_t prevAfterArg = 0;
2272 while (params.length() > prevAfterArg) {
2273 std::size_t posComma = FindNonNestedNeedles(params.substr(prevAfterArg),
",");
2274 if (posComma == std::string_view::npos) {
2279 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)