24 namespace std {}
using namespace std;
33 if (name.compare(0,5,
"std::")==0) {
38 if (gInterpreterHelper) {
39 for(
size_t i = 5; i < name.length(); ++i) {
40 if (name[i] ==
'<')
break;
43 std::string scope(name.data(),i);
44 std::string scoperesult;
47 static std::set<std::string> gInlined;
49 if (gInlined.find(scope) != gInlined.end()) {
51 if (i+1<name.length() && name[i+1]==
':') {
55 if (!gInterpreterHelper->ExistingTypeCheck(scope, scoperesult)
56 && gInterpreterHelper->IsDeclaredScope(scope,isInlined)) {
58 gInlined.insert(scope);
60 if (i+1<name.length() && name[i+1]==
':') {
79 size_t len =
StdLen({name.data()+pos,name.length()-pos});
93 name.remove_prefix(len);
101 if (0 == strncmp(clName,
"complex<", 8)) {
102 const char *clNamePlus8 = clName + 8;
103 if (0 == strcmp(
"float>", clNamePlus8)) {
104 return EComplexType::kFloat;
106 if (0 == strcmp(
"double>", clNamePlus8)) {
107 return EComplexType::kDouble;
109 if (0 == strcmp(
"int>", clNamePlus8)) {
110 return EComplexType::kInt;
112 if (0 == strcmp(
"long>", clNamePlus8)) {
113 return EComplexType::kLong;
123 gInterpreterHelper = helper;
186 if (k<0) kind = -kind;
192 if(kind>2) kind = - kind;
223 if (
fElements[narg-1].empty() ==
false &&
227 || 0 ==
fElements[narg-1].compare(0,6,
"const*")
228 || 0 ==
fElements[narg-1].compare(0,6,
"const&")
229 || 0 ==
fElements[narg-1].compare(0,6,
"const[")
230 || 0 ==
fElements[narg-1].compare(
"const")
233 if ((mode&1)==0) tailLoc = narg-1;
235 else { assert(
fElements[narg-1].empty()); };
245 const int iall =
STLArgs(kind);
249 while(narg-1>iall) {
fElements.pop_back(); narg--;}
261 bool allocRemoved =
false;
267 if (narg-1 == iall+1) {
269 bool dropAlloc =
false;
307 if ( allocRemoved && (mode & kDropStlDefault) && narg-1 == iall) {
323 if (!allocRemoved && narg-1 == iall+1) {
327 if (narg-1 == iall) narg--;
350 bool predRemoved =
false;
352 if ( allocRemoved && (mode & kDropStlDefault) && narg-1 == iall) {
359 if ( predRemoved && (mode & kDropStlDefault) && narg == iall) {
367 if ( (mode & kDropStlDefault) && (narg >= 3)) {
368 unsigned int offset = (0==strncmp(
"const ",
fElements[0].c_str(),6)) ? 6 : 0;
369 offset += (0==strncmp(
"std::",
fElements[0].c_str()+offset,5)) ? 5 : 0;
370 if (0 == strcmp(
fElements[0].c_str()+offset,
"__shared_ptr"))
372 #ifdef _CONCURRENCE_H 373 static const std::string sharedPtrDef = std::to_string(__gnu_cxx::__default_lock_policy);
375 static const std::string sharedPtrDef = std::to_string(2);
385 for (
int i=1;i<narg; i++) {
386 if (strchr(
fElements[i].c_str(),
'<')==0) {
388 unsigned int offset = (0==strncmp(
"const ",
fElements[i].c_str(),6)) ? 6 : 0;
402 if (gInterpreterHelper->ExistingTypeCheck(
fElements[i], typeresult)
403 || gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(
fElements[i], typeresult)) {
404 if (!typeresult.empty())
fElements[i] = typeresult;
409 unsigned int tailOffset = 0;
410 if (tailLoc &&
fElements[tailLoc].compare(0,5,
"const") == 0) {
422 if (mode & kDropAllDefault) {
423 int nargNonDefault = 0;
424 std::string nonDefName = answ;
426 std::string nameSuperLong =
fName;
427 if (gInterpreterHelper)
428 gInterpreterHelper->GetPartiallyDesugaredName(nameSuperLong);
429 while (++nargNonDefault < narg) {
432 const char* closeTemplate =
" >";
433 if (nonDefName[nonDefName.length() - 1] !=
'>')
435 string nondef = nonDefName + closeTemplate;
436 if (gInterpreterHelper &&
437 gInterpreterHelper->IsAlreadyPartiallyDesugaredName(nondef, nameSuperLong))
439 if (nargNonDefault>1) nonDefName +=
",";
442 if (nargNonDefault < narg)
443 narg = nargNonDefault;
447 {
for (
int i=1;i<narg-1; i++) { answ +=
fElements[i]; answ+=
",";} }
448 if (narg>1) { answ +=
fElements[narg-1]; }
451 if ( answ.at(answ.size()-1) ==
'>') {
463 if (tailLoc) answ +=
fElements[tailLoc].c_str()+tailOffset;
472 unsigned char offset = 0;
473 if (type.compare(0,6,
"const ")==0) { offset += 6; }
474 offset +=
StdLen(type.substr(offset));
477 static const char *stls[] =
478 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
479 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap", 0};
480 static const size_t stllen[] =
481 { 3, 6, 4, 5, 3, 8, 3, 8, 6,
482 12, 13, 18, 13, 18, 0};
497 auto len = type.length();
500 for(
int k=1;stls[k];k++) {
501 if (len == stllen[k]) {
502 if (type.compare(offset,len,stls[k])==0)
return values[k];
506 for(
int k=1;stls[k];k++) {
if (type.compare(offset,len,stls[k])==0)
return values[k];}
516 static const char stln[] =
518 { 1, 1, 1, 1, 3, 3, 2, 2, 1,
530 for(
size_t i = 0; i < full.length(); ++i) {
532 case '<': { ++level;
break; }
534 if (level == 0)
return i;
539 if (level == 0)
return i;
545 return full.length();
552 return pos +
findNameEnd( {full.data()+pos,full.length()-pos} );
564 if (a==
"alloc")
return true;
565 if (a==
"__default_alloc_template<true,0>")
return true;
566 if (a==
"__malloc_alloc_template<0>")
return true;
568 const static int alloclen = strlen(
"allocator<");
569 if (a.
compare(0,alloclen,
"allocator<") != 0) {
583 std::string valuepart;
586 std::string norm_value;
589 if (valuepart != norm_value) {
609 const char *keyclassname,
610 const char *valueclassname)
612 if (
IsDefAlloc(allocname,keyclassname))
return true;
617 const static int alloclen = strlen(
"allocator<");
618 if (a.
compare(0,alloclen,
"allocator<") != 0) {
625 const static int pairlen = strlen(
"pair<");
626 if (a.
compare(0,pairlen,
"pair<") != 0) {
631 const static int constlen = strlen(
"const");
632 if (a.
compare(0,constlen+1,
"const ") == 0) {
640 if (k.
compare(0,constlen+1,
"const ") == 0) {
648 std::string alloc_keypart;
651 std::string norm_key;
654 if (alloc_keypart != norm_key) {
655 if ( norm_key[norm_key.length()-1] ==
'*' ) {
659 norm_key +=
" const";
661 if (alloc_keypart != norm_key) {
668 if ( (a[end-1] ==
'*') || a[end]==
' ' ) {
669 size_t skipSpace = (a[end] ==
' ');
670 if (a.
compare(end+skipSpace,constlen,
"const") == 0) {
671 end += constlen+skipSpace;
690 std::string valuepart;
693 std::string norm_value;
696 if (valuepart != norm_value) {
715 static bool IsDefElement(
const char *elementName,
const char* defaultElementName,
const char *classname)
717 string c = elementName;
721 const int elementlen = strlen(defaultElementName);
722 if (c.compare(pos,elementlen,defaultElementName) != 0) {
727 string k = classname;
728 if (c.compare(pos,k.length(),k) != 0) {
735 std::string norm_key;
738 if (keypart != norm_key) {
746 if (c.compare(pos,1,
">")!=0 && c.compare(pos,2,
" >")!=0) {
792 norm_name = std::string(name);
801 if (norm_name.length()>2 && norm_name[0]==
':' && norm_name[1]==
':') {
802 norm_name.erase(0,2);
805 if (gInterpreterHelper) {
807 std::string typeresult;
808 if (gInterpreterHelper->ExistingTypeCheck(norm_name, typeresult)
809 || gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(norm_name, typeresult)) {
811 if (!typeresult.empty()) norm_name = typeresult;
832 static const char* longlong_s =
"long long";
833 static const char* ulonglong_s =
"unsigned long long";
834 static const unsigned int longlong_len = strlen(longlong_s);
835 static const unsigned int ulonglong_len = strlen(ulonglong_s);
837 string result = original;
840 while( (pos = result.find(ulonglong_s,pos) ) >=0 ) {
841 result.replace(pos, ulonglong_len,
"ULong64_t");
844 while( (pos = result.find(longlong_s,pos) ) >=0 ) {
845 result.replace(pos, longlong_len,
"Long64_t");
855 const char *lastPos = original;
858 for(
auto cursor = original; *cursor !=
'\0'; ++cursor) {
859 if ( *cursor ==
'<' || *cursor ==
'(') ++depth;
860 else if ( *cursor ==
'>' || *cursor ==
')' ) --depth;
861 else if ( *cursor ==
':' ) {
862 if (depth==0 && *(cursor+1) ==
':' && *(cursor+2) !=
'\0') {
877 const char *t = full.c_str();
878 const unsigned int tlen( full.size() );
880 const char *starloc = t + tlen - 1;
881 bool hasconst =
false;
883 && (starloc-t) > 4 && 0 == strncmp((starloc-4),
"const",5)
884 && ( (*(starloc-5)) ==
' ' || (*(starloc-5)) ==
'*' || (*(starloc-5)) ==
'&' 885 || (*(starloc-5)) ==
'>' || (*(starloc-5)) ==
']') ) {
888 if ((*starloc-1)==
' ') {
894 if ( hasconst || (*starloc)==
'*' || (*starloc)==
'&' || (*starloc)==
']' ) {
895 bool isArray = ( (*starloc)==
']' );
896 while( t<=(starloc-1) && ((*(starloc-1))==
'*' || (*(starloc-1))==
'&' || (*(starloc-1))==
't' || isArray)) {
899 isArray = ! ( (*starloc)==
'[' );
900 }
else if ( (*(starloc-1))==
't' ) {
901 if ( (starloc-1-t) > 5 && 0 == strncmp((starloc-5),
"const",5)
902 && ( (*(starloc-6)) ==
' ' || (*(starloc-6)) ==
'*' || (*(starloc-6)) ==
'&' 903 || (*(starloc-6)) ==
'>' || (*(starloc-6)) ==
']')) {
914 if ((*(starloc-1))==
' ') {
919 const unsigned int starlen = strlen(starloc);
920 full.erase(tlen-starlen,starlen);
921 }
else if (hasconst) {
923 const unsigned int starlen = strlen(starloc);
924 full.erase(tlen-starlen,starlen);
944 if (strlen(type)==0)
return 0;
946 int cleantypeMode = 1 ;
955 unsigned int const_offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
956 bool isString =
false;
957 bool isStdString =
false;
958 static const char* basic_string_std =
"std::basic_string<char";
959 static const unsigned int basic_string_std_len = strlen(basic_string_std);
961 if (full.compare(const_offset,basic_string_std_len,basic_string_std) == 0
962 && full.size() > basic_string_std_len) {
965 }
else if (full.compare(const_offset,basic_string_std_len-5,basic_string_std+5) == 0
966 && full.size() > (basic_string_std_len-5)) {
971 size_t offset = isStdString ? basic_string_std_len : basic_string_std_len - 5;
972 offset += const_offset;
973 if ( full[offset] ==
'>' ) {
975 }
else if (full[offset] ==
',') {
977 if (full.compare(offset, 5,
"std::") == 0) {
980 static const char* char_traits_s =
"char_traits<char>";
981 static const unsigned int char_traits_len = strlen(char_traits_s);
982 if (full.compare(offset, char_traits_len, char_traits_s) == 0) {
983 offset += char_traits_len;
984 if ( full[offset] ==
'>') {
986 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
989 }
else if (full[offset] ==
',') {
991 if (full.compare(offset, 5,
"std::") == 0) {
994 static const char* allocator_s =
"allocator<char>";
995 static const unsigned int allocator_len = strlen(allocator_s);
996 if (full.compare(offset, allocator_len, allocator_s) == 0) {
997 offset += allocator_len;
998 if ( full[offset] ==
'>') {
1000 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1021 output.push_back(
string());
1022 if (const_offset && (mode & kKeepOuterConst)) {
1023 if (isStdString && !(mode &
kDropStd)) {
1024 output.push_back(
"const std::string");
1026 output.push_back(
"const string");
1029 if (isStdString && !(mode &
kDropStd)) {
1030 output.push_back(
"std::string");
1032 output.push_back(
"string");
1035 if (offset < full.length()) {
1038 string right( full.substr(offset) );
1041 output.back().append(right.c_str()+1);
1042 output.push_back(stars);
1044 output.push_back(
"");
1046 return output.size();
1052 unsigned int offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1057 if ( !full.empty() ) {
1061 const char *
c = strchr(full.c_str(),
'<');
1064 output.push_back(
string(full,0,c - full.c_str()));
1068 for(cursor = c + 1; *cursor !=
'\0' && !(level==0 && *cursor ==
'>'); ++cursor) {
1070 case '<': ++level;
break;
1071 case '>': --level;
break;
1074 output.push_back(std::string(c+1,cursor));
1081 if (*(cursor-1) ==
' ') {
1082 output.push_back(std::string(c+1,cursor-1));
1084 output.push_back(std::string(c+1,cursor));
1087 if (*(cursor+1)==
':') {
1090 nestedLoc = output.size();
1091 output.push_back((cursor+1));
1093 }
else if (level >= 0) {
1095 output.push_back(std::string(c+1,cursor));
1099 output.push_back(
string());
1100 output.push_back(full);
1103 if (!output.empty()) output.push_back(stars);
1104 return output.size();
1126 static const char*
remove[] = {
"class",
"const",
"volatile",0};
1127 static bool isinit =
false;
1128 static std::vector<size_t> lengths;
1130 for (
int k=0;
remove[k]; ++k) {
1131 lengths.push_back(strlen(
remove[k]));
1137 result.reserve(strlen(typeDesc)*2);
1141 for(c=typeDesc;*
c;c++) {
1144 if (!isalnum(c[ 1]) && c[ 1] !=
'_')
continue;
1146 if (kbl && (mode>=2 || lev==0)) {
1148 int n = (mode) ? 999 : 1;
1151 for (
int k=0; k<n &&
remove[k]; k++) {
1152 int rlen = lengths[k];
1155 if (strncmp(
remove[k],c,rlen))
continue;
1158 if (isalnum(c[rlen]) || c[rlen]==
'_' || c[rlen]==
'$')
continue;
1160 c+=rlen-1; done = 1;
break;
1165 kbl = (!isalnum(c[ 0]) && c[ 0]!=
'_' && c[ 0]!=
'$' && c[0]!=
'[' && c[0]!=
']' && c[0]!=
'-' && c[0]!=
'@');
1169 if (*c ==
'<' || *c ==
'(') lev++;
1170 if (lev==0 && !isalnum(*c)) {
1171 if (!strchr(
"*&:._$ []-@",*c))
break;
1175 if (c[0]==
'>' && result.size() && result[result.size()-1]==
'>') result+=
" ";
1179 if (*c ==
'>' || *c ==
')') lev--;
1216 size_t len = strlen(type);
1217 if (len < 2 || strncmp(type+len-2,
"_t",2) != 0)
return false;
1219 unsigned char offset = 0;
1220 if (strncmp(type,
"const ",6)==0) { offset += 6; }
1221 static const char *names[] = {
"CallFunc_t",
"ClassInfo_t",
"BaseClassInfo_t",
1222 "DataMemberInfo_t",
"FuncTempInfo_t",
"MethodInfo_t",
"MethodArgInfo_t",
1223 "TypeInfo_t",
"TypedefInfo_t",0};
1225 for(
int k=1;names[k];k++) {
if (strcmp(type+offset,names[k])==0)
return true;}
1234 size_t offset =
StdLen(classname);
1235 if ( strncmp(classname+offset,
"bitset<",strlen(
"bitset<"))==0)
return true;
1253 if (type.compare(0,6,
"const ",6) == 0)
1254 type.remove_prefix(6);
1256 while(type[type.length()-1]==
'*' ||
1257 type[type.length()-1]==
'&' ||
1258 type[type.length()-1]==
' ') {
1259 type.remove_suffix(1);
1272 auto pos = type.find(
'<');
1276 for (decltype(type.length()) level = 1;
c < type.length(); ++
c) {
1277 if (type[
c] ==
'<') ++level;
1278 if (type[
c] ==
'>') --level;
1279 if (level == 0)
break;
1281 if (
c != (type.length()-1) ) {
1285 return STLKind(type.substr(0,pos));
1301 if (strchr(type,
'<')==0)
return 0;
1312 classname +=
StdLen( classname );
1313 if ( strcmp(classname,
"string")==0 )
return true;
1314 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1315 if ( strncmp(classname,
"pair<",strlen(
"pair<"))==0)
return true;
1316 if ( strcmp(classname,
"allocator")==0)
return true;
1317 if ( strncmp(classname,
"allocator<",strlen(
"allocator<"))==0)
return true;
1318 if ( strncmp(classname,
"greater<",strlen(
"greater<"))==0)
return true;
1319 if ( strncmp(classname,
"less<",strlen(
"less<"))==0)
return true;
1320 if ( strncmp(classname,
"equal_to<",strlen(
"equal_to<"))==0)
return true;
1321 if ( strncmp(classname,
"hash<",strlen(
"hash<"))==0)
return true;
1322 if ( strncmp(classname,
"auto_ptr<",strlen(
"auto_ptr<"))==0)
return true;
1324 if ( strncmp(classname,
"vector<",strlen(
"vector<"))==0)
return true;
1325 if ( strncmp(classname,
"list<",strlen(
"list<"))==0)
return true;
1326 if ( strncmp(classname,
"forward_list<",strlen(
"forward_list<"))==0)
return true;
1327 if ( strncmp(classname,
"deque<",strlen(
"deque<"))==0)
return true;
1328 if ( strncmp(classname,
"map<",strlen(
"map<"))==0)
return true;
1329 if ( strncmp(classname,
"multimap<",strlen(
"multimap<"))==0)
return true;
1330 if ( strncmp(classname,
"set<",strlen(
"set<"))==0)
return true;
1331 if ( strncmp(classname,
"multiset<",strlen(
"multiset<"))==0)
return true;
1332 if ( strncmp(classname,
"unordered_set<",strlen(
"unordered_set<"))==0)
return true;
1333 if ( strncmp(classname,
"unordered_multiset<",strlen(
"unordered_multiset<"))==0)
return true;
1334 if ( strncmp(classname,
"unordered_map<",strlen(
"unordered_map<"))==0)
return true;
1335 if ( strncmp(classname,
"unordered_multimap<",strlen(
"unordered_multimap<"))==0)
return true;
1336 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1355 unsigned int cursor,
1357 unsigned int start_of_type,
1358 unsigned int end_of_type,
1359 unsigned int mod_start_of_type,
1361 std::string &result)
1363 std::string
type(modified && (mod_start_of_type < result.length()) ?
1364 result.substr(mod_start_of_type, string::npos)
1365 : string(tname, start_of_type, end_of_type == 0 ? cursor - start_of_type : end_of_type - start_of_type));
1367 if (gInterpreterHelper->ExistingTypeCheck(
type, typeresult)
1368 || gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(
type, typeresult)) {
1370 if (!typeresult.empty()) {
1373 result.replace(mod_start_of_type, string::npos,
1378 mod_start_of_type = start_of_type;
1379 result += string(tname,0,start_of_type);
1380 if (constprefix && typeresult.compare(0,6,
"const ",6) == 0) {
1381 result += typeresult.substr(6,string::npos);
1383 result += typeresult;
1386 }
else if (modified) {
1387 result.replace(mod_start_of_type, string::npos,
1391 if (end_of_type != 0 && end_of_type!=cursor) {
1392 result += std::string(tname,end_of_type,cursor-end_of_type);
1399 if (end_of_type != 0 && end_of_type!=cursor) {
1400 result += std::string(tname,end_of_type,cursor-end_of_type);
1410 unsigned int &cursor,
1412 std::string &result)
1419 bool constprefix =
false;
1421 if (tname[cursor]==
' ') {
1424 result += string(tname,0,cursor);
1426 while (tname[cursor]==
' ') ++cursor;
1429 if (tname[cursor]==
'c' && (cursor+6<len)) {
1430 if (strncmp(tname+cursor,
"const ",6) == 0) {
1432 if (modified) result +=
"const ";
1440 if (len > 5 && strncmp(tname+cursor,
"std::",5) == 0) {
1443 if (len > 2 && strncmp(tname+cursor,
"::",2) == 0) {
1448 unsigned int start_of_type = cursor;
1449 unsigned int end_of_type = 0;
1450 unsigned int mod_start_of_type = result.length();
1451 unsigned int prevScope = cursor;
1452 for ( ; cursor<len; ++cursor) {
1453 switch (tname[cursor]) {
1455 if ((cursor+1)>=len || tname[cursor+1]!=
':') {
1457 if (modified) result += (tname+prevScope);
1462 scope = result.substr(mod_start_of_type, string::npos);
1463 scope += std::string(tname+prevScope,cursor-prevScope);
1465 scope = std::string(tname, start_of_type, cursor - start_of_type);
1467 std::string scoperesult;
1468 bool isInlined =
false;
1469 if (gInterpreterHelper->ExistingTypeCheck(scope, scoperesult)
1470 ||gInterpreterHelper->GetPartiallyDesugaredNameWithScopeHandling(scope, scoperesult)) {
1472 if (!scoperesult.empty()) {
1475 if (constprefix && scoperesult.compare(0,6,
"const ",6) != 0) mod_start_of_type -= 6;
1476 result.replace(mod_start_of_type, string::npos,
1481 mod_start_of_type = start_of_type;
1482 result += string(tname,0,start_of_type);
1484 result += scoperesult;
1487 }
else if (modified) {
1488 result += std::string(tname+prevScope,cursor+1-prevScope);
1490 }
else if (!gInterpreterHelper->IsDeclaredScope(scope,isInlined)) {
1492 if (modified) result += (tname+prevScope);
1496 }
else if (isInlined) {
1500 mod_start_of_type = start_of_type;
1501 result += string(tname,0,start_of_type);
1503 result += string(tname,start_of_type,prevScope - start_of_type);
1505 }
else if (modified) {
1506 result += std::string(tname+prevScope,cursor+1-prevScope);
1510 prevScope = cursor+1;
1516 result += std::string(tname+prevScope,cursor+1-prevScope);
1522 }
while( cursor<len && tname[cursor] ==
',' );
1524 while (cursor<len && tname[cursor+1]==
' ') ++cursor;
1529 if (cursor+2<len && tname[cursor+1]==
':' && tname[cursor+2]==
':') {
1530 if (modified) result +=
"::";
1532 prevScope = cursor+1;
1534 if ( (cursor+1)<len && tname[cursor+1] ==
',') {
1536 if (modified) result +=
',';
1539 if ( (cursor+1)<len && tname[cursor+1] ==
'>') {
1541 if (modified) result +=
" >";
1544 if ( (cursor+1) >= len) {
1547 if (tname[cursor] !=
' ')
break;
1548 if (modified) prevScope = cursor+1;
1555 end_of_type = cursor;
1557 while ((cursor+1)<len && tname[cursor+1] ==
' ') ++cursor;
1559 auto next = cursor+1;
1560 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] ==
']'))
1565 result += string(tname,0,start_of_type);
1567 mod_start_of_type = start_of_type + 6;
1568 result += string(tname,start_of_type,end_of_type-start_of_type);
1569 }
else if (mod_start_of_type < result.length()) {
1570 result.insert(mod_start_of_type,
"const ");
1571 mod_start_of_type += 6;
1574 mod_start_of_type += 6;
1575 result += string(tname,start_of_type,end_of_type-start_of_type);
1578 end_of_type = cursor+1;
1579 prevScope = end_of_type;
1580 if ((next+5)==len || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1583 }
else if (next!=len && tname[next] !=
'*' && tname[next] !=
'&') {
1593 if (tname[cursor] !=
' ') end_of_type = cursor;
1595 auto next = cursor+1;
1596 if (strncmp(tname+next,
"const",5) == 0) {
1597 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1602 (tname[next] ==
' ' || tname[next] ==
'*' || tname[next] ==
'&')) {
1605 if (strncmp(tname+next,
"const",5) == 0) {
1606 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1618 if (modified && prevScope) {
1619 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1623 if (modified) result +=
',';
1627 if (modified && prevScope) {
1628 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1632 if (modified) result +=
'>';
1640 if (prevScope && modified) result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1657 if (tname == 0 || tname[0] == 0)
1659 if (!gInterpreterHelper)
1666 if (gInterpreterHelper->ExistingTypeCheck(tname, result))
1668 if (result.empty())
return tname;
1672 unsigned int len = strlen(tname);
1674 unsigned int cursor = 0;
1675 bool modified =
false;
1678 if (!modified)
return tname;
1692 static const char* sSTLtypes[] = {
1705 "basic_istringstream",
1708 "basic_ostringstream",
1712 "basic_stringstream",
1741 "istreambuf_iterator",
1750 "localedef utility",
1767 "moneypunct_byname",
1779 "ostreambuf_iterator",
1785 "pointer_to_binary_function",
1786 "pointer_to_unary_function",
1790 "raw_storage_iterator",
1809 "unordered_multimap",
1810 "unordered_multiset",
1816 static set<string> sSetSTLtypes;
1818 if (tname==0 || tname[0]==0)
return "";
1820 if (sSetSTLtypes.empty()) {
1822 const size_t nSTLtypes =
sizeof(sSTLtypes) /
sizeof(
const char*);
1823 for (
size_t i = 0; i < nSTLtypes; ++i)
1824 sSetSTLtypes.insert(sSTLtypes[i]);
1828 size_t len = strlen(tname);
1830 ret.reserve(len + 20);
1834 bool precScope =
false;
1835 while (!(isalnum(tname[b]) || tname[b] ==
'_') && b < len) {
1836 precScope = (b < len - 2) && (tname[b] ==
':') && (tname[b + 1] ==
':');
1848 while (e < len && (isalnum(tname[e]) || tname[e] ==
'_'))
1852 set<string>::const_iterator iSTLtype = sSetSTLtypes.find(
id);
1853 if (iSTLtype != sSetSTLtypes.end())
1868 class NameCleanerForIO {
1870 std::vector<std::unique_ptr<NameCleanerForIO>> fArgumentNodes = {};
1871 NameCleanerForIO* fMother;
1872 bool fHasChanged =
false;
1873 bool AreAncestorsSTLContOrArray()
1875 NameCleanerForIO* mother = fMother;
1876 if (!mother)
return false;
1877 bool isSTLContOrArray =
true;
1878 while (
nullptr != mother){
1881 mother = mother->fMother;
1884 return isSTLContOrArray;
1888 NameCleanerForIO(
const std::string& clName =
"",
1890 NameCleanerForIO* mother =
nullptr):fMother(mother)
1892 if (clName.back() !=
'>') {
1897 std::vector<std::string>
v;
1902 auto argsEnd = v.end();
1903 auto argsBeginPlusOne = ++v.begin();
1904 auto argPos = std::find_if(argsBeginPlusOne, argsEnd,
1905 [](std::string& arg){
return (!arg.empty() && arg.front() ==
':');});
1906 if (argPos != argsEnd) {
1907 const int lenght = clName.size();
1908 int wedgeBalance = 0;
1909 int lastOpenWedge = 0;
1910 for (
int i=lenght-1;i>-1;i--) {
1911 auto&
c = clName.at(i);
1915 }
else if (
c ==
'>') {
1917 }
else if (
c ==
':' && 0 == wedgeBalance) {
1919 auto nameToClean = clName.substr(0,i-1);
1920 NameCleanerForIO node(nameToClean, mode);
1921 auto cleanName = node.ToString();
1922 fHasChanged = node.HasChanged();
1928 cleanName += clName.substr(i+1,lastOpenWedge-i-1);
1931 auto lastTemplate = &clName.data()[i+1];
1943 unsigned int nargs = v.size() - 2;
1944 for (
unsigned int i=0;i<nargs;++i) {
1945 fArgumentNodes.emplace_back(
new NameCleanerForIO(v[i+1],mode,
this));
1949 bool HasChanged()
const {
return fHasChanged;}
1953 std::string
name(fName);
1955 if (fArgumentNodes.empty())
return name;
1960 name = fArgumentNodes.front()->ToString();
1966 auto stlContType = AreAncestorsSTLContOrArray();
1968 name = fArgumentNodes.front()->ToString();
1975 for (
auto& node : fArgumentNodes) {
1976 name += node->ToString() +
",";
1977 fHasChanged |= node->HasChanged();
1980 name += name.back() ==
'>' ?
" >" :
">";
1985 const std::vector<std::unique_ptr<NameCleanerForIO>>* GetChildNodes()
const {
return &fArgumentNodes;}
2000 NameCleanerForIO node(templateInstanceName, mode);
2001 auto nameForIO = node.ToString();
2003 *hasChanged = node.HasChanged();
2012 std::string& typeNameBuf,
2013 std::array<int, 5>& maxIndices,
2019 NameCleanerForIO node(typeName);
2022 auto childNodes = node.GetChildNodes();
2023 for (ndim = 1;ndim <=5 ; ndim++) {
2024 maxIndices[ndim-1] = std::atoi(childNodes->back()->GetName().c_str());
2025 auto& frontNode = childNodes->front();
2026 typeNameBuf = frontNode->GetName();
2028 typeNameBuf = frontNode->ToString();
2031 childNodes = frontNode->GetChildNodes();
2044 const char* mangled_name = ti.name();
2050 struct FunctionSplitInfo {
2052 std::string fReturnType;
2055 std::string fScopeName;
2058 std::string fFunctionName;
2062 std::vector<std::string> fFunctionTemplateArguments;
2065 std::vector<std::string> fFunctionParameters;
2074 std::stack<char> expected;
2075 for (std::size_t pos = 0, end = haystack.length(); pos < end; ++pos) {
2076 char c = haystack[pos];
2077 if (expected.empty()) {
2078 if (needles.
find(c) != std::string_view::npos)
2081 if (c == expected.top()) {
2087 case '<': expected.emplace(
'>');
break;
2088 case '(': expected.emplace(
')');
break;
2089 case '[': expected.emplace(
']');
break;
2092 return std::string_view::npos;
2098 std::size_t lenHaystack = haystack.length();
2099 std::size_t prevAfterColumn = 0;
2101 std::size_t posColumn = FindNonNestedNeedles(haystack.substr(prevAfterColumn),
":");
2102 if (posColumn == std::string_view::npos)
2103 return std::string_view::npos;
2104 prevAfterColumn += posColumn;
2106 if (prevAfterColumn + 1 >= lenHaystack)
2107 return std::string_view::npos;
2110 if (haystack[prevAfterColumn] ==
':')
2111 return prevAfterColumn - 1;
2115 return std::string_view::npos;
2120 while (!str.empty() && std::isspace(str[0]))
2121 str.remove_prefix(1);
2122 while (!str.empty() && std::isspace(str.back()))
2123 str.remove_suffix(1);
2131 return std::string(sv.data(), sv.length());
2144 std::size_t posArgs = FindNonNestedNeedles(decl,
"(");
2147 std::size_t prevAfterWhiteSpace = 0;
2148 static const char whitespace[] =
" \t\n";
2149 while (declNoArgs.length() > prevAfterWhiteSpace) {
2150 std::size_t posWS = FindNonNestedNeedles(declNoArgs.substr(prevAfterWhiteSpace), whitespace);
2151 if (posWS == std::string_view::npos)
2153 prevAfterWhiteSpace += posWS + 1;
2154 while (declNoArgs.length() > prevAfterWhiteSpace
2155 && strchr(whitespace, declNoArgs[prevAfterWhiteSpace]))
2156 ++prevAfterWhiteSpace;
2160 std::size_t endReturn = prevAfterWhiteSpace;
2161 while (declNoArgs.length() > endReturn
2162 && strchr(
"&* \t \n", declNoArgs[endReturn]))
2169 std::size_t prevAtScope = FindNonNestedDoubleColons(scopeFunctionTmplt);
2170 while (prevAtScope != std::string_view::npos
2171 && scopeFunctionTmplt.length() > prevAtScope + 2) {
2172 std::size_t posScope = FindNonNestedDoubleColons(scopeFunctionTmplt.substr(prevAtScope + 2));
2173 if (posScope == std::string_view::npos)
2175 prevAtScope += posScope + 2;
2178 std::size_t afterScope = prevAtScope + 2;
2179 if (prevAtScope == std::string_view::npos) {
2184 result.
fScopeName =
ToString(StripSurroundingSpace(scopeFunctionTmplt.substr(0, prevAtScope)));
2188 std::size_t posTmpltOpen = FindNonNestedNeedles(funcNameTmplArgs,
"<");
2189 if (posTmpltOpen != std::string_view::npos) {
2194 std::size_t posTmpltClose = FindNonNestedNeedles(tmpltArgs,
">");
2195 if (posTmpltClose != std::string_view::npos) {
2196 tmpltArgs = tmpltArgs.substr(0, posTmpltClose);
2197 std::size_t prevAfterArg = 0;
2198 while (tmpltArgs.length() > prevAfterArg) {
2199 std::size_t posComma = FindNonNestedNeedles(tmpltArgs.substr(prevAfterArg),
",");
2200 if (posComma == std::string_view::npos) {
2204 prevAfterArg += posComma + 1;
2214 if (posArgs != std::string_view::npos) {
2217 std::size_t posEndArgs = FindNonNestedNeedles(params,
")");
2218 if (posEndArgs != std::string_view::npos) {
2219 params = params.substr(0, posEndArgs);
2220 std::size_t prevAfterArg = 0;
2221 while (params.length() > prevAfterArg) {
2222 std::size_t posComma = FindNonNestedNeedles(params.substr(prevAfterArg),
",");
2223 if (posComma == std::string_view::npos) {
2228 prevAfterArg += posComma + 1;
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...
TSplitType(const char *type2split, EModType mode=TClassEdit::kNone)
default constructor
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT
std::vector< std::string > fFunctionTemplateArguments
Template arguments of the function template specialization, if any; will contain one element "" for f...
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 fScopeName
Name of the scope qualification of the function, possibly empty.
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)
std::string fFunctionName
Name of the function.
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.
std::string fReturnType
Return type of the function, might be empty if the function declaration string did not provide it...
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)
bool SplitFunction(std::string_view decl, FunctionSplitInfo &result)
Split a function declaration into its different parts.
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...
Result of splitting a function declaration into fReturnType fScopeName::fFunctionName<fFunctionTempla...
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)
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
std::vector< std::string > fFunctionParameters
Function parameters.
static RooMathCoreReg dummy
basic_string_view< char > string_view
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