29 #include "TClassEdit.h" 105 Warning(
"DeleteArray",
"Cannot properly delete emulated array of %s at %p, I don't know how many elements it has!",
fClass->
GetName(), p);
123 std::vector<std::string> inside;
125 int num = TClassEdit::GetSplit(
fName.c_str(),inside,nested);
128 if ( inside[0].find(
"stdext::hash_") != std::string::npos ) {
129 inside[0].replace(3,10,
"::");
131 if ( inside[0].find(
"__gnu_cxx::hash_") != std::string::npos ) {
132 inside[0].replace(0,16,
"std::");
134 fSTL_type = TClassEdit::STLKind(inside[0].c_str());
139 auto alignedSize = [](
size_t in) {
140 constexpr
size_t kSizeOfPtr =
sizeof(
void*);
141 return in + (kSizeOfPtr - in%kSizeOfPtr)%kSizeOfPtr;
145 case ROOT::kSTLmultimap:
146 nam =
"pair<"+inside[1]+
","+inside[2];
147 nam += (nam[nam.length()-1]==
'>') ?
" >" :
">";
169 case ROOT::kSTLbitset:
192 Fatal(
"TEmulatedCollectionProxy",
"Components of %s not analysed!",cl->
GetName());
194 Fatal(
"TEmulatedCollectionProxy",
"Collection class %s not found!",
fTypeinfo.name());
211 Fatal(
"TEmulatedCollectionProxy",
"Size> Logic error - no proxy object set.");
218 Resize(0, opt && *opt==
'f');
225 typedef std::string String_t;
232 case ROOT::kSTLmultimap:
245 for( i=left; i<nCurr; ++i, addr +=
fValDiff ) {
246 ((std::string*)addr)->~String_t();
250 for( i=left; i<nCurr; ++i, addr +=
fValDiff ) {
254 void* ptr = h->
ptr();
260 for( i=nCurr; i<left; ++i, addr +=
fValDiff ) {
264 if (force)
delete (std::string*)h->
ptr();
269 for( i=nCurr; i<left; ++i, addr +=
fValDiff ) {
286 for( i=left; i<nCurr; ++i, addr +=
fValDiff ) {
292 for( i=left; i<nCurr; ++i, addr +=
fValDiff )
293 ((std::string*)addr)->~String_t();
296 for( i=left; i<nCurr; ++i, addr +=
fValDiff ) {
306 for( i=nCurr; i<left; ++i, addr +=
fValDiff ) {
308 if (force)
delete (std::string*)h->
ptr();
313 for( i=nCurr; i<left; ++i, addr +=
fValDiff ) {
335 char* addr = ((
char*)
fEnv->
fStart) + fValDiff*nCurr;
338 case ROOT::kSTLmultimap:
346 for( i=0; i<=nCurr; ++i, offset +=
fValDiff ) {
353 for( i=nCurr; i<left; ++i, addr +=
fValDiff )
357 for( i=nCurr; i<left; ++i, addr +=
fValDiff )
358 ::
new(addr) std::string();
363 for( i=nCurr; i<left; ++i, addr +=
fValDiff )
379 for( i=0; i<=nCurr; ++i, offset +=
fValDiff ) {
386 for( i=nCurr; i<left; ++i, addr +=
fValDiff ) {
391 for( i=nCurr; i<left; ++i, addr +=
fValDiff )
392 ::
new(addr) std::string();
397 for( i=nCurr; i<left; ++i, addr +=
fValDiff )
410 size_t nCurr =
Size();
413 if ( left == nCurr ) {
416 else if ( left < nCurr ) {
417 Shrink(nCurr, left, force);
423 Fatal(
"TEmulatedCollectionProxy",
"Resize> Logic error - no proxy object set.");
431 size_t s = c->size();
437 Fatal(
"TEmulatedCollectionProxy",
"At> Logic error - no proxy object set.");
455 Fatal(
"Insert",
"Not yet implemented, require copy of objects.");
489 Error(
"TEmulatedCollectionProxy",
"fType %d is not supported yet!\n",
fVal->
fKind);
493 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)(((char*)itm) + fValDiff*idx); { x ;} ++idx;} break;} 498 DOLOOP( i->read_std_string(b) );
502 DOLOOP( i->read_std_string_pointer(b) );
504 DOLOOP( i->read_tstring_pointer(vsn3,b) );
538 Error(
"TEmulatedCollectionProxy",
"fType %d is not supported yet!\n",
fVal->
fKind);
541 #define DOLOOP(x) {int idx=0; while(idx<nElements) {StreamHelper* i=(StreamHelper*)(((char*)itm) + fValDiff*idx); { x ;} ++idx;} break;} 549 DOLOOP( i->write_std_string_pointer(b) );
551 DOLOOP( i->write_tstring_pointer(b) );
574 if ( nElements > 0 ) {
588 if ( nElements > 0 ) {
595 if ( nElements > 0 ) {
608 TString s1( TClassEdit::ShortType(dmFull,0) );
609 TString dmType( TClassEdit::ShortType(dmFull,1) );
610 Bool_t dmIsPtr = (s1 != dmType);
611 const char *dmTitle =
"Emulation";
614 if (dt && dt->
GetType() > 0 ) {
619 Error(
"Pair Emulation Building",
"%s is not yet supported in pair emulation",
629 static const char *full_string_name =
"basic_string<char,char_traits<char>,allocator<char> >";
630 if (strcmp(dmType,
"string") == 0 || strcmp(dmType,
"std::string") == 0 || strcmp(dmType,full_string_name)==0 ) {
633 if (TClassEdit::IsSTLCont(dmType)) {
634 return new TStreamerSTL(dmName,dmTitle,offset,dmFull,dmFull,dmIsPtr);
670 std::string pname =
"pair<"+fname+
","+
sname;
671 pname += (pname[pname.length()-1]==
'>') ?
" >" :
">";
681 Int_t sp =
sizeof(
void *);
683 if (size%sp != 0) size = size - size%sp + sp;
virtual UInt_t Size() const
Return the current size of the container.
Describe Streamer information for one class version.
virtual const char * GetName() const
Returns name of object.
void Expand(UInt_t nCurr, UInt_t left)
virtual void WriteFastArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0)=0
R__EXTERN Int_t gErrorIgnoreLevel
UInt_t fProperties
Additional properties of the value type (kNeedDelete)
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE) const
void Fatal(const char *location, const char *msgfmt,...)
virtual void SetSize(Int_t dsize)
Bool_t fPointers
Flag to indicate if containee has pointers (key or value)
std::string fName
Name of the class being proxied.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
static TStreamerElement * R__CreateEmulatedElement(const char *dmName, const char *dmFull, Int_t offset)
R__EXTERN TVirtualMutex * gInterpreterMutex
std::vector< char > Cont_t
virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass)=0
virtual void SetName(const char *name)
Set the name of the TNamed.
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist...
Buffer base class used for serializing objects.
UInt_t fCase
type of data of Value_type
Streamer around an arbitrary STL like container, which implements basic container functionality...
virtual TVirtualStreamerInfo * GetInfo()=0
size_t fSize
fSize of the contained object
void Move(void *arenaFrom, void *arenaTo) const
Register the fact that an object was moved from the memory location 'arenaFrom' to the memory locatio...
TEmulatedCollectionProxy(const TEmulatedCollectionProxy ©)
void SetClass(TClass *cl)
virtual void * Allocate(UInt_t n, Bool_t forceDelete)
Allocate the needed space.
Method0 fCreateEnv
Method to allocate an Environment holder.
void Error(const char *location, const char *msgfmt,...)
EDataType fKind
kind of ROOT-fundamental type
virtual void Resize(UInt_t n, Bool_t force_delete)
Resize the container.
virtual ~TEmulatedCollectionProxy()
int fValOffset
Offset from key to value (in maps)
TGenCollectionProxy * Initialize(Bool_t silent) const
Proxy initializer.
virtual TVirtualCollectionProxy * Generate() const
Virtual copy constructor.
void BuildOld()
rebuild the TStreamerInfo structure
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)=0
int fSTL_type
STL container type.
Basic data type descriptor (datatype information is obtained from CINT).
virtual void Clear(const char *opt="")
Clear the emulated collection.
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=0)=0
virtual TGenCollectionProxy * InitializeEx(Bool_t silent)
Proxy initializer.
The ROOT global object gROOT contains a list of all defined classes.
void Warning(const char *location, const char *msgfmt,...)
void WriteItems(int nElements, TBuffer &b)
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
int fValDiff
Offset between two consecutive value_types (memory layout).
#define R__LOCKGUARD2(mutex)
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=0)=0
virtual void Commit(void *env)
Commit the change.
virtual Int_t GetSize() const
Returns size of this element in bytes.
virtual void Insert(const void *data, void *container, size_t size)
Insert data into the container where data is a C-style array of the actual type contained in the coll...
void Shrink(UInt_t nCurr, UInt_t left, Bool_t force)
virtual Version_t GetOldVersion() const =0
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
std::atomic< Value * > fValue
Descriptor of the container value type.
TClassRef fType
TClass reference of Value_type in collection.
virtual void SetOnFileClass(TClass *cl)
static TStreamerInfo * R__GenerateTClassForPair(const std::string &f, const std::string &s)
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
TObjArray * GetElements() const
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Value * fKey
Descriptor of the key_type.
void ReadItems(int nElements, TBuffer &b)
void BuildCheck(TFile *file=0)
Check if built and consistent with the class dictionary.
virtual void DeleteArray(void *p, Bool_t dtorOnly=kFALSE) const
Helper class to facilitate I/O.
Proxy around an arbitrary container, which implements basic functionality and iteration.
Int_t Size() const
Get size of basic typedef'ed type.
EnvironBase_t * fEnv
Address of the currently proxied object.
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
virtual void * At(UInt_t idx)
Return the address of the value at index 'idx'.
Bool_t IsValid()
Return true if the Value has been properly initialized.
virtual void ReadBuffer(TBuffer &buff, void *pObj)
Info_t fTypeinfo
Type information.
virtual void Streamer(TBuffer &refBuffer)
Streamer Function.
virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)=0
Value * fVal
Descriptor of the Value_type.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.