Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
28
29////////////////////////////////////////////////////////////////////////////////
30///constructor
31
35
36////////////////////////////////////////////////////////////////////////////////
37///constructor
38
42
43////////////////////////////////////////////////////////////////////////////////
44///copy constructor
45
49
50////////////////////////////////////////////////////////////////////////////////
51///copy constructor
52
54{
55}
56
57////////////////////////////////////////////////////////////////////////////////
58///constructor from a char*
59
61{
62}
63
64////////////////////////////////////////////////////////////////////////////////
65///constructor from a char
66
70
71////////////////////////////////////////////////////////////////////////////////
72///constructor from a char
73
77
78////////////////////////////////////////////////////////////////////////////////
79///constructor from a substring
80
84
85////////////////////////////////////////////////////////////////////////////////
86///destructor
87
91
92////////////////////////////////////////////////////////////////////////////////
93/// Fill buffer.
94
95void TStringLong::FillBuffer(char *&buffer) const
96{
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
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
132{
133 Int_t nwh;
134 if (b.IsReading()) {
135 b >> nwh;
137 char *data = GetPointer();
138 data[nwr] = 0;
139 SetSize(nwr);
140 for (Ssiz_t i = 0; i < nwr; 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:278
void tobuf(char *&buf, Bool_t x)
Definition Bytes.h:55
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual ~TStringLong()
destructor
void FillBuffer(char *&buffer) const override
Fill buffer.
TStringLong()
constructor
void Streamer(TBuffer &) override
Stream a long (>255 characters) string object.
Int_t Sizeof() const override
Return the sizeof the string.
void ReadBuffer(char *&buffer) override
Read this string from the buffer.
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
void UnLink() const
Definition TString.h:271
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:268
Ssiz_t Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition TString.cxx:1252
void SetSize(Ssiz_t s)
Definition TString.h:256
void Zero()
Definition TString.h:272
char * GetPointer()
Definition TString.h:264
A zero length substring is legal.
Definition TString.h:84
const Int_t n
Definition legend1.C:16