Logo ROOT   6.12/07
Reference Guide
TStringLong.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Rene Brun 15/11/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 /** \class TStringLong
13 ATTENTION: this class is obsolete. It's functionality has been taken
14 over by TString.
15 
16 The long string class (unlimited number of chars in I/O).
17 
18 This class redefines only the I/O member functions of TString.
19 It uses 4 bytes to store the string length (1 byte only for TString).
20 */
21 
22 #include "TStringLong.h"
23 #include "TBuffer.h"
24 #include "Bytes.h"
25 
27 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 ///constructor
31 
33 {
34 }
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 ///constructor
38 
40 {
41 }
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 ///copy constructor
45 
47 {
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 ///copy constructor
52 
53 TStringLong::TStringLong(const char* cs) : TString(cs)
54 {
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 ///constructor from a char*
59 
60 TStringLong::TStringLong(const char* cs, Ssiz_t n) : TString(cs,n)
61 {
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 ///constructor from a char
66 
68 {
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 ///constructor from a char
73 
75 {
76 }
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 ///constructor from a substring
80 
82 {
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 ///destructor
87 
89 {
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// Fill buffer.
94 
95 void TStringLong::FillBuffer(char *&buffer) const
96 {
97  Int_t nchars = Length();
98  tobuf(buffer, nchars);
99  const char *data = GetPointer();
100  for (Int_t i = 0; i < nchars; i++) buffer[i] = data[i];
101  buffer += nchars;
102 }
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Read this string from the buffer.
106 
107 void TStringLong::ReadBuffer(char *&buffer)
108 {
109  UnLink();
110  Zero();
111 
112  Int_t nchars;
113  frombuf(buffer, &nchars);
114 
115  char *data = Init(nchars, nchars);
116 
117  for (Int_t i = 0; i < nchars; i++) frombuf(buffer, &data[i]);
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// Return the sizeof the string.
122 
124 {
125  return Length()+sizeof(Int_t);
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// Stream a long (>255 characters) string object.
130 
131 void TStringLong::Streamer(TBuffer &b)
132 {
133  Int_t nwh;
134  if (b.IsReading()) {
135  b >> nwh;
136  Clobber(nwh);
137  char *data = GetPointer();
138  data[nwh] = 0;
139  SetSize(nwh);
140  for (int i = 0; i < nwh; i++) b >> data[i];
141  } else {
142  nwh = Length();
143  b << nwh;
144  const char *data = GetPointer();
145  for (int i = 0; i < nwh; i++) b << data[i];
146  }
147 }
A zero length substring is legal.
Definition: TString.h:71
Bool_t IsReading() const
Definition: TBuffer.h:83
void frombuf(char *&buf, Bool_t *x)
Definition: Bytes.h:280
void Zero()
Definition: TString.h:232
virtual Int_t Sizeof() const
Return the sizeof the string.
ATTENTION: this class is obsolete.
Definition: TStringLong.h:31
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
virtual void ReadBuffer(char *&buffer)
Read this string from the buffer.
char * GetPointer()
Definition: TString.h:224
char * Init(Ssiz_t capacity, Ssiz_t nchar)
Private member function returning an empty string representation of size capacity and containing ncha...
Definition: TString.cxx:228
void tobuf(char *&buf, Bool_t x)
Definition: Bytes.h:57
TStringLong()
constructor
Definition: TStringLong.cxx:32
Ssiz_t Length() const
Definition: TString.h:386
void UnLink() const
Definition: TString.h:231
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition: TString.cxx:1158
int Ssiz_t
Definition: RtypesCore.h:63
virtual void FillBuffer(char *&buffer) const
Fill buffer.
Definition: TStringLong.cxx:95
#define ClassImp(name)
Definition: Rtypes.h:359
static constexpr double s
void SetSize(Ssiz_t s)
Definition: TString.h:216
virtual ~TStringLong()
destructor
Definition: TStringLong.cxx:88
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
const Int_t n
Definition: legend1.C:16