Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBufferFile.cxx
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Rene Brun 17/01/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/**
13\file TBufferFile.cxx
14\class TBufferFile
15\ingroup IO
16
17The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
18*/
19
20#include <string.h>
21#include <typeinfo>
22#include <string>
23#include <limits>
24#include <cassert>
25
26#include "TFile.h"
27#include "TBufferFile.h"
28#include "TExMap.h"
29#include "TClass.h"
30#include "TStorage.h"
31#include "TError.h"
32#include "TStreamer.h"
33#include "TStreamerInfo.h"
34#include "TStreamerElement.h"
35#include "TSchemaRuleSet.h"
37#include "TInterpreter.h"
38#include "TVirtualMutex.h"
39
40#if (defined(__linux) || defined(__APPLE__)) && defined(__i386__) && \
41 defined(__GNUC__)
42#define USE_BSWAPCPY
43#endif
44
45#ifdef USE_BSWAPCPY
46#include "Bswapcpy.h"
47#endif
48
49
50const UInt_t kNewClassTag = 0xFFFFFFFF;
51const UInt_t kClassMask = 0x80000000; // OR the class index with this
52const UInt_t kByteCountMask = 0x40000000; // OR the byte count with this
53const UInt_t kMaxMapCount = 0x3FFFFFFE; // last valid fMapCount and byte count
54const Version_t kByteCountVMask = 0x4000; // OR the version byte count with this
55const Version_t kMaxVersion = 0x3FFF; // highest possible version number
56const Int_t kMapOffset = 2; // first 2 map entries are taken by null obj and self obj
57
58
60
61////////////////////////////////////////////////////////////////////////////////
62/// Thread-safe check on StreamerInfos of a TClass
63
64static inline bool Class_Has_StreamerInfo(const TClass* cl)
65{
66 // NOTE: we do not need a R__LOCKGUARD2 since we know the
67 // mutex is available since the TClass constructor will make
68 // it
70 return cl->GetStreamerInfos()->GetLast()>1;
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Create an I/O buffer object. Mode should be either TBuffer::kRead or
75/// TBuffer::kWrite. By default the I/O buffer has a size of
76/// TBuffer::kInitialSize (1024) bytes.
77
80 fInfo(nullptr), fInfoStack()
81{
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Create an I/O buffer object. Mode should be either TBuffer::kRead or
86/// TBuffer::kWrite.
87
89 :TBufferIO(mode,bufsiz),
90 fInfo(nullptr), fInfoStack()
91{
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Create an I/O buffer object.
96/// Mode should be either TBuffer::kRead or
97/// TBuffer::kWrite. By default the I/O buffer has a size of
98/// TBuffer::kInitialSize (1024) bytes. An external buffer can be passed
99/// to TBuffer via the buf argument. By default this buffer will be adopted
100/// unless adopt is false.
101/// If the new buffer is <b>not</b> adopted and no memory allocation routine
102/// is provided, a Fatal error will be issued if the Buffer attempts to
103/// expand.
104
106 TBufferIO(mode,bufsiz,buf,adopt,reallocfunc),
107 fInfo(nullptr), fInfoStack()
108{
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Delete an I/O buffer object.
113
115{
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// Increment level.
120
122{
123 fInfoStack.push_back(fInfo);
124 fInfo = (TStreamerInfo*)info;
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Decrement level.
129
131{
132 fInfo = fInfoStack.back();
133 fInfoStack.pop_back();
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Handle old file formats.
138///
139/// Files written with versions older than 3.00/06 had a non-portable
140/// implementation of Long_t/ULong_t. These types should not have been
141/// used at all. However, because some users had already written many
142/// files with these types we provide this dirty patch for "backward
143/// compatibility"
144
145static void frombufOld(char *&buf, Long_t *x)
146{
147#ifdef R__BYTESWAP
148#ifdef R__B64
149 char *sw = (char *)x;
150 sw[0] = buf[7];
151 sw[1] = buf[6];
152 sw[2] = buf[5];
153 sw[3] = buf[4];
154 sw[4] = buf[3];
155 sw[5] = buf[2];
156 sw[6] = buf[1];
157 sw[7] = buf[0];
158#else
159 char *sw = (char *)x;
160 sw[0] = buf[3];
161 sw[1] = buf[2];
162 sw[2] = buf[1];
163 sw[3] = buf[0];
164#endif
165#else
166 memcpy(x, buf, sizeof(Long_t));
167#endif
168 buf += sizeof(Long_t);
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Read Long from TBuffer.
173
175{
176 TFile *file = (TFile*)fParent;
177 if (file && file->GetVersion() < 30006) {
179 } else {
180 frombuf(fBufCur, &l);
181 }
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Read TString from TBuffer.
186
188{
189 Int_t nbig;
190 UChar_t nwh;
191 *this >> nwh;
192 if (nwh == 0) {
193 s.UnLink();
194 s.Zero();
195 } else {
196 if (nwh == 255)
197 *this >> nbig;
198 else
199 nbig = nwh;
200
201 nbig = s.Clobber(nbig); // update length since Clobber clamps to MaxSize (if Fatal does not abort)
202 char *data = s.GetPointer();
203 data[nbig] = 0;
204 s.SetSize(nbig);
205 ReadFastArray(data, nbig);
206 }
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Write TString to TBuffer.
211
213{
214 Int_t nbig = s.Length();
215 UChar_t nwh;
216 if (nbig > 254) {
217 nwh = 255;
218 *this << nwh;
219 *this << nbig;
220 } else {
221 nwh = UChar_t(nbig);
222 *this << nwh;
223 }
224 const char *data = s.GetPointer();
225 WriteFastArray(data, nbig);
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Read std::string from TBuffer.
230
231void TBufferFile::ReadStdString(std::string *obj)
232{
233 if (obj == nullptr) {
234 Error("TBufferFile::ReadStdString","The std::string address is nullptr but should not");
235 return;
236 }
237 Int_t nbig;
238 UChar_t nwh;
239 *this >> nwh;
240 if (nwh == 0) {
241 obj->clear();
242 } else {
243 if( obj->size() ) {
244 // Insure that the underlying data storage is not shared
245 (*obj)[0] = '\0';
246 }
247 if (nwh == 255) {
248 *this >> nbig;
249 obj->resize(nbig,'\0');
250 ReadFastArray((char*)obj->data(),nbig);
251 }
252 else {
253 obj->resize(nwh,'\0');
254 ReadFastArray((char*)obj->data(),nwh);
255 }
256 }
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// Write std::string to TBuffer.
261
262void TBufferFile::WriteStdString(const std::string *obj)
263{
264 if (obj==0) {
265 *this << (UChar_t)0;
266 WriteFastArray("",0);
267 return;
268 }
269
270 UChar_t nwh;
271 Int_t nbig = obj->length();
272 if (nbig > 254) {
273 nwh = 255;
274 *this << nwh;
275 *this << nbig;
276 } else {
277 nwh = UChar_t(nbig);
278 *this << nwh;
279 }
280 WriteFastArray(obj->data(),nbig);
281}
282
283////////////////////////////////////////////////////////////////////////////////
284/// Read char* from TBuffer.
285
287{
288 delete [] s;
289 s = nullptr;
290
291 Int_t nch;
292 *this >> nch;
293 if (nch > 0) {
294 s = new char[nch+1];
295 ReadFastArray(s, nch);
296 s[nch] = 0;
297 }
298}
299
300////////////////////////////////////////////////////////////////////////////////
301/// Write char* into TBuffer.
302
304{
305 Int_t nch = 0;
306 if (s) {
307 nch = strlen(s);
308 *this << nch;
309 WriteFastArray(s,nch);
310 } else {
311 *this << nch;
312 }
313
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Set byte count at position cntpos in the buffer. Generate warning if
318/// count larger than kMaxMapCount. The count is excluded its own size.
319/// \note If underflow or overflow, an Error ir raised (stricter checks in Debug mode)
320
321void TBufferFile::SetByteCount(UInt_t cntpos, Bool_t packInVersion)
322{
323 assert( (sizeof(UInt_t) + cntpos) < static_cast<UInt_t>(fBufCur - fBuffer)
324 && (fBufCur >= fBuffer)
325 && static_cast<ULong64_t>(fBufCur - fBuffer) <= std::numeric_limits<UInt_t>::max()
326 && "Byte count position is after the end of the buffer");
327 const UInt_t cnt = UInt_t(fBufCur - fBuffer) - cntpos - sizeof(UInt_t);
328 char *buf = (char *)(fBuffer + cntpos);
329
330 // if true, pack byte count in two consecutive shorts, so it can
331 // be read by ReadVersion()
332 if (packInVersion) {
333 union {
334 UInt_t cnt;
335 Version_t vers[2];
336 } v;
337 v.cnt = cnt;
338#ifdef R__BYTESWAP
339 tobuf(buf, Version_t(v.vers[1] | kByteCountVMask));
340 tobuf(buf, v.vers[0]);
341#else
342 tobuf(buf, Version_t(v.vers[0] | kByteCountVMask));
343 tobuf(buf, v.vers[1]);
344#endif
345 } else
346 tobuf(buf, cnt | kByteCountMask);
347
348 if (cnt >= kMaxMapCount) {
349 Error("WriteByteCount", "bytecount too large (more than %d)", kMaxMapCount);
350 // exception
351 }
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Check byte count with current buffer position. They should
356/// match. If not print warning and position buffer in correct
357/// place determined by the byte count. Startpos is position of
358/// first byte where the byte count is written in buffer.
359/// Returns 0 if everything is ok, otherwise the bytecount offset
360/// (< 0 when read too little, >0 when read too much).
361
362Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss, const char *classname)
363{
364 if (!bcnt) return 0;
365
366 Int_t offset = 0;
367
368 Longptr_t endpos = Longptr_t(fBuffer) + startpos + bcnt + sizeof(UInt_t);
369
370 if (Longptr_t(fBufCur) != endpos) {
371 offset = Int_t(Longptr_t(fBufCur) - endpos);
372
373 const char *name = clss ? clss->GetName() : classname ? classname : 0;
374
375 if (name) {
376 if (offset < 0) {
377 Error("CheckByteCount", "object of class %s read too few bytes: %d instead of %d",
378 name,bcnt+offset,bcnt);
379 }
380 if (offset > 0) {
381 Error("CheckByteCount", "object of class %s read too many bytes: %d instead of %d",
382 name,bcnt+offset,bcnt);
383 if (fParent)
384 Warning("CheckByteCount","%s::Streamer() not in sync with data on file %s, fix Streamer()",
385 name, fParent->GetName());
386 else
387 Warning("CheckByteCount","%s::Streamer() not in sync with data, fix Streamer()",
388 name);
389 }
390 }
391 if ( ((char *)endpos) > fBufMax ) {
393 Error("CheckByteCount",
394 "Byte count probably corrupted around buffer position %d:\n\t%d for a possible maximum of %d",
395 startpos, bcnt, offset);
397
398 } else {
399
400 fBufCur = (char *) endpos;
401
402 }
403 }
404 return offset;
405}
406
407////////////////////////////////////////////////////////////////////////////////
408/// Check byte count with current buffer position. They should
409/// match. If not print warning and position buffer in correct
410/// place determined by the byte count. Startpos is position of
411/// first byte where the byte count is written in buffer.
412/// Returns 0 if everything is ok, otherwise the bytecount offset
413/// (< 0 when read too little, >0 when read too much).
414
416{
417 if (!bcnt) return 0;
418 return CheckByteCount( startpos, bcnt, clss, nullptr);
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// Check byte count with current buffer position. They should
423/// match. If not print warning and position buffer in correct
424/// place determined by the byte count. Startpos is position of
425/// first byte where the byte count is written in buffer.
426/// Returns 0 if everything is ok, otherwise the bytecount offset
427/// (< 0 when read too little, >0 when read too much).
428
429Int_t TBufferFile::CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname)
430{
431 if (!bcnt) return 0;
432 return CheckByteCount( startpos, bcnt, nullptr, classname);
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Read a Float16_t from the buffer,
437/// see comments about Float16_t encoding at TBufferFile::WriteFloat16().
438
440{
441 if (ele && ele->GetFactor() != 0) {
442 ReadWithFactor(f, ele->GetFactor(), ele->GetXmin());
443 } else {
444 Int_t nbits = 0;
445 if (ele) nbits = (Int_t)ele->GetXmin();
446 if (!nbits) nbits = 12;
447 ReadWithNbits(f, nbits);
448 }
449}
450
451////////////////////////////////////////////////////////////////////////////////
452/// Read a Double32_t from the buffer,
453/// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
454
456{
457 if (ele && ele->GetFactor() != 0) {
458 ReadWithFactor(d, ele->GetFactor(), ele->GetXmin());
459 } else {
460 Int_t nbits = 0;
461 if (ele) nbits = (Int_t)ele->GetXmin();
462 if (!nbits) {
463 //we read a float and convert it to double
464 Float_t afloat;
465 *this >> afloat;
466 d[0] = (Double_t)afloat;
467 } else {
468 ReadWithNbits(d, nbits);
469 }
470 }
471}
472
473////////////////////////////////////////////////////////////////////////////////
474/// Read a Float16_t from the buffer when the factor and minimum value have been specified
475/// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
476
478{
479 //a range was specified. We read an integer and convert it back to a double.
480 UInt_t aint;
481 frombuf(this->fBufCur,&aint);
482 ptr[0] = (Float_t)(aint/factor + minvalue);
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// Read a Float16_t from the buffer when the number of bits is specified (explicitly or not)
487/// see comments about Float16_t encoding at TBufferFile::WriteFloat16().
488
490{
491 //we read the exponent and the truncated mantissa of the float
492 //and rebuild the float.
493 union {
494 Float_t fFloatValue;
495 Int_t fIntValue;
496 } temp;
497 UChar_t theExp;
498 UShort_t theMan;
499 frombuf(this->fBufCur,&theExp);
500 frombuf(this->fBufCur,&theMan);
501 temp.fIntValue = theExp;
502 temp.fIntValue <<= 23;
503 temp.fIntValue |= (theMan & ((1<<(nbits+1))-1)) <<(23-nbits);
504 if(1<<(nbits+1) & theMan) temp.fFloatValue = -temp.fFloatValue;
505 ptr[0] = temp.fFloatValue;
506}
507
508////////////////////////////////////////////////////////////////////////////////
509/// Read a Double32_t from the buffer when the factor and minimum value have been specified
510/// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
511
513{
514 //a range was specified. We read an integer and convert it back to a double.
515 UInt_t aint;
516 frombuf(this->fBufCur,&aint);
517 ptr[0] = (Double_t)(aint/factor + minvalue);
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Read a Double32_t from the buffer when the number of bits is specified (explicitly or not)
522/// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
523
525{
526 //we read the exponent and the truncated mantissa of the float
527 //and rebuild the float.
528 union {
529 Float_t fFloatValue;
530 Int_t fIntValue;
531 } temp;
532 UChar_t theExp;
533 UShort_t theMan;
534 frombuf(this->fBufCur,&theExp);
535 frombuf(this->fBufCur,&theMan);
536 temp.fIntValue = theExp;
537 temp.fIntValue <<= 23;
538 temp.fIntValue |= (theMan & ((1<<(nbits+1))-1)) <<(23-nbits);
539 if(1<<(nbits+1) & theMan) temp.fFloatValue = -temp.fFloatValue;
540 ptr[0] = (Double_t)temp.fFloatValue;
541}
542
543////////////////////////////////////////////////////////////////////////////////
544/// Write a Float16_t to the buffer.
545///
546/// The following cases are supported for streaming a Float16_t type
547/// depending on the range declaration in the comment field of the data member:
548/// Case | Example |
549/// -----|---------|
550/// A | Float16_t fNormal; |
551/// B | Float16_t fTemperature; //[0,100]|
552/// C | Float16_t fCharge; //[-1,1,2]|
553/// D | Float16_t fVertex[3]; //[-30,30,10]|
554/// E | Float16_t fChi2; //[0,0,6]|
555/// F | Int_t fNsp;<br>Float16_t* fPointValue; //[fNsp][0,3]|
556///
557/// - In case A fNormal is converted from a Float_t to a Float_t with mantissa truncated to 12 bits
558/// - In case B fTemperature is converted to a 32 bit unsigned integer
559/// - In case C fCharge is converted to a 2 bits unsigned integer
560/// - In case D the array elements of fVertex are converted to an unsigned 10 bits integer
561/// - In case E fChi2 is converted to a Float_t with truncated precision at 6 bits
562/// - In case F the fNsp elements of array fPointvalue are converted to an unsigned 32 bit integer
563/// Note that the range specifier must follow the dimension specifier.
564/// Case B has more precision (9 to 10 significative digits than case A (6 to 7 digits).
565/// In Case A and E, the exponent is stored as is (8 bits), for a total of 21 bits (including 1 bit for sign)
566///
567/// The range specifier has the general format: [xmin,xmax] or [xmin,xmax,nbits]
568/// - [0,1];
569/// - [-10,100];
570/// - [-pi,pi], [-pi/2,pi/4],[-2pi,2*pi]
571/// - [-10,100,16]
572/// - [0,0,8]
573/// if nbits is not specified, or nbits <2 or nbits>16 it is set to 16. If
574/// (xmin==0 and xmax==0 and nbits <=14) the float word will have
575/// its mantissa truncated to nbits significative bits.
576///
577/// ## IMPORTANT NOTE
578/// ### NOTE 1
579/// Lets assume an original variable float x:
580/// When using the format [0,0,8] (ie range not specified) you get the best
581/// relative precision when storing and reading back the truncated x, say xt.
582/// The variance of (x-xt)/x will be better than when specifying a range
583/// for the same number of bits. However the precision relative to the
584/// range (x-xt)/(xmax-xmin) will be worst, and vice-versa.
585/// The format [0,0,8] is also interesting when the range of x is infinite
586/// or unknown.
587///
588/// ### NOTE 2
589/// It is important to understand the difference with the meaning of nbits
590/// - in case of [-1,1,nbits], nbits is the total number of bits used to make
591/// the conversion from a float to an integer
592/// - in case of [0,0,nbits], nbits is the number of bits used for the mantissa, to which is added 8 bits for the exponent.
593///
594/// See example of use of the Float16_t data type in tutorial float16.C
595/// \image html tbufferfile_double32.gif
596
598{
599
600 if (ele && ele->GetFactor() != 0) {
601 //A range is specified. We normalize the double to the range and
602 //convert it to an integer using a scaling factor that is a function of nbits.
603 //see TStreamerElement::GetRange.
604 Double_t x = f[0];
605 Double_t xmin = ele->GetXmin();
606 Double_t xmax = ele->GetXmax();
607 if (x < xmin) x = xmin;
608 if (x > xmax) x = xmax;
609 UInt_t aint = UInt_t(0.5+ele->GetFactor()*(x-xmin)); *this << aint;
610 } else {
611 Int_t nbits = 0;
612 //number of bits stored in fXmin (see TStreamerElement::GetRange)
613 if (ele) nbits = (Int_t)ele->GetXmin();
614 if (!nbits) nbits = 12;
615 //a range is not specified, but nbits is.
616 //In this case we truncate the mantissa to nbits and we stream
617 //the exponent as a UChar_t and the mantissa as a UShort_t.
618 union {
619 Float_t fFloatValue;
620 Int_t fIntValue;
621 };
622 fFloatValue = f[0];
623 UChar_t theExp = (UChar_t)(0x000000ff & ((fIntValue<<1)>>24));
624 UShort_t theMan = ((1<<(nbits+1))-1) & (fIntValue>>(23-nbits-1));
625 theMan++;
626 theMan = theMan>>1;
627 if (theMan&1<<nbits) theMan = (1<<nbits) - 1;
628 if (fFloatValue < 0) theMan |= 1<<(nbits+1);
629 *this << theExp;
630 *this << theMan;
631 }
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Write a Double32_t to the buffer.
636///
637/// The following cases are supported for streaming a Double32_t type
638/// depending on the range declaration in the comment field of the data member:
639/// Case | Example |
640/// -----|---------|
641/// A | Double32_t fNormal; |
642/// B | Double32_t fTemperature; //[0,100]|
643/// C | Double32_t fCharge; //[-1,1,2]|
644/// D | Double32_t fVertex[3]; //[-30,30,10]|
645/// E | Double32_t fChi2; //[0,0,6]|
646/// F | Int_t fNsp;<br>Double32_t* fPointValue; //[fNsp][0,3]|
647///
648/// In case A fNormal is converted from a Double_t to a Float_t
649/// In case B fTemperature is converted to a 32 bit unsigned integer
650/// In case C fCharge is converted to a 2 bits unsigned integer
651/// In case D the array elements of fVertex are converted to an unsigned 10 bits integer
652/// In case E fChi2 is converted to a Float_t with mantissa truncated precision at 6 bits
653/// In case F the fNsp elements of array fPointvalue are converted to an unsigned 32 bit integer
654/// Note that the range specifier must follow the dimension specifier.
655/// Case B has more precision (9 to 10 significative digits than case A (6 to 7 digits).
656/// See TBufferFile::WriteFloat16 for more information.
657///
658/// see example of use of the Double32_t data type in tutorial double32.C
659/// \image html tbufferfile_double32.gif
660
662{
663
664 if (ele && ele->GetFactor() != 0) {
665 //A range is specified. We normalize the double to the range and
666 //convert it to an integer using a scaling factor that is a function of nbits.
667 //see TStreamerElement::GetRange.
668 Double_t x = d[0];
669 Double_t xmin = ele->GetXmin();
670 Double_t xmax = ele->GetXmax();
671 if (x < xmin) x = xmin;
672 if (x > xmax) x = xmax;
673 UInt_t aint = UInt_t(0.5+ele->GetFactor()*(x-xmin)); *this << aint;
674 } else {
675 Int_t nbits = 0;
676 //number of bits stored in fXmin (see TStreamerElement::GetRange)
677 if (ele) nbits = (Int_t)ele->GetXmin();
678 if (!nbits) {
679 //if no range and no bits specified, we convert from double to float
680 Float_t afloat = (Float_t)d[0];
681 *this << afloat;
682 } else {
683 //a range is not specified, but nbits is.
684 //In this case we truncate the mantissa to nbits and we stream
685 //the exponent as a UChar_t and the mantissa as a UShort_t.
686 union {
687 Float_t fFloatValue;
688 Int_t fIntValue;
689 };
690 fFloatValue = (Float_t)d[0];
691 UChar_t theExp = (UChar_t)(0x000000ff & ((fIntValue<<1)>>24));
692 UShort_t theMan = ((1<<(nbits+1))-1) & (fIntValue>>(23-nbits-1)) ;
693 theMan++;
694 theMan = theMan>>1;
695 if (theMan&1<<nbits) theMan = (1<<nbits)-1 ;
696 if (fFloatValue < 0) theMan |= 1<<(nbits+1);
697 *this << theExp;
698 *this << theMan;
699 }
700 }
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Read array of bools from the I/O buffer. Returns the number of
705/// bools read. If argument is a 0 pointer then space will be
706/// allocated for the array.
707
709{
711
712 Int_t n;
713 *this >> n;
714
715 if (n <= 0 || n > fBufSize) return 0;
716
717 if (!b) b = new Bool_t[n];
718
719 if (sizeof(Bool_t) > 1) {
720 for (int i = 0; i < n; i++)
721 frombuf(fBufCur, &b[i]);
722 } else {
723 Int_t l = sizeof(Bool_t)*n;
724 memcpy(b, fBufCur, l);
725 fBufCur += l;
726 }
727
728 return n;
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Read array of characters from the I/O buffer. Returns the number of
733/// characters read. If argument is a 0 pointer then space will be
734/// allocated for the array.
735
737{
739
740 Int_t n;
741 *this >> n;
742 Int_t l = sizeof(Char_t)*n;
743
744 if (l <= 0 || l > fBufSize) return 0;
745
746 if (!c) c = new Char_t[n];
747
748 memcpy(c, fBufCur, l);
749 fBufCur += l;
750
751 return n;
752}
753
754////////////////////////////////////////////////////////////////////////////////
755/// Read array of shorts from the I/O buffer. Returns the number of shorts
756/// read. If argument is a 0 pointer then space will be allocated for the
757/// array.
758
760{
762
763 Int_t n;
764 *this >> n;
765 Int_t l = sizeof(Short_t)*n;
766
767 if (l <= 0 || l > fBufSize) return 0;
768
769 if (!h) h = new Short_t[n];
770
771#ifdef R__BYTESWAP
772# ifdef USE_BSWAPCPY
774 fBufCur += l;
775# else
776 for (int i = 0; i < n; i++)
777 frombuf(fBufCur, &h[i]);
778# endif
779#else
780 memcpy(h, fBufCur, l);
781 fBufCur += l;
782#endif
783
784 return n;
785}
786
787////////////////////////////////////////////////////////////////////////////////
788/// Read array of ints from the I/O buffer. Returns the number of ints
789/// read. If argument is a 0 pointer then space will be allocated for the
790/// array.
791
793{
795
796 Int_t n;
797 *this >> n;
798 Int_t l = sizeof(Int_t)*n;
799
800 if (l <= 0 || l > fBufSize) return 0;
801
802 if (!ii) ii = new Int_t[n];
803
804#ifdef R__BYTESWAP
805# ifdef USE_BSWAPCPY
806 bswapcpy32(ii, fBufCur, n);
807 fBufCur += l;
808# else
809 for (int i = 0; i < n; i++)
810 frombuf(fBufCur, &ii[i]);
811# endif
812#else
813 memcpy(ii, fBufCur, l);
814 fBufCur += l;
815#endif
816
817 return n;
818}
819
820////////////////////////////////////////////////////////////////////////////////
821/// Read array of longs from the I/O buffer. Returns the number of longs
822/// read. If argument is a 0 pointer then space will be allocated for the
823/// array.
824
826{
828
829 Int_t n;
830 *this >> n;
831 Int_t l = sizeof(Long_t)*n;
832
833 if (l <= 0 || l > fBufSize) return 0;
834
835 if (!ll) ll = new Long_t[n];
836
837 TFile *file = (TFile*)fParent;
838 if (file && file->GetVersion() < 30006) {
839 for (int i = 0; i < n; i++) frombufOld(fBufCur, &ll[i]);
840 } else {
841 for (int i = 0; i < n; i++) frombuf(fBufCur, &ll[i]);
842 }
843 return n;
844}
845
846////////////////////////////////////////////////////////////////////////////////
847/// Read array of long longs from the I/O buffer. Returns the number of
848/// long longs read. If argument is a 0 pointer then space will be
849/// allocated for the array.
850
852{
854
855 Int_t n;
856 *this >> n;
857 Int_t l = sizeof(Long64_t)*n;
858
859 if (l <= 0 || l > fBufSize) return 0;
860
861 if (!ll) ll = new Long64_t[n];
862
863#ifdef R__BYTESWAP
864 for (int i = 0; i < n; i++)
865 frombuf(fBufCur, &ll[i]);
866#else
867 memcpy(ll, fBufCur, l);
868 fBufCur += l;
869#endif
870
871 return n;
872}
873
874////////////////////////////////////////////////////////////////////////////////
875/// Read array of floats from the I/O buffer. Returns the number of floats
876/// read. If argument is a 0 pointer then space will be allocated for the
877/// array.
878
880{
882
883 Int_t n;
884 *this >> n;
885 Int_t l = sizeof(Float_t)*n;
886
887 if (l <= 0 || l > fBufSize) return 0;
888
889 if (!f) f = new Float_t[n];
890
891#ifdef R__BYTESWAP
892# ifdef USE_BSWAPCPY
894 fBufCur += l;
895# else
896 for (int i = 0; i < n; i++)
897 frombuf(fBufCur, &f[i]);
898# endif
899#else
900 memcpy(f, fBufCur, l);
901 fBufCur += l;
902#endif
903
904 return n;
905}
906
907////////////////////////////////////////////////////////////////////////////////
908/// Read array of doubles from the I/O buffer. Returns the number of doubles
909/// read. If argument is a 0 pointer then space will be allocated for the
910/// array.
911
913{
915
916 Int_t n;
917 *this >> n;
918 Int_t l = sizeof(Double_t)*n;
919
920 if (l <= 0 || l > fBufSize) return 0;
921
922 if (!d) d = new Double_t[n];
923
924#ifdef R__BYTESWAP
925 for (int i = 0; i < n; i++)
926 frombuf(fBufCur, &d[i]);
927#else
928 memcpy(d, fBufCur, l);
929 fBufCur += l;
930#endif
931
932 return n;
933}
934
935////////////////////////////////////////////////////////////////////////////////
936/// Read array of floats (written as truncated float) from the I/O buffer.
937/// Returns the number of floats read.
938/// If argument is a 0 pointer then space will be allocated for the array.
939/// see comments about Float16_t encoding at TBufferFile::WriteFloat16
940
942{
944
945 Int_t n;
946 *this >> n;
947
948 if (n <= 0 || 3*n > fBufSize) return 0;
949
950 if (!f) f = new Float_t[n];
951
953
954 return n;
955}
956
957////////////////////////////////////////////////////////////////////////////////
958/// Read array of doubles (written as float) from the I/O buffer.
959/// Returns the number of doubles read.
960/// If argument is a 0 pointer then space will be allocated for the array.
961/// see comments about Double32_t encoding at TBufferFile::WriteDouble32
962
964{
966
967 Int_t n;
968 *this >> n;
969
970 if (n <= 0 || 3*n > fBufSize) return 0;
971
972 if (!d) d = new Double_t[n];
973
975
976 return n;
977}
978
979////////////////////////////////////////////////////////////////////////////////
980/// Read array of bools from the I/O buffer. Returns the number of bools
981/// read.
982
984{
986
987 Int_t n;
988 *this >> n;
989
990 if (n <= 0 || n > fBufSize) return 0;
991
992 if (!b) return 0;
993
994 if (sizeof(Bool_t) > 1) {
995 for (int i = 0; i < n; i++)
996 frombuf(fBufCur, &b[i]);
997 } else {
998 Int_t l = sizeof(Bool_t)*n;
999 memcpy(b, fBufCur, l);
1000 fBufCur += l;
1001 }
1002
1003 return n;
1004}
1005
1006////////////////////////////////////////////////////////////////////////////////
1007/// Read array of characters from the I/O buffer. Returns the number of
1008/// characters read.
1009
1011{
1013
1014 Int_t n;
1015 *this >> n;
1016 Int_t l = sizeof(Char_t)*n;
1017
1018 if (l <= 0 || l > fBufSize) return 0;
1019
1020 if (!c) return 0;
1021
1022 memcpy(c, fBufCur, l);
1023 fBufCur += l;
1024
1025 return n;
1026}
1027
1028////////////////////////////////////////////////////////////////////////////////
1029/// Read array of shorts from the I/O buffer. Returns the number of shorts
1030/// read.
1031
1033{
1035
1036 Int_t n;
1037 *this >> n;
1038 Int_t l = sizeof(Short_t)*n;
1039
1040 if (l <= 0 || l > fBufSize) return 0;
1041
1042 if (!h) return 0;
1043
1044#ifdef R__BYTESWAP
1045# ifdef USE_BSWAPCPY
1046 bswapcpy16(h, fBufCur, n);
1047 fBufCur += l;
1048# else
1049 for (int i = 0; i < n; i++)
1050 frombuf(fBufCur, &h[i]);
1051# endif
1052#else
1053 memcpy(h, fBufCur, l);
1054 fBufCur += l;
1055#endif
1056
1057 return n;
1058}
1059
1060////////////////////////////////////////////////////////////////////////////////
1061/// Read array of ints from the I/O buffer. Returns the number of ints
1062/// read.
1063
1065{
1067
1068 Int_t n;
1069 *this >> n;
1070 Int_t l = sizeof(Int_t)*n;
1071
1072 if (l <= 0 || l > fBufSize) return 0;
1073
1074 if (!ii) return 0;
1075
1076#ifdef R__BYTESWAP
1077# ifdef USE_BSWAPCPY
1078 bswapcpy32(ii, fBufCur, n);
1079 fBufCur += sizeof(Int_t)*n;
1080# else
1081 for (int i = 0; i < n; i++)
1082 frombuf(fBufCur, &ii[i]);
1083# endif
1084#else
1085 memcpy(ii, fBufCur, l);
1086 fBufCur += l;
1087#endif
1088
1089 return n;
1090}
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Read array of longs from the I/O buffer. Returns the number of longs
1094/// read.
1095
1097{
1099
1100 Int_t n;
1101 *this >> n;
1102 Int_t l = sizeof(Long_t)*n;
1103
1104 if (l <= 0 || l > fBufSize) return 0;
1105
1106 if (!ll) return 0;
1107
1108 TFile *file = (TFile*)fParent;
1109 if (file && file->GetVersion() < 30006) {
1110 for (int i = 0; i < n; i++) frombufOld(fBufCur, &ll[i]);
1111 } else {
1112 for (int i = 0; i < n; i++) frombuf(fBufCur, &ll[i]);
1113 }
1114 return n;
1115}
1116
1117////////////////////////////////////////////////////////////////////////////////
1118/// Read array of long longs from the I/O buffer. Returns the number of
1119/// long longs read.
1120
1122{
1124
1125 Int_t n;
1126 *this >> n;
1127 Int_t l = sizeof(Long64_t)*n;
1128
1129 if (l <= 0 || l > fBufSize) return 0;
1130
1131 if (!ll) return 0;
1132
1133#ifdef R__BYTESWAP
1134 for (int i = 0; i < n; i++)
1135 frombuf(fBufCur, &ll[i]);
1136#else
1137 memcpy(ll, fBufCur, l);
1138 fBufCur += l;
1139#endif
1140
1141 return n;
1142}
1143
1144////////////////////////////////////////////////////////////////////////////////
1145/// Read array of floats from the I/O buffer. Returns the number of floats
1146/// read.
1147
1149{
1151
1152 Int_t n;
1153 *this >> n;
1154 Int_t l = sizeof(Float_t)*n;
1155
1156 if (n <= 0 || l > fBufSize) return 0;
1157
1158 if (!f) return 0;
1159
1160#ifdef R__BYTESWAP
1161# ifdef USE_BSWAPCPY
1162 bswapcpy32(f, fBufCur, n);
1163 fBufCur += sizeof(Float_t)*n;
1164# else
1165 for (int i = 0; i < n; i++)
1166 frombuf(fBufCur, &f[i]);
1167# endif
1168#else
1169 memcpy(f, fBufCur, l);
1170 fBufCur += l;
1171#endif
1172
1173 return n;
1174}
1175
1176////////////////////////////////////////////////////////////////////////////////
1177/// Read array of doubles from the I/O buffer. Returns the number of doubles
1178/// read.
1179
1181{
1183
1184 Int_t n;
1185 *this >> n;
1186 Int_t l = sizeof(Double_t)*n;
1187
1188 if (n <= 0 || l > fBufSize) return 0;
1189
1190 if (!d) return 0;
1191
1192#ifdef R__BYTESWAP
1193 for (int i = 0; i < n; i++)
1194 frombuf(fBufCur, &d[i]);
1195#else
1196 memcpy(d, fBufCur, l);
1197 fBufCur += l;
1198#endif
1199
1200 return n;
1201}
1202
1203////////////////////////////////////////////////////////////////////////////////
1204/// Read array of floats (written as truncated float) from the I/O buffer.
1205/// Returns the number of floats read.
1206/// see comments about Float16_t encoding at TBufferFile::WriteFloat16
1207
1209{
1211
1212 Int_t n;
1213 *this >> n;
1214
1215 if (n <= 0 || 3*n > fBufSize) return 0;
1216
1217 if (!f) return 0;
1218
1220
1221 return n;
1222}
1223
1224////////////////////////////////////////////////////////////////////////////////
1225/// Read array of doubles (written as float) from the I/O buffer.
1226/// Returns the number of doubles read.
1227/// see comments about Double32_t encoding at TBufferFile::WriteDouble32
1228
1230{
1232
1233 Int_t n;
1234 *this >> n;
1235
1236 if (n <= 0 || 3*n > fBufSize) return 0;
1237
1238 if (!d) return 0;
1239
1241
1242 return n;
1243}
1244
1245////////////////////////////////////////////////////////////////////////////////
1246/// Read array of n bools from the I/O buffer.
1247
1249{
1250 if (n <= 0 || n > fBufSize) return;
1251
1252 if (sizeof(Bool_t) > 1) {
1253 for (int i = 0; i < n; i++)
1254 frombuf(fBufCur, &b[i]);
1255 } else {
1256 Int_t l = sizeof(Bool_t)*n;
1257 memcpy(b, fBufCur, l);
1258 fBufCur += l;
1259 }
1260}
1261
1262////////////////////////////////////////////////////////////////////////////////
1263/// Read array of n characters from the I/O buffer.
1264
1266{
1267 if (n <= 0 || n > fBufSize) return;
1268
1269 Int_t l = sizeof(Char_t)*n;
1270 memcpy(c, fBufCur, l);
1271 fBufCur += l;
1272}
1273
1274////////////////////////////////////////////////////////////////////////////////
1275/// Read array of n characters from the I/O buffer.
1276
1278{
1279 Int_t len;
1280 UChar_t lenchar;
1281 *this >> lenchar;
1282 if (lenchar < 255) {
1283 len = lenchar;
1284 } else {
1285 *this >> len;
1286 }
1287 if (len) {
1288 if (len <= 0 || len > fBufSize) return;
1289 Int_t blen = len;
1290 if (len >= n) len = n-1;
1291
1292 Int_t l = sizeof(Char_t)*len;
1293 memcpy(c, fBufCur, l);
1294 fBufCur += blen;
1295
1296 c[len] = 0;
1297 } else {
1298 c[0] = 0;
1299 }
1300}
1301
1302////////////////////////////////////////////////////////////////////////////////
1303/// Read array of n shorts from the I/O buffer.
1304
1306{
1307 Int_t l = sizeof(Short_t)*n;
1308 if (n <= 0 || l > fBufSize) return;
1309
1310#ifdef R__BYTESWAP
1311# ifdef USE_BSWAPCPY
1312 bswapcpy16(h, fBufCur, n);
1313 fBufCur += sizeof(Short_t)*n;
1314# else
1315 for (int i = 0; i < n; i++)
1316 frombuf(fBufCur, &h[i]);
1317# endif
1318#else
1319 memcpy(h, fBufCur, l);
1320 fBufCur += l;
1321#endif
1322}
1323
1324////////////////////////////////////////////////////////////////////////////////
1325/// Read array of n ints from the I/O buffer.
1326
1328{
1329 Int_t l = sizeof(Int_t)*n;
1330 if (l <= 0 || l > fBufSize) return;
1331
1332#ifdef R__BYTESWAP
1333# ifdef USE_BSWAPCPY
1334 bswapcpy32(ii, fBufCur, n);
1335 fBufCur += sizeof(Int_t)*n;
1336# else
1337 for (int i = 0; i < n; i++)
1338 frombuf(fBufCur, &ii[i]);
1339# endif
1340#else
1341 memcpy(ii, fBufCur, l);
1342 fBufCur += l;
1343#endif
1344}
1345
1346////////////////////////////////////////////////////////////////////////////////
1347/// Read array of n longs from the I/O buffer.
1348
1350{
1351 Int_t l = sizeof(Long_t)*n;
1352 if (l <= 0 || l > fBufSize) return;
1353
1354 TFile *file = (TFile*)fParent;
1355 if (file && file->GetVersion() < 30006) {
1356 for (int i = 0; i < n; i++) frombufOld(fBufCur, &ll[i]);
1357 } else {
1358 for (int i = 0; i < n; i++) frombuf(fBufCur, &ll[i]);
1359 }
1360}
1361
1362////////////////////////////////////////////////////////////////////////////////
1363/// Read array of n long longs from the I/O buffer.
1364
1366{
1367 Int_t l = sizeof(Long64_t)*n;
1368 if (l <= 0 || l > fBufSize) return;
1369
1370#ifdef R__BYTESWAP
1371 for (int i = 0; i < n; i++)
1372 frombuf(fBufCur, &ll[i]);
1373#else
1374 memcpy(ll, fBufCur, l);
1375 fBufCur += l;
1376#endif
1377}
1378
1379////////////////////////////////////////////////////////////////////////////////
1380/// Read array of n floats from the I/O buffer.
1381
1383{
1384 Int_t l = sizeof(Float_t)*n;
1385 if (l <= 0 || l > fBufSize) return;
1386
1387#ifdef R__BYTESWAP
1388# ifdef USE_BSWAPCPY
1389 bswapcpy32(f, fBufCur, n);
1390 fBufCur += sizeof(Float_t)*n;
1391# else
1392 for (int i = 0; i < n; i++)
1393 frombuf(fBufCur, &f[i]);
1394# endif
1395#else
1396 memcpy(f, fBufCur, l);
1397 fBufCur += l;
1398#endif
1399}
1400
1401////////////////////////////////////////////////////////////////////////////////
1402/// Read array of n doubles from the I/O buffer.
1403
1405{
1406 Int_t l = sizeof(Double_t)*n;
1407 if (l <= 0 || l > fBufSize) return;
1408
1409#ifdef R__BYTESWAP
1410 for (int i = 0; i < n; i++)
1411 frombuf(fBufCur, &d[i]);
1412#else
1413 memcpy(d, fBufCur, l);
1414 fBufCur += l;
1415#endif
1416}
1417
1418////////////////////////////////////////////////////////////////////////////////
1419/// Read array of n floats (written as truncated float) from the I/O buffer.
1420/// see comments about Float16_t encoding at TBufferFile::WriteFloat16
1421
1423{
1424 if (n <= 0 || 3*n > fBufSize) return;
1425
1426 if (ele && ele->GetFactor() != 0) {
1427 //a range was specified. We read an integer and convert it back to a float
1428 Double_t xmin = ele->GetXmin();
1429 Double_t factor = ele->GetFactor();
1430 for (int j=0;j < n; j++) {
1431 UInt_t aint; *this >> aint; f[j] = (Float_t)(aint/factor + xmin);
1432 }
1433 } else {
1434 Int_t i;
1435 Int_t nbits = 0;
1436 if (ele) nbits = (Int_t)ele->GetXmin();
1437 if (!nbits) nbits = 12;
1438 //we read the exponent and the truncated mantissa of the float
1439 //and rebuild the new float.
1440 union {
1441 Float_t fFloatValue;
1442 Int_t fIntValue;
1443 };
1444 UChar_t theExp;
1445 UShort_t theMan;
1446 for (i = 0; i < n; i++) {
1447 *this >> theExp;
1448 *this >> theMan;
1449 fIntValue = theExp;
1450 fIntValue <<= 23;
1451 fIntValue |= (theMan & ((1<<(nbits+1))-1)) <<(23-nbits);
1452 if(1<<(nbits+1) & theMan) fFloatValue = -fFloatValue;
1453 f[i] = fFloatValue;
1454 }
1455 }
1456}
1457
1458////////////////////////////////////////////////////////////////////////////////
1459/// Read array of n floats (written as truncated float) from the I/O buffer.
1460/// see comments about Float16_t encoding at TBufferFile::WriteFloat16
1461
1463{
1464 if (n <= 0 || 3*n > fBufSize) return;
1465
1466 //a range was specified. We read an integer and convert it back to a float
1467 for (int j=0;j < n; j++) {
1468 UInt_t aint; *this >> aint; ptr[j] = (Float_t)(aint/factor + minvalue);
1469 }
1470}
1471
1472////////////////////////////////////////////////////////////////////////////////
1473/// Read array of n floats (written as truncated float) from the I/O buffer.
1474/// see comments about Float16_t encoding at TBufferFile::WriteFloat16
1475
1477{
1478 if (n <= 0 || 3*n > fBufSize) return;
1479
1480 if (!nbits) nbits = 12;
1481 //we read the exponent and the truncated mantissa of the float
1482 //and rebuild the new float.
1483 union {
1484 Float_t fFloatValue;
1485 Int_t fIntValue;
1486 };
1487 UChar_t theExp;
1488 UShort_t theMan;
1489 for (Int_t i = 0; i < n; i++) {
1490 *this >> theExp;
1491 *this >> theMan;
1492 fIntValue = theExp;
1493 fIntValue <<= 23;
1494 fIntValue |= (theMan & ((1<<(nbits+1))-1)) <<(23-nbits);
1495 if(1<<(nbits+1) & theMan) fFloatValue = -fFloatValue;
1496 ptr[i] = fFloatValue;
1497 }
1498}
1499
1500////////////////////////////////////////////////////////////////////////////////
1501/// Read array of n doubles (written as float) from the I/O buffer.
1502/// see comments about Double32_t encoding at TBufferFile::WriteDouble32
1503
1505{
1506 if (n <= 0 || 3*n > fBufSize) return;
1507
1508 if (ele && ele->GetFactor() != 0) {
1509 //a range was specified. We read an integer and convert it back to a double.
1510 Double_t xmin = ele->GetXmin();
1511 Double_t factor = ele->GetFactor();
1512 for (int j=0;j < n; j++) {
1513 UInt_t aint; *this >> aint; d[j] = (Double_t)(aint/factor + xmin);
1514 }
1515 } else {
1516 Int_t i;
1517 Int_t nbits = 0;
1518 if (ele) nbits = (Int_t)ele->GetXmin();
1519 if (!nbits) {
1520 //we read a float and convert it to double
1521 Float_t afloat;
1522 for (i = 0; i < n; i++) {
1523 *this >> afloat;
1524 d[i] = (Double_t)afloat;
1525 }
1526 } else {
1527 //we read the exponent and the truncated mantissa of the float
1528 //and rebuild the double.
1529 union {
1530 Float_t fFloatValue;
1531 Int_t fIntValue;
1532 };
1533 UChar_t theExp;
1534 UShort_t theMan;
1535 for (i = 0; i < n; i++) {
1536 *this >> theExp;
1537 *this >> theMan;
1538 fIntValue = theExp;
1539 fIntValue <<= 23;
1540 fIntValue |= (theMan & ((1<<(nbits+1))-1)) <<(23-nbits);
1541 if (1<<(nbits+1) & theMan) fFloatValue = -fFloatValue;
1542 d[i] = (Double_t)fFloatValue;
1543 }
1544 }
1545 }
1546}
1547
1548////////////////////////////////////////////////////////////////////////////////
1549/// Read array of n doubles (written as float) from the I/O buffer.
1550/// see comments about Double32_t encoding at TBufferFile::WriteDouble32
1551
1553{
1554 if (n <= 0 || 3*n > fBufSize) return;
1555
1556 //a range was specified. We read an integer and convert it back to a double.
1557 for (int j=0;j < n; j++) {
1558 UInt_t aint; *this >> aint; d[j] = (Double_t)(aint/factor + minvalue);
1559 }
1560}
1561
1562////////////////////////////////////////////////////////////////////////////////
1563/// Read array of n doubles (written as float) from the I/O buffer.
1564/// see comments about Double32_t encoding at TBufferFile::WriteDouble32
1565
1567{
1568 if (n <= 0 || 3*n > fBufSize) return;
1569
1570 if (!nbits) {
1571 //we read a float and convert it to double
1572 Float_t afloat;
1573 for (Int_t i = 0; i < n; i++) {
1574 *this >> afloat;
1575 d[i] = (Double_t)afloat;
1576 }
1577 } else {
1578 //we read the exponent and the truncated mantissa of the float
1579 //and rebuild the double.
1580 union {
1581 Float_t fFloatValue;
1582 Int_t fIntValue;
1583 };
1584 UChar_t theExp;
1585 UShort_t theMan;
1586 for (Int_t i = 0; i < n; i++) {
1587 *this >> theExp;
1588 *this >> theMan;
1589 fIntValue = theExp;
1590 fIntValue <<= 23;
1591 fIntValue |= (theMan & ((1<<(nbits+1))-1)) <<(23-nbits);
1592 if (1<<(nbits+1) & theMan) fFloatValue = -fFloatValue;
1593 d[i] = (Double_t)fFloatValue;
1594 }
1595 }
1596}
1597
1598////////////////////////////////////////////////////////////////////////////////
1599/// Read an array of 'n' objects from the I/O buffer.
1600/// Stores the objects read starting at the address 'start'.
1601/// The objects in the array are assume to be of class 'cl'.
1602
1603void TBufferFile::ReadFastArray(void *start, const TClass *cl, Int_t n,
1604 TMemberStreamer *streamer, const TClass* onFileClass )
1605{
1606 if (streamer) {
1607 streamer->SetOnFileClass(onFileClass);
1608 (*streamer)(*this,start,0);
1609 return;
1610 }
1611
1612 int objectSize = cl->Size();
1613 char *obj = (char*)start;
1614 char *end = obj + n*objectSize;
1615
1616 for(; obj<end; obj+=objectSize) ((TClass*)cl)->Streamer(obj,*this, onFileClass);
1617}
1618
1619////////////////////////////////////////////////////////////////////////////////
1620/// Read an array of 'n' objects from the I/O buffer.
1621///
1622/// The objects read are stored starting at the address '*start'
1623/// The objects in the array are assumed to be of class 'cl' or a derived class.
1624/// 'mode' indicates whether the data member is marked with '->'
1625
1626void TBufferFile::ReadFastArray(void **start, const TClass *cl, Int_t n,
1627 Bool_t isPreAlloc, TMemberStreamer *streamer, const TClass* onFileClass)
1628{
1629 // if isPreAlloc is true (data member has a ->) we can assume that the pointer (*start)
1630 // is never 0.
1631
1632 if (streamer) {
1633 if (isPreAlloc) {
1634 for (Int_t j=0;j<n;j++) {
1635 if (!start[j]) start[j] = cl->New();
1636 }
1637 }
1638 streamer->SetOnFileClass(onFileClass);
1639 (*streamer)(*this,(void*)start,0);
1640 return;
1641 }
1642
1643 if (!isPreAlloc) {
1644
1645 for (Int_t j=0; j<n; j++){
1646 //delete the object or collection
1647 void *old = start[j];
1648 start[j] = ReadObjectAny(cl);
1649 if (old && old!=start[j] &&
1651 // There are some cases where the user may set up a pointer in the (default)
1652 // constructor but not mark this pointer as transient. Sometime the value
1653 // of this pointer is the address of one of the object with just created
1654 // and the following delete would result in the deletion (possibly of the
1655 // top level object we are goint to return!).
1656 // Eventhough this is a user error, we could prevent the crash by simply
1657 // adding:
1658 // && !CheckObject(start[j],cl)
1659 // However this can increase the read time significantly (10% in the case
1660 // of one TLine pointer in the test/Track and run ./Event 200 0 0 20 30000
1661 //
1662 // If ReadObjectAny returned the same value as we previous had, this means
1663 // that when writing this object (start[j] had already been written and
1664 // is indeed pointing to the same object as the object the user set up
1665 // in the default constructor).
1666 ) {
1667 ((TClass*)cl)->Destructor(old,kFALSE); // call delete and desctructor
1668 }
1669 }
1670
1671 } else {
1672 //case //-> in comment
1673
1674 for (Int_t j=0; j<n; j++){
1675 if (!start[j]) start[j] = ((TClass*)cl)->New();
1676 ((TClass*)cl)->Streamer(start[j],*this,onFileClass);
1677 }
1678
1679 }
1680}
1681
1682////////////////////////////////////////////////////////////////////////////////
1683/// Write array of n bools into the I/O buffer.
1684
1686{
1688
1689 *this << n;
1690
1691 if (n <= 0) return;
1692
1693 R__ASSERT(b);
1694
1695 Int_t l = sizeof(UChar_t)*n;
1697
1698 if (sizeof(Bool_t) > 1) {
1699 for (int i = 0; i < n; i++)
1700 tobuf(fBufCur, b[i]);
1701 } else {
1702 memcpy(fBufCur, b, l);
1703 fBufCur += l;
1704 }
1705}
1706
1707////////////////////////////////////////////////////////////////////////////////
1708/// Write array of n characters into the I/O buffer.
1709
1711{
1713
1714 *this << n;
1715
1716 if (n <= 0) return;
1717
1718 R__ASSERT(c);
1719
1720 Int_t l = sizeof(Char_t)*n;
1722
1723 memcpy(fBufCur, c, l);
1724 fBufCur += l;
1725}
1726
1727////////////////////////////////////////////////////////////////////////////////
1728/// Write array of n shorts into the I/O buffer.
1729
1731{
1733
1734 *this << n;
1735
1736 if (n <= 0) return;
1737
1738 R__ASSERT(h);
1739
1740 Int_t l = sizeof(Short_t)*n;
1742
1743#ifdef R__BYTESWAP
1744# ifdef USE_BSWAPCPY
1745 bswapcpy16(fBufCur, h, n);
1746 fBufCur += l;
1747# else
1748 for (int i = 0; i < n; i++)
1749 tobuf(fBufCur, h[i]);
1750# endif
1751#else
1752 memcpy(fBufCur, h, l);
1753 fBufCur += l;
1754#endif
1755}
1756
1757////////////////////////////////////////////////////////////////////////////////
1758/// Write array of n ints into the I/O buffer.
1759
1761{
1763
1764 *this << n;
1765
1766 if (n <= 0) return;
1767
1768 R__ASSERT(ii);
1769
1770 Int_t l = sizeof(Int_t)*n;
1772
1773#ifdef R__BYTESWAP
1774# ifdef USE_BSWAPCPY
1775 bswapcpy32(fBufCur, ii, n);
1776 fBufCur += l;
1777# else
1778 for (int i = 0; i < n; i++)
1779 tobuf(fBufCur, ii[i]);
1780# endif
1781#else
1782 memcpy(fBufCur, ii, l);
1783 fBufCur += l;
1784#endif
1785}
1786
1787////////////////////////////////////////////////////////////////////////////////
1788/// Write array of n longs into the I/O buffer.
1789
1791{
1793
1794 *this << n;
1795
1796 if (n <= 0) return;
1797
1798 R__ASSERT(ll);
1799
1800 Int_t l = 8*n;
1802 for (int i = 0; i < n; i++) tobuf(fBufCur, ll[i]);
1803}
1804
1805////////////////////////////////////////////////////////////////////////////////
1806/// Write array of n unsigned longs into the I/O buffer.
1807/// This is an explicit case for unsigned longs since signed longs
1808/// have a special tobuf().
1809
1811{
1813
1814 *this << n;
1815
1816 if (n <= 0) return;
1817
1818 R__ASSERT(ll);
1819
1820 Int_t l = 8*n;
1822 for (int i = 0; i < n; i++) tobuf(fBufCur, ll[i]);
1823}
1824
1825////////////////////////////////////////////////////////////////////////////////
1826/// Write array of n long longs into the I/O buffer.
1827
1829{
1831
1832 *this << n;
1833
1834 if (n <= 0) return;
1835
1836 R__ASSERT(ll);
1837
1838 Int_t l = sizeof(Long64_t)*n;
1840
1841#ifdef R__BYTESWAP
1842 for (int i = 0; i < n; i++)
1843 tobuf(fBufCur, ll[i]);
1844#else
1845 memcpy(fBufCur, ll, l);
1846 fBufCur += l;
1847#endif
1848}
1849
1850////////////////////////////////////////////////////////////////////////////////
1851/// Write array of n floats into the I/O buffer.
1852
1854{
1856
1857 *this << n;
1858
1859 if (n <= 0) return;
1860
1861 R__ASSERT(f);
1862
1863 Int_t l = sizeof(Float_t)*n;
1865
1866#ifdef R__BYTESWAP
1867# ifdef USE_BSWAPCPY
1868 bswapcpy32(fBufCur, f, n);
1869 fBufCur += l;
1870# else
1871 for (int i = 0; i < n; i++)
1872 tobuf(fBufCur, f[i]);
1873# endif
1874#else
1875 memcpy(fBufCur, f, l);
1876 fBufCur += l;
1877#endif
1878}
1879
1880////////////////////////////////////////////////////////////////////////////////
1881/// Write array of n doubles into the I/O buffer.
1882
1884{
1886
1887 *this << n;
1888
1889 if (n <= 0) return;
1890
1891 R__ASSERT(d);
1892
1893 Int_t l = sizeof(Double_t)*n;
1895
1896#ifdef R__BYTESWAP
1897 for (int i = 0; i < n; i++)
1898 tobuf(fBufCur, d[i]);
1899#else
1900 memcpy(fBufCur, d, l);
1901 fBufCur += l;
1902#endif
1903}
1904
1905////////////////////////////////////////////////////////////////////////////////
1906/// Write array of n floats (as truncated float) into the I/O buffer.
1907/// see comments about Float16_t encoding at TBufferFile::WriteFloat16
1908
1910{
1912
1913 *this << n;
1914
1915 if (n <= 0) return;
1916
1917 R__ASSERT(f);
1918
1919 Int_t l = sizeof(Float_t)*n;
1921
1923}
1924
1925////////////////////////////////////////////////////////////////////////////////
1926/// Write array of n doubles (as float) into the I/O buffer.
1927/// see comments about Double32_t encoding at TBufferFile::WriteDouble32
1928
1930{
1932
1933 *this << n;
1934
1935 if (n <= 0) return;
1936
1937 R__ASSERT(d);
1938
1939 Int_t l = sizeof(Float_t)*n;
1941
1943}
1944
1945////////////////////////////////////////////////////////////////////////////////
1946/// Write array of n bools into the I/O buffer.
1947/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
1948
1950{
1951 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(UChar_t));
1952 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
1953 if (n < 0 || n > maxElements)
1954 {
1955 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
1956 return; // In case the user re-routes the error handler to not die when Fatal is called
1957 }
1958
1959 Int_t l = sizeof(UChar_t)*n;
1961
1962 if (sizeof(Bool_t) > 1) {
1963 for (int i = 0; i < n; i++)
1964 tobuf(fBufCur, b[i]);
1965 } else {
1966 memcpy(fBufCur, b, l);
1967 fBufCur += l;
1968 }
1969}
1970
1971////////////////////////////////////////////////////////////////////////////////
1972/// Write array of n characters into the I/O buffer.
1973/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
1974
1976{
1977 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Char_t));
1978 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
1979 if (n < 0 || n > maxElements)
1980 {
1981 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
1982 return; // In case the user re-routes the error handler to not die when Fatal is called
1983 }
1984
1985 Int_t l = sizeof(Char_t)*n;
1987
1988 memcpy(fBufCur, c, l);
1989 fBufCur += l;
1990}
1991
1992////////////////////////////////////////////////////////////////////////////////
1993/// Write array of n characters into the I/O buffer.
1994/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
1995
1997{
1998 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Char_t));
1999 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2000 if (n < 0 || n > maxElements)
2001 {
2002 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2003 return; // In case the user re-routes the error handler to not die when Fatal is called
2004 }
2005
2006 if (n < 255) {
2007 *this << (UChar_t)n;
2008 } else {
2009 *this << (UChar_t)255;
2010 *this << (Int_t)n;
2011 }
2012
2013 Int_t l = sizeof(Char_t)*n;
2015
2016 memcpy(fBufCur, c, l);
2017 fBufCur += l;
2018}
2019
2020////////////////////////////////////////////////////////////////////////////////
2021/// Write array of n shorts into the I/O buffer.
2022/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2023
2025{
2026 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Short_t));
2027 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2028 if (n < 0 || n > maxElements)
2029 {
2030 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2031 return; // In case the user re-routes the error handler to not die when Fatal is called
2032 }
2033
2034 Int_t l = sizeof(Short_t)*n;
2036
2037#ifdef R__BYTESWAP
2038# ifdef USE_BSWAPCPY
2039 bswapcpy16(fBufCur, h, n);
2040 fBufCur += l;
2041# else
2042 for (int i = 0; i < n; i++)
2043 tobuf(fBufCur, h[i]);
2044# endif
2045#else
2046 memcpy(fBufCur, h, l);
2047 fBufCur += l;
2048#endif
2049}
2050
2051////////////////////////////////////////////////////////////////////////////////
2052/// Write array of n ints into the I/O buffer.
2053/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2054
2056{
2057
2058 constexpr Int_t dataWidth = 4;
2059 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2060 if (n < 0 || n > maxElements)
2061 {
2062 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2063 return; // In case the user re-routes the error handler to not die when Fatal is called
2064 }
2065
2066 Int_t l = sizeof(Int_t)*n;
2068
2069#ifdef R__BYTESWAP
2070# ifdef USE_BSWAPCPY
2071 bswapcpy32(fBufCur, ii, n);
2072 fBufCur += l;
2073# else
2074 for (int i = 0; i < n; i++)
2075 tobuf(fBufCur, ii[i]);
2076# endif
2077#else
2078 memcpy(fBufCur, ii, l);
2079 fBufCur += l;
2080#endif
2081}
2082
2083////////////////////////////////////////////////////////////////////////////////
2084/// Write array of n longs into the I/O buffer with 8-byte width.
2085/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2086
2088{
2089 constexpr Int_t dataWidth = 8;
2090 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2091 if (n < 0 || n > maxElements)
2092 {
2093 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2094 return; // In case the user re-routes the error handler to not die when Fatal is called
2095 }
2096
2097 Int_t l = 8*n;
2099
2100 for (int i = 0; i < n; i++) tobuf(fBufCur, ll[i]);
2101}
2102
2103////////////////////////////////////////////////////////////////////////////////
2104/// Write array of n unsigned longs into the I/O buffer with 8-byte width.
2105/// This is an explicit case for unsigned longs since signed longs
2106/// have a special tobuf().
2107/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2108
2110{
2111 constexpr Int_t dataWidth = 8;
2112 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2113 if (n < 0 || n > maxElements)
2114 {
2115 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2116 return; // In case the user re-routes the error handler to not die when Fatal is called
2117 }
2118
2119 Int_t l = 8*n;
2121
2122 for (int i = 0; i < n; i++) tobuf(fBufCur, ll[i]);
2123}
2124
2125////////////////////////////////////////////////////////////////////////////////
2126/// Write array of n long longs into the I/O buffer.
2127/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2128
2130{
2131 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Long64_t));
2132 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2133 if (n < 0 || n > maxElements)
2134 {
2135 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2136 return; // In case the user re-routes the error handler to not die when Fatal is called
2137 }
2138
2139 Int_t l = sizeof(Long64_t)*n;
2141
2142#ifdef R__BYTESWAP
2143 for (int i = 0; i < n; i++)
2144 tobuf(fBufCur, ll[i]);
2145#else
2146 memcpy(fBufCur, ll, l);
2147 fBufCur += l;
2148#endif
2149}
2150
2151////////////////////////////////////////////////////////////////////////////////
2152/// Write array of n floats into the I/O buffer.
2153/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2154
2156{
2157 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Float_t));
2158 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2159 if (n < 0 || n > maxElements)
2160 {
2161 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2162 return; // In case the user re-routes the error handler to not die when Fatal is called
2163 }
2164
2165 Int_t l = sizeof(Float_t)*n;
2167
2168#ifdef R__BYTESWAP
2169# ifdef USE_BSWAPCPY
2170 bswapcpy32(fBufCur, f, n);
2171 fBufCur += l;
2172# else
2173 for (int i = 0; i < n; i++)
2174 tobuf(fBufCur, f[i]);
2175# endif
2176#else
2177 memcpy(fBufCur, f, l);
2178 fBufCur += l;
2179#endif
2180}
2181
2182////////////////////////////////////////////////////////////////////////////////
2183/// Write array of n doubles into the I/O buffer.
2184/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2185
2187{
2188 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Double_t));
2189 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2190 if (n < 0 || n > maxElements)
2191 {
2192 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2193 return; // In case the user re-routes the error handler to not die when Fatal is called
2194 }
2195
2196 Int_t l = sizeof(Double_t)*n;
2198
2199#ifdef R__BYTESWAP
2200 for (int i = 0; i < n; i++)
2201 tobuf(fBufCur, d[i]);
2202#else
2203 memcpy(fBufCur, d, l);
2204 fBufCur += l;
2205#endif
2206}
2207
2208////////////////////////////////////////////////////////////////////////////////
2209/// Write array of n floats (as truncated float) into the I/O buffer.
2210/// see comments about Float16_t encoding at TBufferFile::WriteFloat16
2211/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2212
2214{
2215 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Float_t));
2216 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2217 if (n < 0 || n > maxElements)
2218 {
2219 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2220 return; // In case the user re-routes the error handler to not die when Fatal is called
2221 }
2222
2223 Int_t l = sizeof(Float_t)*n;
2225
2226 if (ele && ele->GetFactor()) {
2227 //A range is specified. We normalize the float to the range and
2228 //convert it to an integer using a scaling factor that is a function of nbits.
2229 //see TStreamerElement::GetRange.
2230 Double_t factor = ele->GetFactor();
2231 Double_t xmin = ele->GetXmin();
2232 Double_t xmax = ele->GetXmax();
2233 for (int j = 0; j < n; j++) {
2234 Float_t x = f[j];
2235 if (x < xmin) x = xmin;
2236 if (x > xmax) x = xmax;
2237 UInt_t aint = UInt_t(0.5+factor*(x-xmin)); *this << aint;
2238 }
2239 } else {
2240 Int_t nbits = 0;
2241 //number of bits stored in fXmin (see TStreamerElement::GetRange)
2242 if (ele) nbits = (Int_t)ele->GetXmin();
2243 if (!nbits) nbits = 12;
2244 Int_t i;
2245 //a range is not specified, but nbits is.
2246 //In this case we truncate the mantissa to nbits and we stream
2247 //the exponent as a UChar_t and the mantissa as a UShort_t.
2248 union {
2249 Float_t fFloatValue;
2250 Int_t fIntValue;
2251 };
2252 for (i = 0; i < n; i++) {
2253 fFloatValue = f[i];
2254 UChar_t theExp = (UChar_t)(0x000000ff & ((fIntValue<<1)>>24));
2255 UShort_t theMan = ((1<<(nbits+1))-1) & (fIntValue>>(23-nbits-1));
2256 theMan++;
2257 theMan = theMan>>1;
2258 if (theMan&1<<nbits) theMan = (1<<nbits) - 1;
2259 if (fFloatValue < 0) theMan |= 1<<(nbits+1);
2260 *this << theExp;
2261 *this << theMan;
2262 }
2263 }
2264}
2265
2266////////////////////////////////////////////////////////////////////////////////
2267/// Write array of n doubles (as float) into the I/O buffer.
2268/// see comments about Double32_t encoding at TBufferFile::WriteDouble32
2269/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2270
2272{
2273 constexpr Int_t dataWidth = static_cast<Int_t>(sizeof(Float_t));
2274 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
2275 if (n < 0 || n > maxElements)
2276 {
2277 Fatal("WriteFastArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", n, maxElements);
2278 return; // In case the user re-routes the error handler to not die when Fatal is called
2279 }
2280
2281 Int_t l = sizeof(Float_t)*n;
2283
2284 if (ele && ele->GetFactor()) {
2285 //A range is specified. We normalize the double to the range and
2286 //convert it to an integer using a scaling factor that is a function of nbits.
2287 //see TStreamerElement::GetRange.
2288 Double_t factor = ele->GetFactor();
2289 Double_t xmin = ele->GetXmin();
2290 Double_t xmax = ele->GetXmax();
2291 for (int j = 0; j < n; j++) {
2292 Double_t x = d[j];
2293 if (x < xmin) x = xmin;
2294 if (x > xmax) x = xmax;
2295 UInt_t aint = UInt_t(0.5+factor*(x-xmin)); *this << aint;
2296 }
2297 } else {
2298 Int_t nbits = 0;
2299 //number of bits stored in fXmin (see TStreamerElement::GetRange)
2300 if (ele) nbits = (Int_t)ele->GetXmin();
2301 Int_t i;
2302 if (!nbits) {
2303 //if no range and no bits specified, we convert from double to float
2304 for (i = 0; i < n; i++) {
2305 Float_t afloat = (Float_t)d[i];
2306 *this << afloat;
2307 }
2308 } else {
2309 //a range is not specified, but nbits is.
2310 //In this case we truncate the mantissa to nbits and we stream
2311 //the exponent as a UChar_t and the mantissa as a UShort_t.
2312 union {
2313 Float_t fFloatValue;
2314 Int_t fIntValue;
2315 };
2316 for (i = 0; i < n; i++) {
2317 fFloatValue = (Float_t)d[i];
2318 UChar_t theExp = (UChar_t)(0x000000ff & ((fIntValue<<1)>>24));
2319 UShort_t theMan = ((1<<(nbits+1))-1) & (fIntValue>>(23-nbits-1));
2320 theMan++;
2321 theMan = theMan>>1;
2322 if(theMan&1<<nbits) theMan = (1<<nbits) - 1;
2323 if (fFloatValue < 0) theMan |= 1<<(nbits+1);
2324 *this << theExp;
2325 *this << theMan;
2326 }
2327 }
2328 }
2329}
2330
2331////////////////////////////////////////////////////////////////////////////////
2332/// Write an array of object starting at the address 'start' and of length 'n'
2333/// the objects in the array are assumed to be of class 'cl'
2334/// \note Due to the current limit of the buffer size, the function aborts execution of the program in case of underflow or overflow. See https://github.com/root-project/root/issues/6734 for more details.
2335
2336void TBufferFile::WriteFastArray(void *start, const TClass *cl, Long64_t n,
2337 TMemberStreamer *streamer)
2338{
2339 if (streamer) {
2340 (*streamer)(*this, start, 0);
2341 return;
2342 }
2343
2344 char *obj = (char*)start;
2345 if (!n) n=1;
2346 else if (n < 0)
2347 {
2348 Fatal("WriteFastArray", "Negative number of elements %lld", n);
2349 return; // In case the user re-routes the error handler to not die when Fatal is called
2350 }
2351 int size = cl->Size();
2352
2353 for(Int_t j=0; j<n; j++,obj+=size) {
2354 ((TClass*)cl)->Streamer(obj,*this);
2355 }
2356}
2357
2358////////////////////////////////////////////////////////////////////////////////
2359/// Write an array of object starting at the address '*start' and of length 'n'
2360/// the objects in the array are of class 'cl'
2361/// 'isPreAlloc' indicates whether the data member is marked with '->'
2362/// Return:
2363/// - 0: success
2364/// - 2: truncated success (i.e actual class is missing. Only ptrClass saved.)
2365/// - -1: underflow, operation skipped
2366
2368 Bool_t isPreAlloc, TMemberStreamer *streamer)
2369{
2370 // if isPreAlloc is true (data member has a ->) we can assume that the pointer
2371 // is never 0.
2372
2373 if (streamer) {
2374 (*streamer)(*this,(void*)start,0);
2375 return 0;
2376 }
2377 if (n < 0) return -1;
2378 int strInfo = 0;
2379
2380 Int_t res = 0;
2381
2382 if (!isPreAlloc) {
2383
2384 for (Int_t j=0;j<n;j++) {
2385 //must write StreamerInfo if pointer is null
2386 if (!strInfo && !start[j]) {
2387 if (cl->Property() & kIsAbstract) {
2388 // Do not try to generate the StreamerInfo for an abstract class
2389 } else {
2390 TStreamerInfo *info = (TStreamerInfo*)((TClass*)cl)->GetStreamerInfo();
2391 ForceWriteInfo(info,kFALSE);
2392 }
2393 }
2394 strInfo = 2003;
2395 res |= WriteObjectAny(start[j],cl);
2396 }
2397
2398 } else {
2399 //case //-> in comment
2400
2401 for (Int_t j=0;j<n;j++) {
2402 if (!start[j]) start[j] = ((TClass*)cl)->New();
2403 ((TClass*)cl)->Streamer(start[j],*this);
2404 }
2405
2406 }
2407 return res;
2408}
2409
2410////////////////////////////////////////////////////////////////////////////////
2411/// Read object from I/O buffer. clReq is NOT used.
2412///
2413/// The value returned is the address of the actual start in memory of
2414/// the object. Note that if the actual class of the object does not
2415/// inherit first from TObject, the type of the pointer is NOT 'TObject*'.
2416/// [More accurately, the class needs to start with the TObject part, for
2417/// the pointer to be a real TObject*].
2418/// We recommend using ReadObjectAny instead of ReadObject
2419
2421{
2422 return (TObject*) ReadObjectAny(nullptr);
2423}
2424
2425////////////////////////////////////////////////////////////////////////////////
2426/// Skip any kind of object from buffer
2427
2429{
2430 UInt_t start, count;
2431 ReadVersion(&start, &count);
2432 SetBufferOffset(start+count+sizeof(UInt_t));
2433}
2434
2435////////////////////////////////////////////////////////////////////////////////
2436/// Read object from I/O buffer.
2437///
2438/// A typical use for this function is:
2439///
2440/// MyClass *ptr = (MyClass*)b.ReadObjectAny(MyClass::Class());
2441///
2442/// I.e. clCast should point to a TClass object describing the class pointed
2443/// to by your pointer.
2444/// In case of multiple inheritance, the return value might not be the
2445/// real beginning of the object in memory. You will need to use a
2446/// dynamic_cast later if you need to retrieve it.
2447
2449{
2451
2452 // make sure fMap is initialized
2453 InitMap();
2454
2455 // before reading object save start position
2456 UInt_t startpos = UInt_t(fBufCur-fBuffer);
2457
2458 // attempt to load next object as TClass clCast
2459 UInt_t tag; // either tag or byte count
2460 TClass *clRef = ReadClass(clCast, &tag);
2461 TClass *clOnfile = nullptr;
2462 Int_t baseOffset = 0;
2463 if (clRef && (clRef!=(TClass*)(-1)) && clCast) {
2464 //baseOffset will be -1 if clRef does not inherit from clCast.
2465 baseOffset = clRef->GetBaseClassOffset(clCast);
2466 if (baseOffset == -1) {
2467 // The 2 classes are unrelated, maybe there is a converter between the 2.
2468
2469 if (!clCast->GetSchemaRules() ||
2470 !clCast->GetSchemaRules()->HasRuleWithSourceClass(clRef->GetName()))
2471 {
2472 // There is no converter
2473 Error("ReadObject", "got object of wrong class! requested %s but got %s",
2474 clCast->GetName(), clRef->GetName());
2475
2476 CheckByteCount(startpos, tag, (TClass *)nullptr); // avoid mis-leading byte count error message
2477 return 0; // We better return at this point
2478 }
2479 baseOffset = 0; // For now we do not support requesting from a class that is the base of one of the class for which there is transformation to ....
2480
2481 if (gDebug > 0)
2482 Info("ReadObjectAny","Using Converter StreamerInfo from %s to %s",clRef->GetName(),clCast->GetName());
2483 clOnfile = clRef;
2484 clRef = const_cast<TClass*>(clCast);
2485
2486 }
2487 if (clCast->GetState() > TClass::kEmulated && clRef->GetState() <= TClass::kEmulated) {
2488 //we cannot mix a compiled class with an emulated class in the inheritance
2489 Error("ReadObject", "trying to read an emulated class (%s) to store in a compiled pointer (%s)",
2490 clRef->GetName(),clCast->GetName());
2491 CheckByteCount(startpos, tag, (TClass *)nullptr); // avoid mis-leading byte count error message
2492 return 0;
2493 }
2494 }
2495
2496 // check if object has not already been read
2497 // (this can only happen when called via CheckObject())
2498 char *obj;
2499 if (fVersion > 0) {
2500 obj = (char *) (Longptr_t)fMap->GetValue(startpos+kMapOffset);
2501 if (obj == (void*) -1) obj = nullptr;
2502 if (obj) {
2503 CheckByteCount(startpos, tag, (TClass *)nullptr);
2504 return (obj + baseOffset);
2505 }
2506 }
2507
2508 // unknown class, skip to next object and return 0 obj
2509 if (clRef == (TClass*) -1) {
2510 if (fBufCur >= fBufMax) return 0;
2511 if (fVersion > 0)
2512 MapObject((TObject*) -1, startpos+kMapOffset);
2513 else
2514 MapObject((void*)nullptr, nullptr, fMapCount);
2515 CheckByteCount(startpos, tag, (TClass *)nullptr);
2516 return 0;
2517 }
2518
2519 if (!clRef) {
2520
2521 // got a reference to an already read object
2522 if (fVersion > 0) {
2523 tag += fDisplacement;
2524 tag = CheckObject(tag, clCast);
2525 } else {
2526 if (tag > (UInt_t)fMap->GetSize()) {
2527 Error("ReadObject", "object tag too large, I/O buffer corrupted");
2528 return 0;
2529 // exception
2530 }
2531 }
2532 obj = (char *) (Longptr_t)fMap->GetValue(tag);
2533 clRef = (TClass*) (Longptr_t)fClassMap->GetValue(tag);
2534
2535 if (clRef && (clRef!=(TClass*)(-1)) && clCast) {
2536 //baseOffset will be -1 if clRef does not inherit from clCast.
2537 baseOffset = clRef->GetBaseClassOffset(clCast);
2538 if (baseOffset == -1) {
2539 Error("ReadObject", "Got object of wrong class (Got %s while expecting %s)",
2540 clRef->GetName(),clCast->GetName());
2541 // exception
2542 baseOffset = 0;
2543 }
2544 }
2545
2546 // There used to be a warning printed here when:
2547 // obj && isTObject && !((TObject*)obj)->IsA()->InheritsFrom(clReq)
2548 // however isTObject was based on clReq (now clCast).
2549 // If the test was to fail, then it is as likely that the object is not a TObject
2550 // and then we have a potential core dump.
2551 // At this point (missing clRef), we do NOT have enough information to really
2552 // answer the question: is the object read of the type I requested.
2553
2554 } else {
2555
2556 // allocate a new object based on the class found
2557 obj = (char*)clRef->New();
2558 if (!obj) {
2559 Error("ReadObject", "could not create object of class %s",
2560 clRef->GetName());
2561 // exception
2562 return 0;
2563 }
2564
2565 // add to fMap before reading rest of object
2566 if (fVersion > 0)
2567 MapObject(obj, clRef, startpos+kMapOffset);
2568 else
2569 MapObject(obj, clRef, fMapCount);
2570
2571 // let the object read itself
2572 clRef->Streamer( obj, *this, clOnfile );
2573
2574 CheckByteCount(startpos, tag, clRef);
2575 }
2576
2577 return obj+baseOffset;
2578}
2579
2580////////////////////////////////////////////////////////////////////////////////
2581/// Write object to I/O buffer.
2582/// This function assumes that the value of 'actualObjectStart' is the actual start of
2583/// the object of class 'actualClass'
2584/// If 'cacheReuse' is true (default) upon seeing an object address a second time,
2585/// we record the offset where its was written the first time rather than streaming
2586/// the object a second time.
2587/// If 'cacheReuse' is false, we always stream the object. This allows the (re)use
2588/// of temporary object to store different data in the same buffer.
2589
2590void TBufferFile::WriteObjectClass(const void *actualObjectStart, const TClass *actualClass, Bool_t cacheReuse)
2591{
2593
2594 if (!actualObjectStart) {
2595
2596 // save kNullTag to represent NULL pointer
2597 *this << (UInt_t) kNullTag;
2598
2599 } else {
2600
2601 // make sure fMap is initialized
2602 InitMap();
2603
2604 ULongptr_t idx;
2605 UInt_t slot;
2606 ULong_t hash = Void_Hash(actualObjectStart);
2607
2608 if ((idx = (ULongptr_t)fMap->GetValue(hash, (Longptr_t)actualObjectStart, slot)) != 0) {
2609
2610 // truncation is OK the value we did put in the map is an 30-bit offset
2611 // and not a pointer
2612 UInt_t objIdx = UInt_t(idx);
2613
2614 // save index of already stored object
2615 *this << objIdx;
2616
2617 } else {
2618
2619 // A warning to let the user know it will need to change the class code
2620 // to be able to read this back.
2621 if (!actualClass->HasDefaultConstructor(kTRUE)) {
2622 Warning("WriteObjectAny", "since %s has no public constructor\n"
2623 "\twhich can be called without argument, objects of this class\n"
2624 "\tcan not be read with the current library. You will need to\n"
2625 "\tadd a default constructor before attempting to read it.",
2626 actualClass->GetName());
2627 }
2628
2629 // reserve space for leading byte count
2630 UInt_t cntpos = UInt_t(fBufCur-fBuffer);
2631 fBufCur += sizeof(UInt_t);
2632
2633 // write class of object first
2634 Int_t mapsize = fMap->Capacity(); // The slot depends on the capacity and WriteClass might induce an increase.
2635 WriteClass(actualClass);
2636
2637 if (cacheReuse) {
2638 // add to map before writing rest of object (to handle self reference)
2639 // (+kMapOffset so it's != kNullTag)
2640 //MapObject(actualObjectStart, actualClass, cntpos+kMapOffset);
2641 UInt_t offset = cntpos+kMapOffset;
2642 if (mapsize == fMap->Capacity()) {
2643 fMap->AddAt(slot, hash, (Longptr_t)actualObjectStart, offset);
2644 } else {
2645 // The slot depends on the capacity and WriteClass has induced an increase.
2646 fMap->Add(hash, (Longptr_t)actualObjectStart, offset);
2647 }
2648 // No need to keep track of the class in write mode
2649 // fClassMap->Add(hash, (Long_t)obj, (Long_t)((TObject*)obj)->IsA());
2650 fMapCount++;
2651 }
2652
2653 ((TClass*)actualClass)->Streamer((void*)actualObjectStart,*this);
2654
2655 // write byte count
2656 SetByteCount(cntpos);
2657 }
2658 }
2659}
2660
2661////////////////////////////////////////////////////////////////////////////////
2662/// Read class definition from I/O buffer.
2663///
2664/// \param[in] clReq Can be used to cross check if the actually read object is of the requested class.
2665/// \param[in] objTag Set in case the object is a reference to an already read object.
2666
2668{
2670
2671 // read byte count and/or tag (older files don't have byte count)
2672 TClass *cl;
2673 if (fBufCur < fBuffer || fBufCur > fBufMax) {
2674 fBufCur = fBufMax;
2675 cl = (TClass*)-1;
2676 return cl;
2677 }
2678 UInt_t bcnt, tag, startpos = 0;
2679 *this >> bcnt;
2680 if (!(bcnt & kByteCountMask) || bcnt == kNewClassTag) {
2681 tag = bcnt;
2682 bcnt = 0;
2683 } else {
2684 fVersion = 1;
2685 startpos = UInt_t(fBufCur-fBuffer);
2686 *this >> tag;
2687 }
2688
2689 // in case tag is object tag return tag
2690 if (!(tag & kClassMask)) {
2691 if (objTag) *objTag = tag;
2692 return 0;
2693 }
2694
2695 if (tag == kNewClassTag) {
2696
2697 // got a new class description followed by a new object
2698 // (class can be 0 if class dictionary is not found, in that
2699 // case object of this class must be skipped)
2700 cl = TClass::Load(*this);
2701
2702 // add class to fMap for later reference
2703 if (fVersion > 0) {
2704 // check if class was already read
2705 TClass *cl1 = (TClass *)(Longptr_t)fMap->GetValue(startpos+kMapOffset);
2706 if (cl1 != cl)
2707 MapObject(cl ? cl : (TObject*) -1, startpos+kMapOffset);
2708 } else
2709 MapObject(cl, fMapCount);
2710
2711 } else {
2712
2713 // got a tag to an already seen class
2714 UInt_t clTag = (tag & ~kClassMask);
2715
2716 if (fVersion > 0) {
2717 clTag += fDisplacement;
2718 clTag = CheckObject(clTag, clReq, kTRUE);
2719 } else {
2720 if (clTag == 0 || clTag > (UInt_t)fMap->GetSize()) {
2721 Error("ReadClass", "illegal class tag=%d (0<tag<=%d), I/O buffer corrupted",
2722 clTag, fMap->GetSize());
2723 // exception
2724 }
2725 }
2726
2727 // class can be 0 if dictionary was not found
2728 cl = (TClass *)(Longptr_t)fMap->GetValue(clTag);
2729 }
2730
2731 if (cl && clReq &&
2732 (!cl->InheritsFrom(clReq) &&
2733 !(clReq->GetSchemaRules() &&
2735 ) ) {
2736 Error("ReadClass", "The on-file class is \"%s\" which is not compatible with the requested class: \"%s\"",
2737 cl->GetName(), clReq->GetName());
2738 // exception
2739 }
2740
2741 // return bytecount in objTag
2742 if (objTag) *objTag = (bcnt & ~kByteCountMask);
2743
2744 // case of unknown class
2745 if (!cl) cl = (TClass*)-1;
2746
2747 return cl;
2748}
2749
2750////////////////////////////////////////////////////////////////////////////////
2751/// Write class description to I/O buffer.
2752
2754{
2756
2757 ULongptr_t idx;
2758 ULong_t hash = Void_Hash(cl);
2759 UInt_t slot;
2760
2761 if ((idx = (ULongptr_t)fMap->GetValue(hash, (Longptr_t)cl,slot)) != 0) {
2762
2763 // truncation is OK the value we did put in the map is an 30-bit offset
2764 // and not a pointer
2765 UInt_t clIdx = UInt_t(idx);
2766
2767 // save index of already stored class
2768 *this << (clIdx | kClassMask);
2769
2770 } else {
2771
2772 // offset in buffer where class info is written
2774
2775 // save new class tag
2776 *this << kNewClassTag;
2777
2778 // write class name
2779 cl->Store(*this);
2780
2781 // store new class reference in fMap (+kMapOffset so it's != kNullTag)
2783 fMap->AddAt(slot, hash, (Longptr_t)cl, offset+kMapOffset);
2784 fMapCount++;
2785 }
2786}
2787
2788////////////////////////////////////////////////////////////////////////////////
2789/// Skip class version from I/O buffer.
2790
2792{
2793 Version_t version;
2794
2795 // not interested in byte count
2796 frombuf(this->fBufCur,&version);
2797
2798 // if this is a byte count, then skip next short and read version
2799 if (version & kByteCountVMask) {
2800 frombuf(this->fBufCur,&version);
2801 frombuf(this->fBufCur,&version);
2802 }
2803
2804 if (cl && cl->GetClassVersion() != 0 && version<=1) {
2805 if (version <= 0) {
2806 UInt_t checksum = 0;
2807 //*this >> checksum;
2808 frombuf(this->fBufCur,&checksum);
2809 TStreamerInfo *vinfo = (TStreamerInfo*)cl->FindStreamerInfo(checksum);
2810 if (vinfo) {
2811 return;
2812 } else {
2813 // There are some cases (for example when the buffer was stored outside of
2814 // a ROOT file) where we do not have a TStreamerInfo. If the checksum is
2815 // the one from the current class, we can still assume that we can read
2816 // the data so let use it.
2817 if (checksum==cl->GetCheckSum() || cl->MatchLegacyCheckSum(checksum)) {
2818 version = cl->GetClassVersion();
2819 } else {
2820 if (fParent) {
2821 Error("SkipVersion", "Could not find the StreamerInfo with a checksum of %d for the class \"%s\" in %s.",
2822 checksum, cl->GetName(), ((TFile*)fParent)->GetName());
2823 } else {
2824 Error("SkipVersion", "Could not find the StreamerInfo with a checksum of %d for the class \"%s\" (buffer with no parent)",
2825 checksum, cl->GetName());
2826 }
2827 return;
2828 }
2829 }
2830 } else if (version == 1 && fParent && ((TFile*)fParent)->GetVersion()<40000 ) {
2831 // We could have a file created using a Foreign class before
2832 // the introduction of the CheckSum. We need to check
2833 if ((!cl->IsLoaded() || cl->IsForeign()) &&
2835
2836 const TList *list = ((TFile*)fParent)->GetStreamerInfoCache();
2837 const TStreamerInfo *local = list ? (TStreamerInfo*)list->FindObject(cl->GetName()) : 0;
2838 if ( local ) {
2839 UInt_t checksum = local->GetCheckSum();
2840 TStreamerInfo *vinfo = (TStreamerInfo*)cl->FindStreamerInfo(checksum);
2841 if (vinfo) {
2842 version = vinfo->GetClassVersion();
2843 } else {
2844 Error("SkipVersion", "Could not find the StreamerInfo with a checksum of %d for the class \"%s\" in %s.",
2845 checksum, cl->GetName(), ((TFile*)fParent)->GetName());
2846 return;
2847 }
2848 }
2849 else {
2850 Error("SkipVersion", "Class %s not known to file %s.",
2851 cl->GetName(), ((TFile*)fParent)->GetName());
2852 version = 0;
2853 }
2854 }
2855 }
2856 }
2857}
2858
2859////////////////////////////////////////////////////////////////////////////////
2860/// Read class version from I/O buffer.
2861
2863{
2864 Version_t version;
2865
2866 if (startpos) {
2867 // before reading object save start position
2868 *startpos = UInt_t(fBufCur-fBuffer);
2869 }
2870
2871 // read byte count (older files don't have byte count)
2872 // byte count is packed in two individual shorts, this to be
2873 // backward compatible with old files that have at this location
2874 // only a single short (i.e. the version)
2875 union {
2876 UInt_t cnt;
2877 Version_t vers[2];
2878 } v;
2879#ifdef R__BYTESWAP
2880 frombuf(this->fBufCur,&v.vers[1]);
2881 frombuf(this->fBufCur,&v.vers[0]);
2882#else
2883 frombuf(this->fBufCur,&v.vers[0]);
2884 frombuf(this->fBufCur,&v.vers[1]);
2885#endif
2886
2887 // no bytecount, backup and read version
2888 if (!(v.cnt & kByteCountMask)) {
2889 fBufCur -= sizeof(UInt_t);
2890 v.cnt = 0;
2891 }
2892 if (bcnt) *bcnt = (v.cnt & ~kByteCountMask);
2893 frombuf(this->fBufCur,&version);
2894
2895 if (version<=1) {
2896 if (version <= 0) {
2897 if (cl) {
2898 if (cl->GetClassVersion() != 0
2899 // If v.cnt < 6 then we have a class with a version that used to be zero and so there is no checksum.
2900 && (v.cnt && v.cnt >= 6)
2901 ) {
2902 UInt_t checksum = 0;
2903 //*this >> checksum;
2904 frombuf(this->fBufCur,&checksum);
2905 TStreamerInfo *vinfo = (TStreamerInfo*)cl->FindStreamerInfo(checksum);
2906 if (vinfo) {
2907 return vinfo->TStreamerInfo::GetClassVersion(); // Try to get inlining.
2908 } else {
2909 // There are some cases (for example when the buffer was stored outside of
2910 // a ROOT file) where we do not have a TStreamerInfo. If the checksum is
2911 // the one from the current class, we can still assume that we can read
2912 // the data so let use it.
2913 if (checksum==cl->GetCheckSum() || cl->MatchLegacyCheckSum(checksum)) {
2914 version = cl->GetClassVersion();
2915 } else {
2916 if (fParent) {
2917 Error("ReadVersion", "Could not find the StreamerInfo with a checksum of 0x%x for the class \"%s\" in %s.",
2918 checksum, cl->GetName(), ((TFile*)fParent)->GetName());
2919 } else {
2920 Error("ReadVersion", "Could not find the StreamerInfo with a checksum of 0x%x for the class \"%s\" (buffer with no parent)",
2921 checksum, cl->GetName());
2922 }
2923 return 0;
2924 }
2925 }
2926 }
2927 } else { // of if (cl) {
2928 UInt_t checksum = 0;
2929 //*this >> checksum;
2930 // If *bcnt < 6 then we have a class with 'just' version zero and no checksum
2931 if (v.cnt && v.cnt >= 6)
2932 frombuf(this->fBufCur,&checksum);
2933 }
2934 } else if (version == 1 && fParent && ((TFile*)fParent)->GetVersion()<40000 && cl && cl->GetClassVersion() != 0) {
2935 // We could have a file created using a Foreign class before
2936 // the introduction of the CheckSum. We need to check
2937 if ((!cl->IsLoaded() || cl->IsForeign()) &&
2939
2940 const TList *list = ((TFile*)fParent)->GetStreamerInfoCache();
2941 const TStreamerInfo *local = list ? (TStreamerInfo*)list->FindObject(cl->GetName()) : 0;
2942 if ( local ) {
2943 UInt_t checksum = local->GetCheckSum();
2944 TStreamerInfo *vinfo = (TStreamerInfo*)cl->FindStreamerInfo(checksum);
2945 if (vinfo) {
2946 version = vinfo->GetClassVersion();
2947 } else {
2948 Error("ReadVersion", "Could not find the StreamerInfo with a checksum of 0x%x for the class \"%s\" in %s.",
2949 checksum, cl->GetName(), ((TFile*)fParent)->GetName());
2950 return 0;
2951 }
2952 }
2953 else {
2954 Error("ReadVersion", "Class %s not known to file %s.",
2955 cl->GetName(), ((TFile*)fParent)->GetName());
2956 version = 0;
2957 }
2958 }
2959 }
2960 }
2961 return version;
2962}
2963
2964////////////////////////////////////////////////////////////////////////////////
2965/// Read class version from I/O buffer, when the caller knows for sure that
2966/// there is no checksum written/involved.
2967
2969{
2970 Version_t version;
2971
2972 if (startpos) {
2973 // before reading object save start position
2974 *startpos = UInt_t(fBufCur-fBuffer);
2975 }
2976
2977 // read byte count (older files don't have byte count)
2978 // byte count is packed in two individual shorts, this to be
2979 // backward compatible with old files that have at this location
2980 // only a single short (i.e. the version)
2981 union {
2982 UInt_t cnt;
2983 Version_t vers[2];
2984 } v;
2985#ifdef R__BYTESWAP
2986 frombuf(this->fBufCur,&v.vers[1]);
2987 frombuf(this->fBufCur,&v.vers[0]);
2988#else
2989 frombuf(this->fBufCur,&v.vers[0]);
2990 frombuf(this->fBufCur,&v.vers[1]);
2991#endif
2992
2993 // no bytecount, backup and read version
2994 if (!(v.cnt & kByteCountMask)) {
2995 fBufCur -= sizeof(UInt_t);
2996 v.cnt = 0;
2997 }
2998 if (bcnt) *bcnt = (v.cnt & ~kByteCountMask);
2999 frombuf(this->fBufCur,&version);
3000
3001 return version;
3002}
3003
3004////////////////////////////////////////////////////////////////////////////////
3005/// Read class version from I/O buffer
3006///
3007/// To be used when streaming out member-wise streamed collection where we do not
3008/// care (not save) about the byte count and can safely ignore missing streamerInfo
3009/// (since they usually indicate empty collections).
3010
3012{
3013 Version_t version;
3014
3015 // not interested in byte count
3016 frombuf(this->fBufCur,&version);
3017
3018 if (version<=1) {
3019 if (version <= 0) {
3020 if (cl) {
3021 if (cl->GetClassVersion() != 0) {
3022 UInt_t checksum = 0;
3023 frombuf(this->fBufCur,&checksum);
3024 TStreamerInfo *vinfo = (TStreamerInfo*)cl->FindStreamerInfo(checksum);
3025 if (vinfo) {
3026 return vinfo->TStreamerInfo::GetClassVersion(); // Try to get inlining.
3027 } else {
3028 // There are some cases (for example when the buffer was stored outside of
3029 // a ROOT file) where we do not have a TStreamerInfo. If the checksum is
3030 // the one from the current class, we can still assume that we can read
3031 // the data so let use it.
3032 if (checksum==cl->GetCheckSum() || cl->MatchLegacyCheckSum(checksum)) {
3033 version = cl->GetClassVersion();
3034 } else {
3035 // If we can not find the streamerInfo this means that
3036 // we do not actually need it (the collection is always empty
3037 // in this file), so no need to issue a warning.
3038 return 0;
3039 }
3040 }
3041 }
3042 } else { // of if (cl) {
3043 UInt_t checksum = 0;
3044 frombuf(this->fBufCur,&checksum);
3045 }
3046 } else if (version == 1 && fParent && ((TFile*)fParent)->GetVersion()<40000 && cl && cl->GetClassVersion() != 0) {
3047 // We could have a file created using a Foreign class before
3048 // the introduction of the CheckSum. We need to check
3049 if ((!cl->IsLoaded() || cl->IsForeign()) && Class_Has_StreamerInfo(cl) ) {
3050
3051 const TList *list = ((TFile*)fParent)->GetStreamerInfoCache();
3052 const TStreamerInfo *local = list ? (TStreamerInfo*)list->FindObject(cl->GetName()) : 0;
3053 if ( local ) {
3054 UInt_t checksum = local->GetCheckSum();
3055 TStreamerInfo *vinfo = (TStreamerInfo*)cl->FindStreamerInfo(checksum);
3056 if (vinfo) {
3057 version = vinfo->GetClassVersion();
3058 } else {
3059 // If we can not find the streamerInfo this means that
3060 // we do not actually need it (the collection is always empty
3061 // in this file), so no need to issue a warning.
3062 return 0;
3063 }
3064 }
3065 else {
3066 Error("ReadVersion", "Class %s not known to file %s.",
3067 cl->GetName(), ((TFile*)fParent)->GetName());
3068 version = 0;
3069 }
3070 }
3071 }
3072 }
3073 return version;
3074}
3075
3076////////////////////////////////////////////////////////////////////////////////
3077/// Write class version to I/O buffer.
3078
3080{
3081 UInt_t cntpos = 0;
3082 if (useBcnt) {
3083 // reserve space for leading byte count
3084 cntpos = UInt_t(fBufCur-fBuffer);
3085 fBufCur += sizeof(UInt_t);
3086 }
3087
3088 Version_t version = cl->GetClassVersion();
3089 if (version<=1 && cl->IsForeign()) {
3090 *this << Version_t(0);
3091 *this << cl->GetCheckSum();
3092 } else {
3093 if (version > kMaxVersion) {
3094 Error("WriteVersion", "version number cannot be larger than %hd)",
3095 kMaxVersion);
3096 version = kMaxVersion;
3097 }
3098 *this <<version;
3099 }
3100
3101 // return position where to store possible byte count
3102 return cntpos;
3103}
3104
3105////////////////////////////////////////////////////////////////////////////////
3106/// Write class version to I/O buffer after setting the kStreamedMemberWise
3107/// bit in the version number.
3108
3110{
3111 UInt_t cntpos = 0;
3112 if (useBcnt) {
3113 // reserve space for leading byte count
3114 cntpos = UInt_t(fBufCur-fBuffer);
3115 fBufCur += sizeof(UInt_t);
3116 }
3117
3118 Version_t version = cl->GetClassVersion();
3119 if (version<=1 && cl->IsForeign()) {
3120 Error("WriteVersionMemberWise", "Member-wise streaming of foreign collection not yet implemented!");
3121 *this << Version_t(0);
3122 *this << cl->GetCheckSum();
3123 } else {
3124 if (version > kMaxVersion) {
3125 Error("WriteVersionMemberWise", "version number cannot be larger than %hd)",
3126 kMaxVersion);
3127 version = kMaxVersion;
3128 }
3129 version |= kStreamedMemberWise;
3130 *this <<version;
3131 }
3132
3133 // return position where to store possible byte count
3134 return cntpos;
3135}
3136
3137////////////////////////////////////////////////////////////////////////////////
3138/// Stream an object given its C++ typeinfo information.
3139
3140void TBufferFile::StreamObject(void *obj, const std::type_info &typeinfo, const TClass* onFileClass )
3141{
3142 TClass *cl = TClass::GetClass(typeinfo);
3143 if (cl) cl->Streamer(obj, *this, (TClass*)onFileClass );
3144 else Warning("StreamObject","No TClass for the type %s is available, the object was not read.", typeinfo.name());
3145}
3146
3147////////////////////////////////////////////////////////////////////////////////
3148/// Stream an object given the name of its actual class.
3149
3150void TBufferFile::StreamObject(void *obj, const char *className, const TClass* onFileClass)
3151{
3152 TClass *cl = TClass::GetClass(className);
3153 if (cl) cl->Streamer(obj, *this, (TClass*)onFileClass );
3154 else Warning("StreamObject","No TClass for the type %s is available, the object was not read.", className);
3155}
3156
3157////////////////////////////////////////////////////////////////////////////////
3158/// Stream an object given a pointer to its actual class.
3159
3160void TBufferFile::StreamObject(void *obj, const TClass *cl, const TClass* onFileClass )
3161{
3162 ((TClass*)cl)->Streamer(obj, *this, (TClass*)onFileClass );
3163}
3164
3165////////////////////////////////////////////////////////////////////////////////
3166/// Stream an object inheriting from TObject using its streamer.
3167
3169{
3170 obj->Streamer(*this);
3171}
3172
3173////////////////////////////////////////////////////////////////////////////////
3174/// Check if offset is not too large (< kMaxMapCount) when writing.
3175
3177{
3178 if (IsWriting()) {
3179 if (offset >= kMaxMapCount) {
3180 Error("CheckCount", "buffer offset too large (larger than %d)", kMaxMapCount);
3181 // exception
3182 }
3183 }
3184}
3185
3186////////////////////////////////////////////////////////////////////////////////
3187/// Check for object in the read map. If the object is 0 it still has to be
3188/// read. Try to read it from the buffer starting at location offset. If the
3189/// object is -1 then it really does not exist and we return 0. If the object
3190/// exists just return the offset.
3191
3193{
3194 // in position 0 we always have the reference to the null object
3195 if (!offset) return offset;
3196
3197 Longptr_t cli;
3198
3199 if (readClass) {
3200 if ((cli = fMap->GetValue(offset)) == 0) {
3201 // No class found at this location in map. It might have been skipped
3202 // as part of a skipped object. Try to explicitly read the class.
3203
3204 // save fBufCur and set to place specified by offset (-kMapOffset-sizeof(bytecount))
3205 char *bufsav = fBufCur;
3206 fBufCur = (char *)(fBuffer + offset-kMapOffset-sizeof(UInt_t));
3207
3208 TClass *c = ReadClass(cl);
3209 if (c == (TClass*) -1) {
3210 // mark class as really not available
3211 fMap->Remove(offset);
3212 fMap->Add(offset, -1);
3213 offset = 0;
3214 if (cl)
3215 Warning("CheckObject", "reference to unavailable class %s,"
3216 " pointers of this type will be 0", cl->GetName());
3217 else
3218 Warning("CheckObject", "reference to an unavailable class,"
3219 " pointers of that type will be 0");
3220 }
3221
3222 fBufCur = bufsav;
3223
3224 } else if (cli == -1) {
3225
3226 // class really does not exist
3227 return 0;
3228 }
3229
3230 } else {
3231
3232 if ((cli = fMap->GetValue(offset)) == 0) {
3233 // No object found at this location in map. It might have been skipped
3234 // as part of a skipped object. Try to explicitly read the object.
3235
3236 // save fBufCur and set to place specified by offset (-kMapOffset)
3237 char *bufsav = fBufCur;
3238 fBufCur = (char *)(fBuffer + offset-kMapOffset);
3239
3240 TObject *obj = ReadObject(cl);
3241 if (!obj) {
3242 // mark object as really not available
3243 fMap->Remove(offset);
3244 fMap->Add(offset, -1);
3245 Warning("CheckObject", "reference to object of unavailable class %s, offset=%d"
3246 " pointer will be 0", cl ? cl->GetName() : "TObject",offset);
3247 offset = 0;
3248 }
3249
3250 fBufCur = bufsav;
3251
3252 } else if (cli == -1) {
3253
3254 // object really does not exist
3255 return 0;
3256 }
3257
3258 }
3259
3260 return offset;
3261}
3262
3263
3264////////////////////////////////////////////////////////////////////////////////
3265/// Read max bytes from the I/O buffer into buf. The function returns
3266/// the actual number of bytes read.
3267
3269{
3271
3272 if (max == 0) return 0;
3273
3274 Int_t n = TMath::Min(max, (Int_t)(fBufMax - fBufCur));
3275
3276 memcpy(buf, fBufCur, n);
3277 fBufCur += n;
3278
3279 return n;
3280}
3281
3282////////////////////////////////////////////////////////////////////////////////
3283/// Write max bytes from buf into the I/O buffer.
3284
3285void TBufferFile::WriteBuf(const void *buf, Int_t max)
3286{
3288
3289 if (max == 0) return;
3290
3291 if (fBufCur + max > fBufMax) AutoExpand(fBufSize+max); // a more precise request would be: fBufSize + max - (fBufMax - fBufCur)
3292
3293 memcpy(fBufCur, buf, max);
3294 fBufCur += max;
3295}
3296
3297////////////////////////////////////////////////////////////////////////////////
3298/// Read string from I/O buffer. String is read till 0 character is
3299/// found or till max-1 characters are read (i.e. string s has max
3300/// bytes allocated). If max = -1 no check on number of character is
3301/// made, reading continues till 0 character is found.
3302
3304{
3306
3307 char ch;
3308 Int_t nr = 0;
3309
3310 if (max == -1) max = kMaxInt;
3311
3312 while (nr < max-1) {
3313
3314 *this >> ch;
3315
3316 // stop when 0 read
3317 if (ch == 0) break;
3318
3319 s[nr++] = ch;
3320 }
3321
3322 s[nr] = 0;
3323 return s;
3324}
3325
3326////////////////////////////////////////////////////////////////////////////////
3327/// Write string to I/O buffer. Writes string upto and including the
3328/// terminating 0.
3329
3330void TBufferFile::WriteString(const char *s)
3331{
3332 WriteBuf(s, (strlen(s)+1)*sizeof(char));
3333}
3334
3335////////////////////////////////////////////////////////////////////////////////
3336/// Read emulated class.
3337
3338Int_t TBufferFile::ReadClassEmulated(const TClass *cl, void *object, const TClass *onFileClass)
3339{
3340 UInt_t start,count;
3341 //We assume that the class was written with a standard streamer
3342 //We attempt to recover if a version count was not written
3343 Version_t v = ReadVersion(&start,&count);
3344
3345 if (count) {
3346 TStreamerInfo *sinfo = nullptr;
3347 if( onFileClass ) {
3348 sinfo = (TStreamerInfo*)cl->GetConversionStreamerInfo( onFileClass, v );
3349 if( !sinfo )
3350 return 0;
3351 }
3352
3353 sinfo = (TStreamerInfo*)cl->GetStreamerInfo(v);
3354 ApplySequence(*(sinfo->GetReadObjectWiseActions()), object);
3355 if (sinfo->IsRecovered()) count=0;
3356 CheckByteCount(start,count,cl);
3357 } else {
3358 SetBufferOffset(start);
3359 TStreamerInfo *sinfo = ((TStreamerInfo*)cl->GetStreamerInfo());
3360 ApplySequence(*(sinfo->GetReadObjectWiseActions()), object);
3361 }
3362 return 0;
3363}
3364
3365////////////////////////////////////////////////////////////////////////////////
3366/// Deserialize information from a buffer into an object.
3367///
3368/// Note: This function is called by the xxx::Streamer() functions in
3369/// rootcint-generated dictionaries.
3370/// This function assumes that the class version and the byte count
3371/// information have been read.
3372///
3373/// \param[in] cl pointer to the local TClass
3374/// \param[out] pointer void pointer to object
3375/// \param[in] version The version number of the class
3376/// \param[in] start The starting position in the buffer b
3377/// \param[in] count The number of bytes for this object in the buffer
3378/// \param[in] onFileClass pointer to TClass object on file
3379///
3380
3381Int_t TBufferFile::ReadClassBuffer(const TClass *cl, void *pointer, Int_t version, UInt_t start, UInt_t count, const TClass *onFileClass)
3382{
3383
3384 //---------------------------------------------------------------------------
3385 // The ondisk class has been specified so get foreign streamer info
3386 /////////////////////////////////////////////////////////////////////////////
3387
3388 TStreamerInfo *sinfo = nullptr;
3389 if( onFileClass ) {
3390 sinfo = (TStreamerInfo*)cl->GetConversionStreamerInfo( onFileClass, version );
3391 if( !sinfo ) {
3392 Error("ReadClassBuffer",
3393 "Could not find the right streamer info to convert %s version %d into a %s, object skipped at offset %d",
3394 onFileClass->GetName(), version, cl->GetName(), Length() );
3395 CheckByteCount(start, count, onFileClass);
3396 return 0;
3397 }
3398 }
3399 //---------------------------------------------------------------------------
3400 // Get local streamer info
3401 /////////////////////////////////////////////////////////////////////////////
3402 /// The StreamerInfo should exist at this point.
3403
3404 else {
3406 auto infos = cl->GetStreamerInfos();
3407 auto ninfos = infos->GetSize();
3408 if (version < -1 || version >= ninfos) {
3409 Error("ReadClassBuffer", "class: %s, attempting to access a wrong version: %d, object skipped at offset %d",
3410 cl->GetName(), version, Length() );
3411 CheckByteCount(start, count, cl);
3412 return 0;
3413 }
3414 sinfo = (TStreamerInfo*)infos->At(version);
3415 if (sinfo == nullptr) {
3416 // Unless the data is coming via a socket connection from with schema evolution
3417 // (tracking) was not enabled. So let's create the StreamerInfo if it is the
3418 // one for the current version, otherwise let's complain ...
3419 // We could also get here if there old class version was '1' and the new class version is higher than 1
3420 // AND the checksum is the same.
3422 // check if another thread took care of this already
3423 sinfo = (TStreamerInfo*)cl->GetStreamerInfos()->At(version);
3424 if (sinfo == nullptr) {
3425 if ( version == cl->GetClassVersion() || version == 1 ) {
3426 const_cast<TClass*>(cl)->BuildRealData(pointer);
3427 // This creation is alright since we just checked within the
3428 // current 'locked' section.
3429 sinfo = new TStreamerInfo(const_cast<TClass*>(cl));
3430 const_cast<TClass*>(cl)->RegisterStreamerInfo(sinfo);
3431 if (gDebug > 0) Info("ReadClassBuffer", "Creating StreamerInfo for class: %s, version: %d", cl->GetName(), version);
3432 sinfo->Build();
3433 } else if (version==0) {
3434 // When the object was written the class was version zero, so
3435 // there is no StreamerInfo to be found.
3436 // Check that the buffer position corresponds to the byte count.
3437 CheckByteCount(start, count, cl);
3438 return 0;
3439 } else {
3440 Error("ReadClassBuffer", "Could not find the StreamerInfo for version %d of the class %s, object skipped at offset %d",
3441 version, cl->GetName(), Length() );
3442 CheckByteCount(start, count, cl);
3443 return 0;
3444 }
3445 }
3446 } else if (!sinfo->IsCompiled()) { // Note this read is protected by the above lock.
3447 // Streamer info has not been compiled, but exists.
3448 // Therefore it was read in from a file and we have to do schema evolution.
3450 // check if another thread took care of this already
3451 if (!sinfo->IsCompiled()) {
3452 const_cast<TClass*>(cl)->BuildRealData(pointer);
3453 sinfo->BuildOld();
3454 }
3455 }
3456 }
3457
3458 // Deserialize the object.
3459 ApplySequence(*(sinfo->GetReadObjectWiseActions()), (char*)pointer);
3460 if (sinfo->IsRecovered()) count=0;
3461
3462 // Check that the buffer position corresponds to the byte count.
3463 CheckByteCount(start, count, cl);
3464 return 0;
3465}
3466
3467////////////////////////////////////////////////////////////////////////////////
3468/// Deserialize information from a buffer into an object.
3469///
3470/// Note: This function is called by the xxx::Streamer()
3471/// functions in rootcint-generated dictionaries.
3472///
3473
3474Int_t TBufferFile::ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onFileClass)
3475{
3476 // Read the class version from the buffer.
3477 UInt_t R__s = 0; // Start of object.
3478 UInt_t R__c = 0; // Count of bytes.
3479 Version_t version;
3480
3481 if( onFileClass )
3482 version = ReadVersion(&R__s, &R__c, onFileClass);
3483 else
3484 version = ReadVersion(&R__s, &R__c, cl);
3485
3486 Bool_t v2file = kFALSE;
3487 TFile *file = (TFile*)GetParent();
3488 if (file && file->GetVersion() < 30000) {
3489 version = -1; //This is old file
3490 v2file = kTRUE;
3491 }
3492
3493 //---------------------------------------------------------------------------
3494 // The ondisk class has been specified so get foreign streamer info
3495 /////////////////////////////////////////////////////////////////////////////
3496
3497 TStreamerInfo *sinfo = nullptr;
3498 if( onFileClass ) {
3499 sinfo = (TStreamerInfo*)cl->GetConversionStreamerInfo( onFileClass, version );
3500 if( !sinfo ) {
3501 Error("ReadClassBuffer",
3502 "Could not find the right streamer info to convert %s version %d into a %s, object skipped at offset %d",
3503 onFileClass->GetName(), version, cl->GetName(), Length() );
3504 CheckByteCount(R__s, R__c, onFileClass);
3505 return 0;
3506 }
3507 }
3508 //---------------------------------------------------------------------------
3509 // Get local streamer info
3510 /////////////////////////////////////////////////////////////////////////////
3511 /// The StreamerInfo should exist at this point.
3512
3513 else {
3515 if (guess && guess->GetClassVersion() == version) {
3516 sinfo = guess;
3517 } else {
3518 // The last one is not the one we are looking for.
3519 {
3521
3522 const TObjArray *infos = cl->GetStreamerInfos();
3523 Int_t infocapacity = infos->Capacity();
3524 if (infocapacity) {
3525 if (version < -1 || version >= infocapacity) {
3526 Error("ReadClassBuffer","class: %s, attempting to access a wrong version: %d, object skipped at offset %d",
3527 cl->GetName(), version, Length());
3528 CheckByteCount(R__s, R__c, cl);
3529 return 0;
3530 }
3531 sinfo = (TStreamerInfo*) infos->UncheckedAt(version);
3532 if (sinfo) {
3533 if (!sinfo->IsCompiled())
3534 {
3535 // Streamer info has not been compiled, but exists.
3536 // Therefore it was read in from a file and we have to do schema evolution?
3538 const_cast<TClass*>(cl)->BuildRealData(pointer);
3539 sinfo->BuildOld();
3540 }
3541 // If the compilation succeeded, remember this StreamerInfo.
3542 // const_cast okay because of the lock on gInterpreterMutex.
3543 if (sinfo->IsCompiled()) const_cast<TClass*>(cl)->SetLastReadInfo(sinfo);
3544 }
3545 }
3546 }
3547
3548 if (sinfo == nullptr) {
3549 // Unless the data is coming via a socket connection from with schema evolution
3550 // (tracking) was not enabled. So let's create the StreamerInfo if it is the
3551 // one for the current version, otherwise let's complain ...
3552 // We could also get here when reading a file prior to the introduction of StreamerInfo.
3553 // We could also get here if there old class version was '1' and the new class version is higher than 1
3554 // AND the checksum is the same.
3555 if (v2file || version == cl->GetClassVersion() || version == 1 ) {
3557
3558 // We need to check if another thread did not get here first
3559 // and did the StreamerInfo creation already.
3560 auto infos = cl->GetStreamerInfos();
3561 auto ninfos = infos->GetSize();
3562 if (!(version < -1 || version >= ninfos)) {
3563 sinfo = (TStreamerInfo *) infos->At(version);
3564 }
3565 if (!sinfo) {
3566 const_cast<TClass *>(cl)->BuildRealData(pointer);
3567 sinfo = new TStreamerInfo(const_cast<TClass *>(cl));
3568 sinfo->SetClassVersion(version);
3569 const_cast<TClass *>(cl)->RegisterStreamerInfo(sinfo);
3570 if (gDebug > 0)
3571 Info("ReadClassBuffer", "Creating StreamerInfo for class: %s, version: %d",
3572 cl->GetName(), version);
3573 if (v2file) {
3574 sinfo->Build(); // Get the elements.
3575 sinfo->Clear("build"); // Undo compilation.
3576 sinfo->BuildEmulated(file); // Fix the types and redo compilation.
3577 } else {
3578 sinfo->Build();
3579 }
3580 }
3581 } else if (version==0) {
3582 // When the object was written the class was version zero, so
3583 // there is no StreamerInfo to be found.
3584 // Check that the buffer position corresponds to the byte count.
3585 CheckByteCount(R__s, R__c, cl);
3586 return 0;
3587 } else {
3588 Error( "ReadClassBuffer", "Could not find the StreamerInfo for version %d of the class %s, object skipped at offset %d",
3589 version, cl->GetName(), Length() );
3590 CheckByteCount(R__s, R__c, cl);
3591 return 0;
3592 }
3593 }
3594 }
3595 }
3596
3597 //deserialize the object
3598 ApplySequence(*(sinfo->GetReadObjectWiseActions()), (char*)pointer );
3599 if (sinfo->TStreamerInfo::IsRecovered()) R__c=0; // 'TStreamerInfo::' avoids going via a virtual function.
3600
3601 // Check that the buffer position corresponds to the byte count.
3602 CheckByteCount(R__s, R__c, cl);
3603
3604 if (gDebug > 2) Info("ReadClassBuffer", "For class: %s has read %d bytes", cl->GetName(), R__c);
3605
3606 return 0;
3607}
3608
3609////////////////////////////////////////////////////////////////////////////////
3610/// Function called by the Streamer functions to serialize object at p
3611/// to buffer b. The optional argument info may be specified to give an
3612/// alternative StreamerInfo instead of using the default StreamerInfo
3613/// automatically built from the class definition.
3614/// For more information, see class TStreamerInfo.
3615
3617{
3618 //build the StreamerInfo if first time for the class
3619 TStreamerInfo *sinfo = (TStreamerInfo*)const_cast<TClass*>(cl)->GetCurrentStreamerInfo();
3620 if (sinfo == nullptr) {
3621 //Have to be sure between the check and the taking of the lock if the current streamer has changed
3623 sinfo = (TStreamerInfo*)const_cast<TClass*>(cl)->GetCurrentStreamerInfo();
3624 if (sinfo == nullptr)
3625 sinfo = (TStreamerInfo*)const_cast<TClass*>(cl)->GetStreamerInfo();
3626 if (sinfo == nullptr) {
3627 const_cast<TClass*>(cl)->BuildRealData(pointer);
3628 sinfo = new TStreamerInfo(const_cast<TClass*>(cl));
3629 const_cast<TClass*>(cl)->SetCurrentStreamerInfo(sinfo);
3630 const_cast<TClass*>(cl)->RegisterStreamerInfo(sinfo);
3631 if (gDebug > 0) Info("WritedClassBuffer", "Creating StreamerInfo for class: %s, version: %d",cl->GetName(),cl->GetClassVersion());
3632 sinfo->Build();
3633 }
3634 } else if (!sinfo->IsCompiled()) {
3636 // Redo the test in case we have been victim of a data race on fIsCompiled.
3637 if (!sinfo->IsCompiled()) {
3638 const_cast<TClass*>(cl)->BuildRealData(pointer);
3639 sinfo->BuildOld();
3640 }
3641 }
3642
3643 //write the class version number and reserve space for the byte count
3644 UInt_t R__c = WriteVersion(cl, kTRUE);
3645
3646 //NOTE: In the future Philippe wants this to happen via a custom action
3647 TagStreamerInfo(sinfo);
3648 ApplySequence(*(sinfo->GetWriteObjectWiseActions()), (char*)pointer);
3649
3650 //write the byte count at the start of the buffer
3651 SetByteCount(R__c, kTRUE);
3652
3653 if (gDebug > 2) Info("WritedClassBuffer", "For class: %s version %d has written %d bytes",cl->GetName(),cl->GetClassVersion(),UInt_t(fBufCur - fBuffer) - R__c - (UInt_t)sizeof(UInt_t));
3654 return 0;
3655}
3656
3657////////////////////////////////////////////////////////////////////////////////
3658/// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
3659/// The collection needs to be a split TClonesArray or a split vector of pointers.
3660
3662{
3663 if (gDebug) {
3664 //loop on all active members
3665 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3666 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
3667 iter != end;
3668 ++iter) {
3669 (*iter).PrintDebug(*this,obj);
3670 (*iter)(*this,obj);
3671 }
3672
3673 } else {
3674 //loop on all active members
3675 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3676 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
3677 iter != end;
3678 ++iter) {
3679 (*iter)(*this,obj);
3680 }
3681 }
3682
3683 return 0;
3684}
3685
3686////////////////////////////////////////////////////////////////////////////////
3687/// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
3688/// The collection needs to be a split TClonesArray or a split vector of pointers.
3689
3690Int_t TBufferFile::ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
3691{
3692 if (gDebug) {
3693 //loop on all active members
3694 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3695 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
3696 iter != end;
3697 ++iter) {
3698 if (!start_collection || start_collection == end_collection)
3699 (*iter).PrintDebug(*this, nullptr); // Warning: This limits us to TClonesArray and vector of pointers.
3700 else
3701 (*iter).PrintDebug(*this, *(char**)start_collection); // Warning: This limits us to TClonesArray and vector of pointers.
3702 (*iter)(*this, start_collection, end_collection);
3703 }
3704
3705 } else {
3706 //loop on all active members
3707 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3708 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
3709 iter != end;
3710 ++iter) {
3711 (*iter)(*this,start_collection,end_collection);
3712 }
3713 }
3714
3715 return 0;
3716}
3717
3718////////////////////////////////////////////////////////////////////////////////
3719/// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
3720
3721Int_t TBufferFile::ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
3722{
3724 if (gDebug) {
3725
3726 // Get the address of the first item for the PrintDebug.
3727 // (Performance is not essential here since we are going to print to
3728 // the screen anyway).
3729 void *arr0 = start_collection ? loopconfig->GetFirstAddress(start_collection,end_collection) : 0;
3730 // loop on all active members
3731 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3732 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
3733 iter != end;
3734 ++iter) {
3735 (*iter).PrintDebug(*this,arr0);
3736 (*iter)(*this,start_collection,end_collection,loopconfig);
3737 }
3738
3739 } else {
3740 //loop on all active members
3741 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
3742 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
3743 iter != end;
3744 ++iter) {
3745 (*iter)(*this,start_collection,end_collection,loopconfig);
3746 }
3747 }
3748
3749 return 0;
3750}
void * bswapcpy16(void *to, const void *from, size_t n)
Definition Bswapcpy.h:45
void * bswapcpy32(void *to, const void *from, size_t n)
Definition Bswapcpy.h:60
void frombuf(char *&buf, Bool_t *x)
Definition Bytes.h:278
void tobuf(char *&buf, Bool_t x)
Definition Bytes.h:55
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
constexpr Int_t kMaxInt
Definition RtypesCore.h:112
long Longptr_t
Definition RtypesCore.h:82
short Version_t
Definition RtypesCore.h:65
unsigned char UChar_t
Definition RtypesCore.h:38
char Char_t
Definition RtypesCore.h:37
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
unsigned long ULongptr_t
Definition RtypesCore.h:83
float Float_t
Definition RtypesCore.h:57
short Short_t
Definition RtypesCore.h:39
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
unsigned long long ULong64_t
Definition RtypesCore.h:81
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
const UInt_t kMaxMapCount
const Int_t kMapOffset
const UInt_t kNewClassTag
static void frombufOld(char *&buf, Long_t *x)
Handle old file formats.
const Version_t kMaxVersion
const UInt_t kClassMask
static bool Class_Has_StreamerInfo(const TClass *cl)
Thread-safe check on StreamerInfos of a TClass.
const Version_t kByteCountVMask
const UInt_t kByteCountMask
@ kIsAbstract
Definition TDictionary.h:71
#define R__ASSERT(e)
Definition TError.h:118
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
float xmin
float xmax
R__EXTERN TVirtualMutex * gInterpreterMutex
Int_t gDebug
Definition TROOT.cxx:597
char *(* ReAllocCharFun_t)(char *, size_t, size_t)
Definition TStorage.h:30
#define R__LOCKGUARD(mutex)
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
Bool_t HasRuleWithSourceClass(const TString &source) const
Return True if we have any rule whose source class is 'source'.
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
void WriteFastArrayFloat16(const Float_t *f, Long64_t n, TStreamerElement *ele=nullptr) override
Write array of n floats (as truncated float) into the I/O buffer.
void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue) override
Read a Float16_t from the buffer when the factor and minimum value have been specified see comments a...
void WriteBuf(const void *buf, Int_t max) override
Write max bytes from buf into the I/O buffer.
void WriteFastArray(const Bool_t *b, Long64_t n) override
Write array of n bools into the I/O buffer.
TObject * ReadObject(const TClass *cl) override
Read object from I/O buffer.
void ReadDouble32(Double_t *d, TStreamerElement *ele=nullptr) override
Read a Double32_t from the buffer, see comments about Double32_t encoding at TBufferFile::WriteDouble...
Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=nullptr) override
Read array of floats (written as truncated float) from the I/O buffer.
void DecrementLevel(TVirtualStreamerInfo *) override
Decrement level.
Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr) override
Read class version from I/O buffer.
Version_t ReadVersionNoCheckSum(UInt_t *start=nullptr, UInt_t *bcnt=nullptr) override
Read class version from I/O buffer, when the caller knows for sure that there is no checksum written/...
void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE) override
Set byte count at position cntpos in the buffer.
~TBufferFile() override
Delete an I/O buffer object.
void ReadWithNbits(Float_t *ptr, Int_t nbits) override
Read a Float16_t from the buffer when the number of bits is specified (explicitly or not) see comment...
void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) override
Write object to I/O buffer.
void ReadTString(TString &s) override
Read TString from TBuffer.
void ReadCharStar(char *&s) override
Read char* from TBuffer.
void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=nullptr) override
Stream an object given its C++ typeinfo information.
UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE) override
Write class version to I/O buffer.
Int_t ReadBuf(void *buf, Int_t max) override
Read max bytes from the I/O buffer into buf.
void WriteString(const char *s) override
Write string to I/O buffer.
char * ReadString(char *s, Int_t max) override
Read string from I/O buffer.
void WriteArray(const Bool_t *b, Int_t n) override
Write array of n bools into the I/O buffer.
void ReadFastArray(Bool_t *b, Int_t n) override
Read array of n bools from the I/O buffer.
void ReadFastArrayString(Char_t *c, Int_t n) override
Read array of n characters from the I/O buffer.
Int_t ReadArray(Bool_t *&b) override
Read array of bools from the I/O buffer.
Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object) override
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
void * ReadObjectAny(const TClass *cast) override
Read object from I/O buffer.
void SkipObjectAny() override
Skip any kind of object from buffer.
Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=nullptr) override
Read array of doubles (written as float) from the I/O buffer.
TClass * ReadClass(const TClass *cl=nullptr, UInt_t *objTag=nullptr) override
Read class definition from I/O buffer.
Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class) override
Deserialize information from a buffer into an object.
void SkipVersion(const TClass *cl=nullptr) override
Skip class version from I/O buffer.
void ReadFloat16(Float_t *f, TStreamerElement *ele=nullptr) override
Read a Float16_t from the buffer, see comments about Float16_t encoding at TBufferFile::WriteFloat16(...
@ kStreamedMemberWise
Definition TBufferFile.h:69
void Streamer(TBuffer &) override
Stream an object of class TObject.
void WriteFastArrayDouble32(const Double_t *d, Long64_t n, TStreamerElement *ele=nullptr) override
Write array of n doubles (as float) into the I/O buffer.
void WriteFastArrayString(const Char_t *c, Long64_t n) override
Write array of n characters into the I/O buffer.
Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss, const char *classname)
Check byte count with current buffer position.
void WriteCharStar(char *s) override
Write char* into TBuffer.
Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection) override
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
void WriteStdString(const std::string *s) override
Write std::string to TBuffer.
Int_t WriteClassBuffer(const TClass *cl, void *pointer) override
Function called by the Streamer functions to serialize object at p to buffer b.
void WriteClass(const TClass *cl) override
Write class description to I/O buffer.
void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=nullptr) override
Read array of n doubles (written as float) from the I/O buffer.
UInt_t WriteVersionMemberWise(const TClass *cl, Bool_t useBcnt=kFALSE) override
Write class version to I/O buffer after setting the kStreamedMemberWise bit in the version number.
void CheckCount(UInt_t offset) override
Check if offset is not too large (< kMaxMapCount) when writing.
Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=nullptr) override
Read array of floats (written as truncated float) from the I/O buffer.
void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=nullptr) override
Read array of n floats (written as truncated float) from the I/O buffer.
void ReadStdString(std::string *s) override
Read std::string from TBuffer.
void WriteFloat16(Float_t *f, TStreamerElement *ele=nullptr) override
Write a Float16_t to the buffer.
Int_t ReadStaticArray(Bool_t *b) override
Read array of bools from the I/O buffer.
void WriteTString(const TString &s) override
Write TString to TBuffer.
UInt_t CheckObject(UInt_t offset, const TClass *cl, Bool_t readClass=kFALSE)
Check for object in the read map.
InfoList_t fInfoStack
Stack of pointers to the TStreamerInfos.
Definition TBufferFile.h:53
void WriteDouble32(Double_t *d, TStreamerElement *ele=nullptr) override
Write a Double32_t to the buffer.
void ReadLong(Long_t &l) override
Read Long from TBuffer.
void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits) override
Read array of n floats (written as truncated float) from the I/O buffer.
void IncrementLevel(TVirtualStreamerInfo *info) override
Increment level.
Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele=nullptr) override
Read array of doubles (written as float) from the I/O buffer.
void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=nullptr) override
Write array of n doubles (as float) into the I/O buffer.
void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=nullptr) override
Write array of n floats (as truncated float) into the I/O buffer.
void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue) override
Read array of n floats (written as truncated float) from the I/O buffer.
Version_t ReadVersionForMemberWise(const TClass *cl=nullptr) override
Read class version from I/O buffer.
TStreamerInfo * fInfo
Pointer to TStreamerInfo object writing/reading the buffer.
Definition TBufferFile.h:52
Int_t ReadClassEmulated(const TClass *cl, void *object, const TClass *onfile_class) override
Read emulated class.
Direct subclass of TBuffer, implements common methods for TBufferFile and TBufferText classes.
Definition TBufferIO.h:30
void InitMap() override
Create the fMap container and initialize them with the null object.
void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override
force writing the TStreamerInfo to the file
TExMap * fMap
Map containing object,offset pairs for reading/writing.
Definition TBufferIO.h:39
void MapObject(const TObject *obj, UInt_t offset=1) override
Add object to the fMap container.
TExMap * fClassMap
Map containing object,class pairs for reading.
Definition TBufferIO.h:40
Int_t fDisplacement
Value to be added to the map offsets.
Definition TBufferIO.h:37
static R__ALWAYS_INLINE ULong_t Void_Hash(const void *ptr)
Return hash value for provided object.
Definition TBufferIO.h:53
Int_t fMapCount
Number of objects or classes in map.
Definition TBufferIO.h:35
void TagStreamerInfo(TVirtualStreamerInfo *info) override
Mark the classindex of the current file as using this TStreamerInfo.
Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Int_t fBufSize
Definition TBuffer.h:50
TObject * GetParent() const
Return pointer to parent of this buffer.
Definition TBuffer.cxx:262
char * fBufMax
Definition TBuffer.h:53
char * fBufCur
Definition TBuffer.h:52
void AutoExpand(Int_t size_needed)
Automatically calculate a new size and expand the buffer to fit at least size_needed.
Definition TBuffer.cxx:158
Bool_t IsWriting() const
Definition TBuffer.h:87
Bool_t IsReading() const
Definition TBuffer.h:86
void SetBufferOffset(Int_t offset=0)
Definition TBuffer.h:93
char * fBuffer
Definition TBuffer.h:51
TObject * fParent
Definition TBuffer.h:54
Int_t fVersion
Definition TBuffer.h:49
Int_t Length() const
Definition TBuffer.h:100
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
UInt_t GetCheckSum(ECheckSum code=kCurrentCheckSum) const
Call GetCheckSum with validity check.
Definition TClass.cxx:6505
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=nullptr) const
Definition TClass.h:607
EState GetState() const
Definition TClass.h:488
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:4978
static TClass * Load(TBuffer &b)
Load class description from I/O buffer and return class object.
Definition TClass.cxx:5715
TVirtualStreamerInfo * GetCurrentStreamerInfo()
Definition TClass.h:439
void SetLastReadInfo(TVirtualStreamerInfo *info)
Definition TClass.h:445
Bool_t MatchLegacyCheckSum(UInt_t checksum) const
Return true if the checksum passed as argument is one of the checksum value produced by the older che...
Definition TClass.cxx:6494
TVirtualStreamerInfo * GetLastReadInfo() const
Definition TClass.h:444
Int_t Size() const
Return size of object of this class.
Definition TClass.cxx:5704
const ROOT::Detail::TSchemaRuleSet * GetSchemaRules() const
Return the set of the schema rules if any.
Definition TClass.cxx:1932
void Store(TBuffer &b) const
Store class description on I/O buffer.
Definition TClass.cxx:5860
const TObjArray * GetStreamerInfos() const
Definition TClass.h:492
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
Definition TClass.cxx:5912
Bool_t IsForeign() const
Return kTRUE is the class is Foreign (the class does not have a Streamer method).
Definition TClass.cxx:5947
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Definition TClass.cxx:4599
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4874
Int_t GetBaseClassOffset(const TClass *toBase, void *address=nullptr, bool isDerivedObject=true)
Definition TClass.cxx:2791
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Definition TClass.cxx:6086
Bool_t HasDefaultConstructor(Bool_t testio=kFALSE) const
Return true if we have access to a constructor usable for I/O.
Definition TClass.cxx:7393
TVirtualStreamerInfo * GetConversionStreamerInfo(const char *onfile_classname, Int_t version) const
Return a Conversion StreamerInfo from the class 'classname' for version number 'version' to this clas...
Definition TClass.cxx:7086
@ kEmulated
Definition TClass.h:125
TVirtualStreamerInfo * FindStreamerInfo(TObjArray *arr, UInt_t checksum) const
Find the TVirtualStreamerInfo in the StreamerInfos corresponding to checksum.
Definition TClass.cxx:7066
Version_t GetClassVersion() const
Definition TClass.h:420
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.
Definition TClass.cxx:2968
Int_t Capacity() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Int_t GetSize() const
Definition TExMap.h:71
void Remove(ULong64_t hash, Long64_t key)
Remove entry with specified key from the TExMap.
Definition TExMap.cxx:217
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition TExMap.cxx:88
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition TExMap.cxx:174
Int_t Capacity() const
Definition TExMap.h:69
void AddAt(UInt_t slot, ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table.
Definition TExMap.cxx:117
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
Int_t GetVersion() const
Definition TFile.h:245
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:576
virtual void SetOnFileClass(const TClass *cl)
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
An array of TObjects.
Definition TObjArray.h:31
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
Int_t GetLast() const override
Return index of last object in array.
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:439
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:888
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:973
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1015
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:961
Double_t GetXmax() const
Double_t GetFactor() const
Double_t GetXmin() const
TLoopConfiguration * fLoopConfig
If this is a bundle of memberwise streaming action, this configures the looping.
Base class of the Configurations for the member wise looping routines.
virtual void * GetFirstAddress(void *start, const void *end) const =0
Describes a persistent version of a class.
Int_t GetClassVersion() const override
void BuildEmulated(TFile *file) override
Create an Emulation TStreamerInfo object.
void Build(Bool_t isTransient=kFALSE) override
Build the I/O data structure for the current class version.
void BuildOld() override
rebuild the TStreamerInfo structure
TStreamerInfoActions::TActionSequence * GetReadObjectWiseActions()
void SetClassVersion(Int_t vers) override
void Clear(Option_t *="") override
If opt contains 'built', reset this StreamerInfo as if Build or BuildOld was never called on it (usef...
UInt_t GetCheckSum() const override
TStreamerInfoActions::TActionSequence * GetWriteObjectWiseActions()
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
void UnLink() const
Definition TString.h:263
Ssiz_t Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition TString.cxx:1246
void SetSize(Ssiz_t s)
Definition TString.h:248
void Zero()
Definition TString.h:264
char * GetPointer()
Definition TString.h:256
Abstract Interface class describing Streamer information for one class.
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__EXTERN TVirtualRWMutex * gCoreMutex
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
TLine l
Definition textangle.C:4