#ifndef ROOT_TClassEdit
#define ROOT_TClassEdit
#include "RConfig.h"
#include "RConfigure.h"
#include <stdlib.h>
#ifdef R__WIN32
#ifndef UNDNAME_COMPLETE
#define UNDNAME_COMPLETE 0x0000
#endif
extern "C" {
char *__unDName(char *demangled, const char *mangled, int out_len,
void * (* pAlloc )(size_t), void (* pFree )(void *),
unsigned short int flags);
}
#else
#include <cxxabi.h>
#endif
#include <string>
#include <vector>
#ifndef ROOT_ESTLType
#include "ESTLType.h"
#endif
#ifdef R__OLDHPACC
namespace std {
using ::string;
using ::vector;
}
#endif
#if defined(__CYGWIN__)
#include <sstream>
namespace std {
template <typename T>
string to_string(T value) {
ostringstream os;
os << value;
return os.str();
}
}
#endif
namespace cling {
class Interpreter;
}
namespace ROOT {
namespace TMetaUtils {
class TNormalizedCtxt;
}
}
#include "RStringView.h"
namespace TClassEdit {
enum EModType {
kNone = 0,
kDropTrailStar = 1<<0,
kDropDefaultAlloc = 1<<1,
kDropAlloc = 1<<2,
kInnerClass = 1<<3,
kInnedMostClass = 1<<4,
kDropStlDefault = 1<<5,
kDropComparator = 1<<6,
kDropAllDefault = 1<<7,
kLong64 = 1<<8,
kDropStd = 1<<9,
kKeepOuterConst = 1<<10,
kResolveTypedef = 1<<11,
kDropPredicate = 1<<12,
kDropHash = 1<<13
};
enum ESTLType {
kNotSTL = ROOT::kNotSTL,
kVector = ROOT::kSTLvector,
kList = ROOT::kSTLlist,
kForwardist = ROOT::kSTLforwardlist,
kDeque = ROOT::kSTLdeque,
kMap = ROOT::kSTLmap,
kMultiMap = ROOT::kSTLmultimap,
kSet = ROOT::kSTLset,
kMultiSet = ROOT::kSTLmultiset,
kUnorderedSet = ROOT::kSTLunorderedset,
kUnorderedMultiSet = ROOT::kSTLunorderedmultiset,
kUnorderedMap = ROOT::kSTLunorderedmap,
kUnorderedMultiMap = ROOT::kSTLunorderedmultimap,
kBitSet = ROOT::kSTLbitset,
kEnd = ROOT::kSTLend
};
enum class EComplexType : short {
kNone,
kDouble,
kFloat,
kInt,
kLong
};
EComplexType GetComplexType(const char*);
class TInterpreterLookupHelper {
public:
TInterpreterLookupHelper() { }
virtual ~TInterpreterLookupHelper() { }
virtual bool ExistingTypeCheck(const std::string & ,
std::string & ) = 0;
virtual void GetPartiallyDesugaredName(std::string & ) = 0;
virtual bool IsAlreadyPartiallyDesugaredName(const std::string & ,
const std::string & ) = 0;
virtual bool IsDeclaredScope(const std::string & , bool & ) = 0;
virtual bool GetPartiallyDesugaredNameWithScopeHandling(const std::string & ,
std::string & ) = 0;
};
struct TSplitType {
const char *fName;
std::vector<std::string> fElements;
int fNestedLocation;
TSplitType(const char *type2split, EModType mode = TClassEdit::kNone);
int IsSTLCont(int testAlloc=0) const;
ROOT::ESTLType IsInSTL() const;
void ShortType(std::string &answer, int mode);
private:
TSplitType(const TSplitType&);
TSplitType &operator=(const TSplitType &);
};
void Init(TClassEdit::TInterpreterLookupHelper *helper);
std::string CleanType (const char *typeDesc,int mode = 0,const char **tail=0);
bool IsDefAlloc(const char *alloc, const char *classname);
bool IsDefAlloc(const char *alloc, const char *keyclassname, const char *valueclassname);
bool IsDefComp (const char *comp , const char *classname);
bool IsDefPred(const char *predname, const char *classname);
bool IsDefHash(const char *hashname, const char *classname);
bool IsInterpreterDetail(const char *type);
bool IsSTLBitset(const char *type);
ROOT::ESTLType UnderlyingIsSTLCont(std::string_view type);
ROOT::ESTLType IsSTLCont (std::string_view type);
int IsSTLCont (const char *type,int testAlloc);
bool IsStdClass(const char *type);
bool IsVectorBool(const char *name);
void GetNormalizedName(std::string &norm_name,std::string_view name);
std::string GetLong64_Name(const char *original);
std::string GetLong64_Name(const std::string& original);
int GetSplit (const char *type, std::vector<std::string> &output, int &nestedLoc, EModType mode = TClassEdit::kNone);
ROOT::ESTLType STLKind(std::string_view type);
int STLArgs (int kind);
std::string ResolveTypedef(const char *tname, bool resolveAll = false);
std::string ShortType (const char *typeDesc, int mode);
std::string InsertStd(const char *tname);
const char* GetUnqualifiedName(const char*name);
inline char* DemangleName(const char* mangled_name, int& errorCode)
{
errorCode=0;
#ifdef R__WIN32
char *demangled_name = __unDName(0, mangled_name, 0, malloc, free, UNDNAME_COMPLETE);
if (!demangled_name) {
errorCode = -1;
return nullptr;
}
#else
char *demangled_name = abi::__cxa_demangle(mangled_name, 0, 0, &errorCode);
if (!demangled_name || errorCode) {
free(demangled_name);
return nullptr;
}
#endif
return demangled_name;
}
char* DemangleTypeIdName(const std::type_info& ti, int& errorCode);
}
#endif