Logo ROOT  
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 
26 // Remove to avoid deprecation warnings during root build
27 //ClassImp(TStringLong);
28 
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 ///constructor
32 
34 {
35 }
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 ///constructor
39 
41 {
42 }
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 ///copy constructor
46 
48 {
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 ///copy constructor
53 
54 TStringLong::TStringLong(const char* cs) : TString(cs)
55 {
56 }
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 ///constructor from a char*
60 
61 TStringLong::TStringLong(const char* cs, Ssiz_t n) : TString(cs,n)
62 {
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 ///constructor from a char
67 
69 {
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 ///constructor from a char
74 
76 {
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 ///constructor from a substring
81 
83 {
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 ///destructor
88 
90 {
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Fill buffer.
95 
96 void TStringLong::FillBuffer(char *&buffer) const
97 {
98  Int_t nchars = Length();
99  tobuf(buffer, nchars);
100  const char *data = GetPointer();
101  for (Int_t i = 0; i < nchars; i++) buffer[i] = data[i];
102  buffer += nchars;
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Read this string from the buffer.
107 
108 void TStringLong::ReadBuffer(char *&buffer)
109 {
110  UnLink();
111  Zero();
112 
113  Int_t nchars;
114  frombuf(buffer, &nchars);
115 
116  char *data = Init(nchars, nchars);
117 
118  for (Int_t i = 0; i < nchars; i++) frombuf(buffer, &data[i]);
119 }
120 
121 ////////////////////////////////////////////////////////////////////////////////
122 /// Return the sizeof the string.
123 
125 {
126  return Length()+sizeof(Int_t);
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 /// Stream a long (>255 characters) string object.
131 
132 void TStringLong::Streamer(TBuffer &b)
133 {
134  Int_t nwh;
135  if (b.IsReading()) {
136  b >> nwh;
137  Clobber(nwh);
138  char *data = GetPointer();
139  data[nwh] = 0;
140  SetSize(nwh);
141  for (int i = 0; i < nwh; i++) b >> data[i];
142  } else {
143  nwh = Length();
144  b << nwh;
145  const char *data = GetPointer();
146  for (int i = 0; i < nwh; i++) b << data[i];
147  }
148 }
c
#define c(i)
Definition: RSha256.hxx:101
n
const Int_t n
Definition: legend1.C:16
TString::Zero
void Zero()
Definition: TString.h:255
TString::GetPointer
char * GetPointer()
Definition: TString.h:247
TStringLong.h
TString::UnLink
void UnLink() const
Definition: TString.h:254
tobuf
void tobuf(char *&buf, Bool_t x)
Definition: Bytes.h:55
TString::Clobber
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition: TString.cxx:1184
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
Int_t
int Int_t
Definition: RtypesCore.h:45
TStringLong::Sizeof
virtual Int_t Sizeof() const
Return the sizeof the string.
Definition: TStringLong.cxx:124
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
TString::Init
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:239
TString
Basic string class.
Definition: TString.h:136
b
#define b(i)
Definition: RSha256.hxx:100
TStringLong::ReadBuffer
virtual void ReadBuffer(char *&buffer)
Read this string from the buffer.
Definition: TStringLong.cxx:108
TSubString
A zero length substring is legal.
Definition: TString.h:82
TBuffer.h
TStringLong::TStringLong
TStringLong()
constructor
Definition: TStringLong.cxx:33
TString::SetSize
void SetSize(Ssiz_t s)
Definition: TString.h:239
frombuf
void frombuf(char *&buf, Bool_t *x)
Definition: Bytes.h:278
Bytes.h
TStringLong::FillBuffer
virtual void FillBuffer(char *&buffer) const
Fill buffer.
Definition: TStringLong.cxx:96
TStringLong::~TStringLong
virtual ~TStringLong()
destructor
Definition: TStringLong.cxx:89
int