22 namespace std {}
using namespace std;
31 if (name.compare(0,5,
"std::")==0) {
36 if (gInterpreterHelper) {
37 for(
size_t i = 5; i < name.length(); ++i) {
38 if (name[i] ==
'<')
break;
41 std::string scope(name.data(),i);
42 std::string scoperesult;
45 static std::set<std::string> gInlined;
47 if (gInlined.find(scope) != gInlined.end()) {
49 if (i+1<name.length() && name[i+1]==
':') {
53 if (!gInterpreterHelper->ExistingTypeCheck(scope, scoperesult)
54 && gInterpreterHelper->IsDeclaredScope(scope,isInlined)) {
56 gInlined.insert(scope);
58 if (i+1<name.length() && name[i+1]==
':') {
77 size_t len =
StdLen({name.data()+pos,name.length()-pos});
91 name.remove_prefix(len);
99 if (0 == strncmp(clName,
"complex<", 8)) {
100 const char *clNamePlus8 = clName + 8;
101 if (0 == strcmp(
"float>", clNamePlus8)) {
102 return EComplexType::kFloat;
104 if (0 == strcmp(
"double>", clNamePlus8)) {
105 return EComplexType::kDouble;
107 if (0 == strcmp(
"int>", clNamePlus8)) {
108 return EComplexType::kInt;
110 if (0 == strcmp(
"long>", clNamePlus8)) {
111 return EComplexType::kLong;
121 gInterpreterHelper = helper;
184 if (k<0) kind = -kind;
190 if(kind>2) kind = - kind;
221 if (
fElements[narg-1].empty() ==
false &&
225 || 0 ==
fElements[narg-1].compare(0,6,
"const*")
226 || 0 ==
fElements[narg-1].compare(0,6,
"const&")
227 || 0 ==
fElements[narg-1].compare(0,6,
"const[")
228 || 0 ==
fElements[narg-1].compare(
"const")
231 if ((mode&1)==0) tailLoc = narg-1;
233 else { assert(
fElements[narg-1].empty()); };
243 const int iall =
STLArgs(kind);
247 while(narg-1>iall) {
fElements.pop_back(); narg--;}
259 bool allocRemoved =
false;
265 if (narg-1 == iall+1) {
267 bool dropAlloc =
false;
305 if ( allocRemoved && (mode & kDropStlDefault) && narg-1 == iall) {
321 if (!allocRemoved && narg-1 == iall+1) {
325 if (narg-1 == iall) narg--;
348 bool predRemoved =
false;
350 if ( allocRemoved && (mode & kDropStlDefault) && narg-1 == iall) {
357 if ( predRemoved && (mode & kDropStlDefault) && narg == iall) {
365 if ( (mode & kDropStlDefault) && (narg >= 3)) {
366 unsigned int offset = (0==strncmp(
"const ",
fElements[0].c_str(),6)) ? 6 : 0;
367 offset += (0==strncmp(
"std::",
fElements[0].c_str()+offset,5)) ? 5 : 0;
368 if (0 == strcmp(
fElements[0].c_str()+offset,
"__shared_ptr"))
370 #ifdef _CONCURRENCE_H 371 static const std::string sharedPtrDef = std::to_string(__gnu_cxx::__default_lock_policy);
373 static const std::string sharedPtrDef = std::to_string(2);
383 for (
int i=1;i<narg; i++) {
384 if (strchr(
fElements[i].c_str(),
'<')==0) {
386 unsigned int offset = (0==strncmp(
"const ",
fElements[i].c_str(),6)) ? 6 : 0;
400 if (gInterpreterHelper->ExistingTypeCheck(
fElements[i], typeresult)
401 || gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(
fElements[i], typeresult)) {
402 if (!typeresult.empty())
fElements[i] = typeresult;
407 unsigned int tailOffset = 0;
408 if (tailLoc &&
fElements[tailLoc].compare(0,5,
"const") == 0) {
420 if (mode & kDropAllDefault) {
421 int nargNonDefault = 0;
422 std::string nonDefName = answ;
424 std::string nameSuperLong =
fName;
425 if (gInterpreterHelper)
426 gInterpreterHelper->GetPartiallyDesugaredName(nameSuperLong);
427 while (++nargNonDefault < narg) {
430 const char* closeTemplate =
" >";
431 if (nonDefName[nonDefName.length() - 1] !=
'>')
433 string nondef = nonDefName + closeTemplate;
434 if (gInterpreterHelper &&
435 gInterpreterHelper->IsAlreadyPartiallyDesugaredName(nondef, nameSuperLong))
437 if (nargNonDefault>1) nonDefName +=
",";
440 if (nargNonDefault < narg)
441 narg = nargNonDefault;
445 {
for (
int i=1;i<narg-1; i++) { answ +=
fElements[i]; answ+=
",";} }
446 if (narg>1) { answ +=
fElements[narg-1]; }
449 if ( answ.at(answ.size()-1) ==
'>') {
461 if (tailLoc) answ +=
fElements[tailLoc].c_str()+tailOffset;
470 unsigned char offset = 0;
471 if (type.compare(0,6,
"const ")==0) { offset += 6; }
472 offset +=
StdLen(type.substr(offset));
475 static const char *stls[] =
476 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
477 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap", 0};
478 static const size_t stllen[] =
479 { 3, 6, 4, 5, 3, 8, 3, 8, 6,
480 12, 13, 18, 13, 18, 0};
495 auto len = type.length();
498 for(
int k=1;stls[k];k++) {
499 if (len == stllen[k]) {
500 if (type.compare(offset,len,stls[k])==0)
return values[k];
504 for(
int k=1;stls[k];k++) {
if (type.compare(offset,len,stls[k])==0)
return values[k];}
514 static const char stln[] =
516 { 1, 1, 1, 1, 3, 3, 2, 2, 1,
528 for(
size_t i = 0; i < full.length(); ++i) {
530 case '<': { ++level;
break; }
532 if (level == 0)
return i;
537 if (level == 0)
return i;
543 return full.length();
550 return pos +
findNameEnd( {full.data()+pos,full.length()-pos} );
562 if (a==
"alloc")
return true;
563 if (a==
"__default_alloc_template<true,0>")
return true;
564 if (a==
"__malloc_alloc_template<0>")
return true;
566 const static int alloclen = strlen(
"allocator<");
567 if (a.
compare(0,alloclen,
"allocator<") != 0) {
581 std::string valuepart;
584 std::string norm_value;
587 if (valuepart != norm_value) {
607 const char *keyclassname,
608 const char *valueclassname)
610 if (
IsDefAlloc(allocname,keyclassname))
return true;
615 const static int alloclen = strlen(
"allocator<");
616 if (a.
compare(0,alloclen,
"allocator<") != 0) {
623 const static int pairlen = strlen(
"pair<");
624 if (a.
compare(0,pairlen,
"pair<") != 0) {
629 const static int constlen = strlen(
"const");
630 if (a.
compare(0,constlen+1,
"const ") == 0) {
638 if (k.
compare(0,constlen+1,
"const ") == 0) {
646 std::string alloc_keypart;
649 std::string norm_key;
652 if (alloc_keypart != norm_key) {
653 if ( norm_key[norm_key.length()-1] ==
'*' ) {
657 norm_key +=
" const";
659 if (alloc_keypart != norm_key) {
666 if ( (a[end-1] ==
'*') || a[end]==
' ' ) {
667 size_t skipSpace = (a[end] ==
' ');
668 if (a.
compare(end+skipSpace,constlen,
"const") == 0) {
669 end += constlen+skipSpace;
688 std::string valuepart;
691 std::string norm_value;
694 if (valuepart != norm_value) {
713 static bool IsDefElement(
const char *elementName,
const char* defaultElementName,
const char *classname)
715 string c = elementName;
719 const int elementlen = strlen(defaultElementName);
720 if (c.compare(pos,elementlen,defaultElementName) != 0) {
725 string k = classname;
726 if (c.compare(pos,k.length(),k) != 0) {
733 std::string norm_key;
736 if (keypart != norm_key) {
744 if (c.compare(pos,1,
">")!=0 && c.compare(pos,2,
" >")!=0) {
790 norm_name = std::string(name);
799 if (norm_name.length()>2 && norm_name[0]==
':' && norm_name[1]==
':') {
800 norm_name.erase(0,2);
803 if (gInterpreterHelper) {
805 std::string typeresult;
806 if (gInterpreterHelper->ExistingTypeCheck(norm_name, typeresult)
807 || gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(norm_name, typeresult)) {
809 if (!typeresult.empty()) norm_name = typeresult;
830 static const char* longlong_s =
"long long";
831 static const char* ulonglong_s =
"unsigned long long";
832 static const unsigned int longlong_len = strlen(longlong_s);
833 static const unsigned int ulonglong_len = strlen(ulonglong_s);
835 string result = original;
838 while( (pos = result.find(ulonglong_s,pos) ) >=0 ) {
839 result.replace(pos, ulonglong_len,
"ULong64_t");
842 while( (pos = result.find(longlong_s,pos) ) >=0 ) {
843 result.replace(pos, longlong_len,
"Long64_t");
853 const char *lastPos = original;
856 for(
auto cursor = original; *cursor !=
'\0'; ++cursor) {
857 if ( *cursor ==
'<' || *cursor ==
'(') ++depth;
858 else if ( *cursor ==
'>' || *cursor ==
')' ) --depth;
859 else if ( *cursor ==
':' ) {
860 if (depth==0 && *(cursor+1) ==
':' && *(cursor+2) !=
'\0') {
875 const char *t = full.c_str();
876 const unsigned int tlen( full.size() );
878 const char *starloc = t + tlen - 1;
879 bool hasconst =
false;
881 && (starloc-t) > 4 && 0 == strncmp((starloc-4),
"const",5)
882 && ( (*(starloc-5)) ==
' ' || (*(starloc-5)) ==
'*' || (*(starloc-5)) ==
'&' 883 || (*(starloc-5)) ==
'>' || (*(starloc-5)) ==
']') ) {
886 if ((*starloc-1)==
' ') {
892 if ( hasconst || (*starloc)==
'*' || (*starloc)==
'&' || (*starloc)==
']' ) {
893 bool isArray = ( (*starloc)==
']' );
894 while( t<=(starloc-1) && ((*(starloc-1))==
'*' || (*(starloc-1))==
'&' || (*(starloc-1))==
't' || isArray)) {
897 isArray = ! ( (*starloc)==
'[' );
898 }
else if ( (*(starloc-1))==
't' ) {
899 if ( (starloc-1-t) > 5 && 0 == strncmp((starloc-5),
"const",5)
900 && ( (*(starloc-6)) ==
' ' || (*(starloc-6)) ==
'*' || (*(starloc-6)) ==
'&' 901 || (*(starloc-6)) ==
'>' || (*(starloc-6)) ==
']')) {
912 if ((*(starloc-1))==
' ') {
917 const unsigned int starlen = strlen(starloc);
918 full.erase(tlen-starlen,starlen);
919 }
else if (hasconst) {
921 const unsigned int starlen = strlen(starloc);
922 full.erase(tlen-starlen,starlen);
942 if (strlen(type)==0)
return 0;
944 int cleantypeMode = 1 ;
953 unsigned int const_offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
954 bool isString =
false;
955 bool isStdString =
false;
956 static const char* basic_string_std =
"std::basic_string<char";
957 static const unsigned int basic_string_std_len = strlen(basic_string_std);
959 if (full.compare(const_offset,basic_string_std_len,basic_string_std) == 0
960 && full.size() > basic_string_std_len) {
963 }
else if (full.compare(const_offset,basic_string_std_len-5,basic_string_std+5) == 0
964 && full.size() > (basic_string_std_len-5)) {
969 size_t offset = isStdString ? basic_string_std_len : basic_string_std_len - 5;
970 offset += const_offset;
971 if ( full[offset] ==
'>' ) {
973 }
else if (full[offset] ==
',') {
975 if (full.compare(offset, 5,
"std::") == 0) {
978 static const char* char_traits_s =
"char_traits<char>";
979 static const unsigned int char_traits_len = strlen(char_traits_s);
980 if (full.compare(offset, char_traits_len, char_traits_s) == 0) {
981 offset += char_traits_len;
982 if ( full[offset] ==
'>') {
984 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
987 }
else if (full[offset] ==
',') {
989 if (full.compare(offset, 5,
"std::") == 0) {
992 static const char* allocator_s =
"allocator<char>";
993 static const unsigned int allocator_len = strlen(allocator_s);
994 if (full.compare(offset, allocator_len, allocator_s) == 0) {
995 offset += allocator_len;
996 if ( full[offset] ==
'>') {
998 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1019 output.push_back(
string());
1020 if (const_offset && (mode & kKeepOuterConst)) {
1021 if (isStdString && !(mode &
kDropStd)) {
1022 output.push_back(
"const std::string");
1024 output.push_back(
"const string");
1027 if (isStdString && !(mode &
kDropStd)) {
1028 output.push_back(
"std::string");
1030 output.push_back(
"string");
1033 if (offset < full.length()) {
1036 string right( full.substr(offset) );
1039 output.back().append(right.c_str()+1);
1040 output.push_back(stars);
1042 output.push_back(
"");
1044 return output.size();
1050 unsigned int offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1055 if ( !full.empty() ) {
1059 const char *c = strchr(full.c_str(),
'<');
1062 output.push_back(
string(full,0,c - full.c_str()));
1066 for(cursor = c + 1; *cursor !=
'\0' && !(level==0 && *cursor ==
'>'); ++cursor) {
1068 case '<': ++level;
break;
1069 case '>': --level;
break;
1072 output.push_back(std::string(c+1,cursor));
1079 if (*(cursor-1) ==
' ') {
1080 output.push_back(std::string(c+1,cursor-1));
1082 output.push_back(std::string(c+1,cursor));
1085 if (*(cursor+1)==
':') {
1088 nestedLoc = output.size();
1089 output.push_back((cursor+1));
1091 }
else if (level >= 0) {
1093 output.push_back(std::string(c+1,cursor));
1097 output.push_back(
string());
1098 output.push_back(full);
1101 if (!output.empty()) output.push_back(stars);
1102 return output.size();
1124 static const char*
remove[] = {
"class",
"const",
"volatile",0};
1125 static bool isinit =
false;
1126 static std::vector<size_t> lengths;
1128 for (
int k=0;
remove[k]; ++k) {
1129 lengths.push_back(strlen(
remove[k]));
1135 result.reserve(strlen(typeDesc)*2);
1139 for(c=typeDesc;*c;c++) {
1142 if (!isalnum(c[ 1]) && c[ 1] !=
'_')
continue;
1144 if (kbl && (mode>=2 || lev==0)) {
1146 int n = (mode) ? 999 : 1;
1149 for (
int k=0; k<n &&
remove[k]; k++) {
1150 int rlen = lengths[k];
1153 if (strncmp(
remove[k],c,rlen))
continue;
1156 if (isalnum(c[rlen]) || c[rlen]==
'_' || c[rlen]==
'$')
continue;
1158 c+=rlen-1; done = 1;
break;
1163 kbl = (!isalnum(c[ 0]) && c[ 0]!=
'_' && c[ 0]!=
'$' && c[0]!=
'[' && c[0]!=
']' && c[0]!=
'-' && c[0]!=
'@');
1167 if (*c ==
'<' || *c ==
'(') lev++;
1168 if (lev==0 && !isalnum(*c)) {
1169 if (!strchr(
"*&:._$ []-@",*c))
break;
1173 if (c[0]==
'>' && result.size() && result[result.size()-1]==
'>') result+=
" ";
1177 if (*c ==
'>' || *c ==
')') lev--;
1214 size_t len = strlen(type);
1215 if (len < 2 || strncmp(type+len-2,
"_t",2) != 0)
return false;
1217 unsigned char offset = 0;
1218 if (strncmp(type,
"const ",6)==0) { offset += 6; }
1219 static const char *names[] = {
"CallFunc_t",
"ClassInfo_t",
"BaseClassInfo_t",
1220 "DataMemberInfo_t",
"FuncTempInfo_t",
"MethodInfo_t",
"MethodArgInfo_t",
1221 "TypeInfo_t",
"TypedefInfo_t",0};
1223 for(
int k=1;names[k];k++) {
if (strcmp(type+offset,names[k])==0)
return true;}
1232 size_t offset =
StdLen(classname);
1233 if ( strncmp(classname+offset,
"bitset<",strlen(
"bitset<"))==0)
return true;
1251 if (type.compare(0,6,
"const ",6) == 0)
1252 type.remove_prefix(6);
1254 while(type[type.length()-1]==
'*' ||
1255 type[type.length()-1]==
'&' ||
1256 type[type.length()-1]==
' ') {
1257 type.remove_suffix(1);
1270 auto pos = type.find(
'<');
1274 for (decltype(type.length()) level = 1; c < type.length(); ++c) {
1275 if (type[c] ==
'<') ++level;
1276 if (type[c] ==
'>') --level;
1277 if (level == 0)
break;
1279 if (c != (type.length()-1) ) {
1283 return STLKind(type.substr(0,pos));
1299 if (strchr(type,
'<')==0)
return 0;
1310 classname +=
StdLen( classname );
1311 if ( strcmp(classname,
"string")==0 )
return true;
1312 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1313 if ( strncmp(classname,
"pair<",strlen(
"pair<"))==0)
return true;
1314 if ( strcmp(classname,
"allocator")==0)
return true;
1315 if ( strncmp(classname,
"allocator<",strlen(
"allocator<"))==0)
return true;
1316 if ( strncmp(classname,
"greater<",strlen(
"greater<"))==0)
return true;
1317 if ( strncmp(classname,
"less<",strlen(
"less<"))==0)
return true;
1318 if ( strncmp(classname,
"equal_to<",strlen(
"equal_to<"))==0)
return true;
1319 if ( strncmp(classname,
"hash<",strlen(
"hash<"))==0)
return true;
1320 if ( strncmp(classname,
"auto_ptr<",strlen(
"auto_ptr<"))==0)
return true;
1322 if ( strncmp(classname,
"vector<",strlen(
"vector<"))==0)
return true;
1323 if ( strncmp(classname,
"list<",strlen(
"list<"))==0)
return true;
1324 if ( strncmp(classname,
"forward_list<",strlen(
"forward_list<"))==0)
return true;
1325 if ( strncmp(classname,
"deque<",strlen(
"deque<"))==0)
return true;
1326 if ( strncmp(classname,
"map<",strlen(
"map<"))==0)
return true;
1327 if ( strncmp(classname,
"multimap<",strlen(
"multimap<"))==0)
return true;
1328 if ( strncmp(classname,
"set<",strlen(
"set<"))==0)
return true;
1329 if ( strncmp(classname,
"multiset<",strlen(
"multiset<"))==0)
return true;
1330 if ( strncmp(classname,
"unordered_set<",strlen(
"unordered_set<"))==0)
return true;
1331 if ( strncmp(classname,
"unordered_multiset<",strlen(
"unordered_multiset<"))==0)
return true;
1332 if ( strncmp(classname,
"unordered_map<",strlen(
"unordered_map<"))==0)
return true;
1333 if ( strncmp(classname,
"unordered_multimap<",strlen(
"unordered_multimap<"))==0)
return true;
1334 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1353 unsigned int cursor,
1355 unsigned int start_of_type,
1356 unsigned int end_of_type,
1357 unsigned int mod_start_of_type,
1359 std::string &result)
1361 std::string
type(modified && (mod_start_of_type < result.length()) ?
1362 result.substr(mod_start_of_type, string::npos)
1363 : string(tname, start_of_type, end_of_type == 0 ? cursor - start_of_type : end_of_type - start_of_type));
1365 if (gInterpreterHelper->ExistingTypeCheck(
type, typeresult)
1366 || gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(
type, typeresult)) {
1368 if (!typeresult.empty()) {
1371 result.replace(mod_start_of_type, string::npos,
1376 mod_start_of_type = start_of_type;
1377 result += string(tname,0,start_of_type);
1378 if (constprefix && typeresult.compare(0,6,
"const ",6) == 0) {
1379 result += typeresult.substr(6,string::npos);
1381 result += typeresult;
1384 }
else if (modified) {
1385 result.replace(mod_start_of_type, string::npos,
1389 if (end_of_type != 0 && end_of_type!=cursor) {
1390 result += std::string(tname,end_of_type,cursor-end_of_type);
1397 if (end_of_type != 0 && end_of_type!=cursor) {
1398 result += std::string(tname,end_of_type,cursor-end_of_type);
1408 unsigned int &cursor,
1410 std::string &result)
1417 bool constprefix =
false;
1419 if (tname[cursor]==
' ') {
1422 result += string(tname,0,cursor);
1424 while (tname[cursor]==
' ') ++cursor;
1427 if (tname[cursor]==
'c' && (cursor+6<len)) {
1428 if (strncmp(tname+cursor,
"const ",6) == 0) {
1430 if (modified) result +=
"const ";
1438 if (len > 5 && strncmp(tname+cursor,
"std::",5) == 0) {
1441 if (len > 2 && strncmp(tname+cursor,
"::",2) == 0) {
1446 unsigned int start_of_type = cursor;
1447 unsigned int end_of_type = 0;
1448 unsigned int mod_start_of_type = result.length();
1449 unsigned int prevScope = cursor;
1450 for ( ; cursor<len; ++cursor) {
1451 switch (tname[cursor]) {
1453 if ((cursor+1)>=len || tname[cursor+1]!=
':') {
1455 if (modified) result += (tname+prevScope);
1460 scope = result.substr(mod_start_of_type, string::npos);
1461 scope += std::string(tname+prevScope,cursor-prevScope);
1463 scope = std::string(tname, start_of_type, cursor - start_of_type);
1465 std::string scoperesult;
1466 bool isInlined =
false;
1467 if (gInterpreterHelper->ExistingTypeCheck(scope, scoperesult)
1468 ||gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(scope, scoperesult)) {
1470 if (!scoperesult.empty()) {
1473 if (constprefix && scoperesult.compare(0,6,
"const ",6) != 0) mod_start_of_type -= 6;
1474 result.replace(mod_start_of_type, string::npos,
1479 mod_start_of_type = start_of_type;
1480 result += string(tname,0,start_of_type);
1482 result += scoperesult;
1485 }
else if (modified) {
1486 result += std::string(tname+prevScope,cursor+1-prevScope);
1488 }
else if (!gInterpreterHelper->IsDeclaredScope(scope,isInlined)) {
1490 if (modified) result += (tname+prevScope);
1494 }
else if (isInlined) {
1498 mod_start_of_type = start_of_type;
1499 result += string(tname,0,start_of_type);
1501 result += string(tname,start_of_type,prevScope - start_of_type);
1503 }
else if (modified) {
1504 result += std::string(tname+prevScope,cursor+1-prevScope);
1508 prevScope = cursor+1;
1514 result += std::string(tname+prevScope,cursor+1-prevScope);
1520 }
while( cursor<len && tname[cursor] ==
',' );
1522 while (cursor<len && tname[cursor+1]==
' ') ++cursor;
1527 if (cursor+2<len && tname[cursor+1]==
':' && tname[cursor+2]==
':') {
1528 if (modified) result +=
"::";
1530 prevScope = cursor+1;
1532 if ( (cursor+1)<len && tname[cursor+1] ==
',') {
1534 if (modified) result +=
',';
1537 if ( (cursor+1)<len && tname[cursor+1] ==
'>') {
1539 if (modified) result +=
" >";
1542 if ( (cursor+1) >= len) {
1545 if (tname[cursor] !=
' ')
break;
1546 if (modified) prevScope = cursor+1;
1553 end_of_type = cursor;
1555 while ((cursor+1)<len && tname[cursor+1] ==
' ') ++cursor;
1557 auto next = cursor+1;
1558 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] ==
']'))
1563 result += string(tname,0,start_of_type);
1565 mod_start_of_type = start_of_type + 6;
1566 result += string(tname,start_of_type,end_of_type-start_of_type);
1567 }
else if (mod_start_of_type < result.length()) {
1568 result.insert(mod_start_of_type,
"const ");
1569 mod_start_of_type += 6;
1572 mod_start_of_type += 6;
1573 result += string(tname,start_of_type,end_of_type-start_of_type);
1576 end_of_type = cursor+1;
1577 prevScope = end_of_type;
1578 if ((next+5)==len || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1581 }
else if (next!=len && tname[next] !=
'*' && tname[next] !=
'&') {
1591 if (tname[cursor] !=
' ') end_of_type = cursor;
1593 auto next = cursor+1;
1594 if (strncmp(tname+next,
"const",5) == 0) {
1595 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1600 (tname[next] ==
' ' || tname[next] ==
'*' || tname[next] ==
'&')) {
1603 if (strncmp(tname+next,
"const",5) == 0) {
1604 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1616 if (modified && prevScope) {
1617 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1621 if (modified) result +=
',';
1625 if (modified && prevScope) {
1626 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1630 if (modified) result +=
'>';
1638 if (prevScope && modified) result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1655 if (tname == 0 || tname[0] == 0)
1657 if (!gInterpreterHelper)
1664 if (gInterpreterHelper->ExistingTypeCheck(tname, result))
1666 if (result.empty())
return tname;
1670 unsigned int len = strlen(tname);
1672 unsigned int cursor = 0;
1673 bool modified =
false;
1676 if (!modified)
return tname;
1690 static const char* sSTLtypes[] = {
1703 "basic_istringstream",
1706 "basic_ostringstream",
1710 "basic_stringstream",
1739 "istreambuf_iterator",
1748 "localedef utility",
1765 "moneypunct_byname",
1777 "ostreambuf_iterator",
1783 "pointer_to_binary_function",
1784 "pointer_to_unary_function",
1788 "raw_storage_iterator",
1807 "unordered_multimap",
1808 "unordered_multiset",
1814 static set<string> sSetSTLtypes;
1816 if (tname==0 || tname[0]==0)
return "";
1818 if (sSetSTLtypes.empty()) {
1820 const size_t nSTLtypes =
sizeof(sSTLtypes) /
sizeof(
const char*);
1821 for (
size_t i = 0; i < nSTLtypes; ++i)
1822 sSetSTLtypes.insert(sSTLtypes[i]);
1826 size_t len = strlen(tname);
1828 ret.reserve(len + 20);
1832 bool precScope =
false;
1833 while (!(isalnum(tname[b]) || tname[b] ==
'_') && b < len) {
1834 precScope = (b < len - 2) && (tname[b] ==
':') && (tname[b + 1] ==
':');
1846 while (e < len && (isalnum(tname[e]) || tname[e] ==
'_'))
1850 set<string>::const_iterator iSTLtype = sSetSTLtypes.find(
id);
1851 if (iSTLtype != sSetSTLtypes.end())
1866 class NameCleanerForIO {
1868 std::vector<std::unique_ptr<NameCleanerForIO>> fArgumentNodes = {};
1869 NameCleanerForIO* fMother;
1870 bool fHasChanged =
false;
1871 bool AreAncestorsSTLContOrArray()
1873 NameCleanerForIO* mother = fMother;
1874 if (!mother)
return false;
1875 bool isSTLContOrArray =
true;
1876 while (
nullptr != mother){
1879 mother = mother->fMother;
1882 return isSTLContOrArray;
1886 NameCleanerForIO(
const std::string& clName =
"",
1888 NameCleanerForIO* mother =
nullptr):fMother(mother)
1890 if (clName.back() !=
'>') {
1895 std::vector<std::string>
v;
1900 auto argsEnd = v.end();
1901 auto argsBeginPlusOne = ++v.begin();
1902 auto argPos = std::find_if(argsBeginPlusOne, argsEnd,
1903 [](std::string& arg){
return arg.front() ==
':';});
1904 if (argPos != argsEnd) {
1905 const int lenght = clName.size();
1906 int wedgeBalance = 0;
1907 int lastOpenWedge = 0;
1908 for (
int i=lenght-1;i>-1;i--) {
1909 auto& c = clName.at(i);
1913 }
else if (c ==
'>') {
1915 }
else if (c ==
':' && 0 == wedgeBalance) {
1917 auto nameToClean = clName.substr(0,i-1);
1918 NameCleanerForIO node(nameToClean, mode);
1919 auto cleanName = node.ToString();
1920 fHasChanged = node.HasChanged();
1926 cleanName += clName.substr(i+1,lastOpenWedge-i-1);
1929 auto lastTemplate = &clName.data()[i+1];
1941 unsigned int nargs = v.size() - 2;
1942 for (
unsigned int i=0;i<nargs;++i) {
1943 fArgumentNodes.emplace_back(
new NameCleanerForIO(v[i+1],mode,
this));
1947 bool HasChanged()
const {
return fHasChanged;}
1951 std::string
name(fName);
1953 if (fArgumentNodes.empty())
return name;
1958 name = fArgumentNodes.front()->ToString();
1964 auto stlContType = AreAncestorsSTLContOrArray();
1966 name = fArgumentNodes.front()->ToString();
1973 for (
auto& node : fArgumentNodes) {
1974 name += node->ToString() +
",";
1975 fHasChanged |= node->HasChanged();
1978 name += name.back() ==
'>' ?
" >" :
">";
1983 const std::vector<std::unique_ptr<NameCleanerForIO>>* GetChildNodes()
const {
return &fArgumentNodes;}
1998 NameCleanerForIO node(templateInstanceName, mode);
1999 auto nameForIO = node.ToString();
2001 *hasChanged = node.HasChanged();
2010 std::string& typeNameBuf,
2011 std::array<int, 5>& maxIndices,
2017 NameCleanerForIO node(typeName);
2020 auto childNodes = node.GetChildNodes();
2021 for (ndim = 1;ndim <=5 ; ndim++) {
2022 maxIndices[ndim-1] = std::atoi(childNodes->back()->GetName().c_str());
2023 auto& frontNode = childNodes->front();
2024 typeNameBuf = frontNode->GetName();
2026 typeNameBuf = frontNode->ToString();
2029 childNodes = frontNode->GetChildNodes();
2042 const char* mangled_name = ti.name();
std::string GetName(const std::string &scope_name)
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...
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
basic_string_view< char > string_view
TSplitType(const char *type2split, EModType mode=TClassEdit::kNone)
default constructor
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT
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.
bool IsDefAlloc(const char *alloc, const char *classname)
return whether or not 'allocname' is the STL default allocator for type 'classname' ...
ROOT::ESTLType IsInSTL() const
type : type name: vector<list<classA,allocator>,allocator>[::iterator] result: 0 : not stl container ...
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 ...
std::string InsertStd(const char *tname)
static void RemoveStd(std::string &name, size_t pos=0)
Remove std:: and any potential inline namespace (well compiler detail namespace.
bool IsSTLBitset(const char *type)
Return true is the name is std::bitset<number> or bitset<number>
int STLArgs(int kind)
Return number of arguments for STL container before allocator.
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
char * DemangleName(const char *mangled_name, int &errorCode)
std::string GetNameForIO(const std::string &templateInstanceName, TClassEdit::EModType mode=TClassEdit::kNone, bool *hasChanged=nullptr)
void Init(TClassEdit::TInterpreterLookupHelper *helper)
int IsSTLCont(int testAlloc=0) const
type : type name: vector<list<classA,allocator>,allocator> testAlloc: if true, we test allocator...
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
static size_t findNameEnd(const std::string_view full)
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
bool IsStdArray(std::string_view name)
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 GetLong64_Name(const char *original)
Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'.
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 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)
bool IsDefHash(const char *hashname, const char *classname)
return whether or not 'hashname' is the STL default hash for type 'classname'
static void R__FindTrailing(std::string &full, std::string &stars)
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
std::vector< std::string > fElements
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
bool IsVectorBool(const char *name)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
static RooMathCoreReg dummy
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
bool IsDefComp(const char *comp, const char *classname)
return whether or not 'compare' is the STL default comparator for type 'classname' ...
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_pointer data() const _NOEXCEPT
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' ...
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.
std::string ToString(const T &val)
Utility function for conversion to strings.
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
bool IsUniquePtr(std::string_view name)
bool GetStdArrayProperties(const char *typeName, std::string &typeNameBuf, std::array< int, 5 > &maxIndices, int &ndim)
static void ResolveTypedefImpl(const char *tname, unsigned int len, unsigned int &cursor, bool &modified, std::string &result)
bool IsDefPred(const char *predname, const char *classname)
return whether or not 'predname' is the STL default predicate for type 'classname' ...
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_prefix(size_type __n) _NOEXCEPT