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//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
133{
134 Int_t nwh;
135 if (b.IsReading()) {
136 b >> nwh;
137 Ssiz_t nwr = Clobber(nwh);
138 char *data = GetPointer();
139 data[nwr] = 0;
140 SetSize(nwr);
141 for (Ssiz_t i = 0; i < nwr; 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: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
Definition RtypesCore.h:45
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:139
Ssiz_t Length() const
Definition TString.h:417
void UnLink() const
Definition TString.h:263
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:261
Ssiz_t Clobber(Ssiz_t nc)
Clear string and make sure it has a capacity of nc.
Definition TString.cxx:1246
void SetSize(Ssiz_t s)
Definition TString.h:248
void Zero()
Definition TString.h:264
char * GetPointer()
Definition TString.h:256
A zero length substring is legal.
Definition TString.h:85
const Int_t n
Definition legend1.C:16