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
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
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
54TStringLong::TStringLong(const char* cs) : TString(cs)
55{
56}
57
58////////////////////////////////////////////////////////////////////////////////
59///constructor from a char*
60
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
96void 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
108void 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
132void 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}
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
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
virtual ~TStringLong()
destructor
Definition: TStringLong.cxx:89
virtual void FillBuffer(char *&buffer) const
Fill buffer.
Definition: TStringLong.cxx:96
TStringLong()
constructor
Definition: TStringLong.cxx:33
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:239
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:1184
A zero length substring is legal.
Definition: TString.h:77
const Int_t n
Definition: legend1.C:16
static constexpr double s