Logo ROOT   6.16/01
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
13ATTENTION: this class is obsolete. It's functionality has been taken
14over by TString.
15
16The long string class (unlimited number of chars in I/O).
17
18This class redefines only the I/O member functions of TString.
19It 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
53TStringLong::TStringLong(const char* cs) : TString(cs)
54{
55}
56
57////////////////////////////////////////////////////////////////////////////////
58///constructor from a char*
59
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
95void 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
107void 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
131void 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}
void frombuf(char *&buf, Bool_t *x)
Definition: Bytes.h:280
void tobuf(char *&buf, Bool_t x)
Definition: Bytes.h:57
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
int Int_t
Definition: RtypesCore.h:41
int Ssiz_t
Definition: RtypesCore.h:63
#define ClassImp(name)
Definition: Rtypes.h:363
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
ATTENTION: this class is obsolete.
Definition: TStringLong.h:31
virtual ~TStringLong()
destructor
Definition: TStringLong.cxx:88
virtual void FillBuffer(char *&buffer) const
Fill buffer.
Definition: TStringLong.cxx:95
TStringLong()
constructor
Definition: TStringLong.cxx:32
virtual void ReadBuffer(char *&buffer)
Read this string from the buffer.
virtual Int_t Sizeof() const
Return the sizeof the string.
Basic string class.
Definition: TString.h:131
Ssiz_t Length() const
Definition: TString.h:405
void UnLink() const
Definition: TString.h:249
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:227
void SetSize(Ssiz_t s)
Definition: TString.h:234
void Zero()
Definition: TString.h:250
char * GetPointer()
Definition: TString.h:242
void Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition: TString.cxx:1159
A zero length substring is legal.
Definition: TString.h:77
const Int_t n
Definition: legend1.C:16
static constexpr double s