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
32TStringLong::TStringLong() : TString()
33{
34}
35
36////////////////////////////////////////////////////////////////////////////////
37///constructor
38
39TStringLong::TStringLong(Ssiz_t ic) : TString(ic)
40{
41}
42
43////////////////////////////////////////////////////////////////////////////////
44///copy constructor
45
46TStringLong::TStringLong(const TString& s) : TString(s)
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
60TStringLong::TStringLong(const char* cs, Ssiz_t n) : TString(cs,n)
61{
62}
63
64////////////////////////////////////////////////////////////////////////////////
65///constructor from a char
66
67TStringLong::TStringLong(char c) : TString(c)
68{
69}
70
71////////////////////////////////////////////////////////////////////////////////
72///constructor from a char
73
74TStringLong::TStringLong(char c, Ssiz_t n) : TString(c,n)
75{
76}
77
78////////////////////////////////////////////////////////////////////////////////
79///constructor from a substring
80
81TStringLong::TStringLong(const TSubString& substr) : TString(substr)
82{
83}
84
85////////////////////////////////////////////////////////////////////////////////
86///destructor
87
88TStringLong::~TStringLong()
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
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
123Int_t TStringLong::Sizeof() const
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 Ssiz_t nwr = Clobber(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
int Ssiz_t
String size (currently int)
Definition RtypesCore.h:81
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
Basic string class.
Definition TString.h:138
A zero length substring is legal.
Definition TString.h:84
const Int_t n
Definition legend1.C:16
void Init(TClassEdit::TInterpreterLookupHelper *helper)