Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TBufferText.h
Go to the documentation of this file.
1 // $Id$
2 // Author: Sergey Linev 21.12.2017
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2017, 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 #ifndef ROOT_TBufferText
13 #define ROOT_TBufferText
14 
15 #include "TBufferIO.h"
16 #include "TString.h"
17 
18 class TStreamerBase;
19 class TExMap;
20 
21 class TBufferText : public TBufferIO {
22 
23 protected:
24  TBufferText();
25  TBufferText(TBuffer::EMode mode, TObject *parent = nullptr);
26 
27 public:
28  virtual ~TBufferText();
29 
30  // virtual TBuffer methods, which are generic for all text-based streamers
31 
32  void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass = nullptr) override;
33  void StreamObject(void *obj, const char *className, const TClass *onFileClass = nullptr) override;
34  void StreamObject(TObject *obj) override;
35  using TBuffer::StreamObject;
36 
37  Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object) final;
38  Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection,
39  void *end_collection) final;
40  Int_t
41  ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection) final;
42 
43  void ReadFloat16(Float_t *f, TStreamerElement *ele = nullptr) final;
44  void WriteFloat16(Float_t *f, TStreamerElement *ele = nullptr) final;
45  void ReadDouble32(Double_t *d, TStreamerElement *ele = nullptr) final;
46  void WriteDouble32(Double_t *d, TStreamerElement *ele = nullptr) final;
47  void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue) final;
48  void ReadWithNbits(Float_t *ptr, Int_t nbits) final;
49  void ReadWithFactor(Double_t *ptr, Double_t factor, Double_t minvalue) final;
50  void ReadWithNbits(Double_t *ptr, Int_t nbits) final;
51 
52  Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele = nullptr) override;
53  Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele = nullptr) override;
54 
55  Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele = nullptr) final;
56  Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele = nullptr) final;
57 
58  void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele = nullptr) final;
59  void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele = nullptr) final;
60  void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue) final;
61  void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits) final;
62  void ReadFastArrayWithFactor(Double_t *ptr, Int_t n, Double_t factor, Double_t minvalue) final;
63  void ReadFastArrayWithNbits(Double_t *ptr, Int_t n, Int_t nbits) final;
64 
65  void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele = nullptr) final;
66  void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele = nullptr) final;
67 
68  void WriteFastArrayFloat16(const Float_t *d, Int_t n, TStreamerElement *ele = nullptr) final;
69  void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele = nullptr) final;
70 
71  // Utilities for TClass
72  Int_t ReadClassBuffer(const TClass * /*cl*/, void * /*pointer*/, const TClass * /*onfile_class*/ = nullptr) override;
73  Int_t ReadClassBuffer(const TClass * /*cl*/, void * /*pointer*/, Int_t /*version*/, UInt_t /*start*/,
74  UInt_t /*count*/, const TClass * /*onfile_class*/ = nullptr) override;
75  Int_t WriteClassBuffer(const TClass *cl, void *pointer) override;
76 
77  // virtual abstract TBuffer methods, which are not used in text streaming
78 
79  Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const TClass * /* clss */) final { return 0; }
80  Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const char * /* classname */) final { return 0; }
81  void SetByteCount(UInt_t /* cntpos */, Bool_t /* packInVersion */ = kFALSE) final {}
82  void SkipVersion(const TClass *cl = nullptr) final;
83  Version_t ReadVersionNoCheckSum(UInt_t *, UInt_t *) final { return 0; }
84 
85  Int_t ReadBuf(void * /*buf*/, Int_t /*max*/) final
86  {
87  Error("ReadBuf", "useless in text streamers");
88  return 0;
89  }
90  void WriteBuf(const void * /*buf*/, Int_t /*max*/) final { Error("WriteBuf", "useless in text streamers"); }
91 
92  char *ReadString(char * /*s*/, Int_t /*max*/) final
93  {
94  Error("ReadString", "useless");
95  return nullptr;
96  }
97  void WriteString(const char * /*s*/) final { Error("WriteString", "useless"); }
98 
99  Version_t ReadVersionForMemberWise(const TClass * /*cl*/ = nullptr) final
100  {
101  Error("ReadVersionForMemberWise", "not defined in text-based streamers");
102  return 0;
103  }
104  UInt_t WriteVersionMemberWise(const TClass * /*cl*/, Bool_t /*useBcnt*/ = kFALSE) final
105  {
106  Error("WriteVersionMemberWise", "not defined in text-based streamers");
107  return 0;
108  }
109 
110  TObject *ReadObject(const TClass * /*cl*/) final
111  {
112  Error("ReadObject", "not yet implemented for text-based streamers");
113  return nullptr;
114  }
115 
116  // Utilities for TClass
117  Int_t ReadClassEmulated(const TClass * /*cl*/, void * /*object*/, const TClass * /*onfile_class*/ = nullptr) final
118  {
119  Error("ReadClassEmulated", "not defined in text-based streamers");
120  return 0;
121  }
122 
123  virtual void WriteBaseClass(void *start, TStreamerBase *elem);
124 
125  virtual void ReadBaseClass(void *start, TStreamerBase *elem);
126 
127  static void SetFloatFormat(const char *fmt = "%e");
128  static const char *GetFloatFormat();
129  static void SetDoubleFormat(const char *fmt = "%.14e");
130  static const char *GetDoubleFormat();
131 
132  static void CompactFloatString(char *buf, unsigned len);
133  static const char *ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize = kFALSE);
134  static const char *ConvertDouble(Double_t v, char *buf, unsigned len, Bool_t not_optimize = kFALSE);
135 
136 protected:
137  static const char *fgFloatFmt; ///<! printf argument for floats, either "%f" or "%e" or "%10f" and so on
138  static const char *fgDoubleFmt; ///<! printf argument for doubles, either "%f" or "%e" or "%10f" and so on
139 
140  ClassDefOverride(TBufferText, 0); // a TBuffer subclass for all text-based streamers
141 };
142 
143 #endif