00001 // @(#)root/base:$Id: TStringLong.cxx 20877 2007-11-19 11:17:07Z rdm $ 00002 // Author: Rene Brun 15/11/95 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 ////////////////////////////////////////////////////////////////////////// 00013 // // 00014 // TStringLong // 00015 // // 00016 // ATTENTION: this class is obsolete. It's functionality has been taken // 00017 // over by TString. // 00018 // // 00019 // The long string class (unlimited number of chars in I/O). // 00020 // // 00021 // This class redefines only the I/O member functions of TString. // 00022 // It uses 4 bytes to store the string length (1 byte only for TString).// 00023 // // 00024 ////////////////////////////////////////////////////////////////////////// 00025 00026 #include "TStringLong.h" 00027 #include "TBuffer.h" 00028 #include "Bytes.h" 00029 00030 ClassImp(TStringLong) 00031 00032 00033 //______________________________________________________________________________ 00034 TStringLong::TStringLong() : TString() 00035 { 00036 //constructor 00037 } 00038 00039 //______________________________________________________________________________ 00040 TStringLong::TStringLong(Ssiz_t ic) : TString(ic) 00041 { 00042 //constructor 00043 } 00044 00045 //______________________________________________________________________________ 00046 TStringLong::TStringLong(const TString& s) : TString(s) 00047 { 00048 //copy constructor 00049 } 00050 00051 //______________________________________________________________________________ 00052 TStringLong::TStringLong(const char* cs) : TString(cs) 00053 { 00054 //copy constructor 00055 } 00056 00057 //______________________________________________________________________________ 00058 TStringLong::TStringLong(const char* cs, Ssiz_t n) : TString(cs,n) 00059 { 00060 //constructor from a char* 00061 } 00062 00063 //______________________________________________________________________________ 00064 TStringLong::TStringLong(char c) : TString(c) 00065 { 00066 //constructor from a char 00067 } 00068 00069 //______________________________________________________________________________ 00070 TStringLong::TStringLong(char c, Ssiz_t n) : TString(c,n) 00071 { 00072 //constructor from a char 00073 } 00074 00075 //______________________________________________________________________________ 00076 TStringLong::TStringLong(const TSubString& substr) : TString(substr) 00077 { 00078 //constructor from a substring 00079 } 00080 00081 //______________________________________________________________________________ 00082 TStringLong::~TStringLong() 00083 { 00084 //destructor 00085 } 00086 00087 //______________________________________________________________________________ 00088 void TStringLong::FillBuffer(char *&buffer) 00089 { 00090 //fill buffer 00091 Int_t nchars = Length(); 00092 tobuf(buffer, nchars); 00093 for (Int_t i = 0; i < nchars; i++) buffer[i] = fData[i]; 00094 buffer += nchars; 00095 } 00096 00097 //______________________________________________________________________________ 00098 void TStringLong::ReadBuffer(char *&buffer) 00099 { 00100 // Read this string from the buffer. 00101 Pref()->UnLink(); 00102 00103 Int_t nchars; 00104 frombuf(buffer, &nchars); 00105 00106 fData = TStringRef::GetRep(nchars, nchars)->Data(); 00107 00108 for (Int_t i = 0; i < nchars; i++) frombuf(buffer, &fData[i]); 00109 } 00110 00111 //______________________________________________________________________________ 00112 Int_t TStringLong::Sizeof() const 00113 { 00114 // Return the sizeof the string. 00115 return Length()+sizeof(Int_t); 00116 } 00117 00118 //_______________________________________________________________________ 00119 void TStringLong::Streamer(TBuffer &b) 00120 { 00121 // Stream a long (>255 characters) string object. 00122 00123 Int_t nwh; 00124 if (b.IsReading()) { 00125 b >> nwh; 00126 fData = TStringRef::GetRep(nwh, nwh)->Data(); 00127 for (int i = 0; i < nwh; i++) b >> fData[i]; 00128 } else { 00129 nwh = Length(); 00130 b << nwh; 00131 for (int i = 0; i < nwh; i++) b << fData[i]; 00132 } 00133 }