Skip to content
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rootcint_*.h
/buildtools
/roottest
/*.mk
/.project

# cint/cint
cint/cint/inc/configcint.h
Expand Down Expand Up @@ -135,6 +136,7 @@ cint/cint/src/loadfile_tmp.cxx
/etc/cling
/etc/allDict.cxx.pch
/etc/allDict.cxx.h
/etc/dictpch

# /etc/daemons/
/etc/daemons/rootd.rc.d
Expand Down
2 changes: 2 additions & 0 deletions core/base/inc/TBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class TBuffer : public TObject {
virtual void ReadDouble(Double_t &d) = 0;
virtual void ReadCharP(Char_t *c) = 0;
virtual void ReadTString(TString &s) = 0;
virtual void ReadStdString(std::string &s) = 0;

virtual void WriteBool(Bool_t b) = 0;
virtual void WriteChar(Char_t c) = 0;
Expand All @@ -293,6 +294,7 @@ class TBuffer : public TObject {
virtual void WriteDouble(Double_t d) = 0;
virtual void WriteCharP(const Char_t *c) = 0;
virtual void WriteTString(const TString &s) = 0;
virtual void WriteStdString(const std::string &s) = 0;

// Special basic ROOT objects and collections
virtual TProcessID *GetLastProcessID(TRefTable *reftable) const = 0;
Expand Down
2 changes: 2 additions & 0 deletions core/base/inc/TString.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TString;
class TSubString;
class TObjArray;
class TVirtualMutex;
class TBufferFile;

R__EXTERN TVirtualMutex *gStringMutex;

Expand Down Expand Up @@ -135,6 +136,7 @@ class TString {

friend class TStringLong;
friend class TSubString;
friend class TBufferFile;

friend TString operator+(const TString &s1, const TString &s2);
friend TString operator+(const TString &s, const char *cs);
Expand Down
37 changes: 3 additions & 34 deletions core/base/src/String.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,16 @@
#include "RConfig.h"
#include <string>
#include "TBuffer.h"
#include "TString.h"

namespace std {} using namespace std;

void std_string_streamer(TBuffer &b, void *objadd)
{
// Streamer function for std::string object.
string *obj = (string*)objadd;
Int_t nbig;
UChar_t nwh;
if (b.IsReading()) {
b >> nwh;
;
if (nwh == 0) {
obj->clear();
} else {
if( obj->size() ) {
// Insure that the underlying data storage is not shared
(*obj)[0] = '\0';
}
if (nwh == 255) {
b >> nbig;
obj->resize(nbig,'\0');
b.ReadFastArray((char*)obj->data(),nbig);
}
else {
obj->resize(nwh,'\0');
b.ReadFastArray((char*)obj->data(),nwh);
}
}
} else if ( obj ) {
nbig = obj->length();
if (nbig > 254) {
nwh = 255;
b << nwh;
b << nbig;
} else {
nwh = UChar_t(nbig);
b << nwh;
}
b.WriteFastArray(obj->data(),nbig);
b.ReadStdString(*(std::string*)objadd);
} else {
b.WriteStdString(*(std::string*)objadd);
}
}

Expand Down
31 changes: 2 additions & 29 deletions core/base/src/TString.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1286,37 +1286,10 @@ void TString::Streamer(TBuffer &b)
{
// Stream a string object.

Int_t nbig;
UChar_t nwh;
if (b.IsReading()) {
b >> nwh;
if (nwh == 0) {
UnLink();
Zero();
} else {
if (nwh == 255)
b >> nbig;
else
nbig = nwh;

Clobber(nbig);
char *data = GetPointer();
data[nbig] = 0;
SetSize(nbig);
b.ReadFastArray(data, nbig);
}
b.ReadTString(*this);
} else {
nbig = Length();
if (nbig > 254) {
nwh = 255;
b << nwh;
b << nbig;
} else {
nwh = UChar_t(nbig);
b << nwh;
}
const char *data = GetPointer();
b.WriteFastArray(data, nbig);
b.WriteTString(*this);
}
}

Expand Down
2 changes: 2 additions & 0 deletions io/io/inc/TBufferFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ class TBufferFile : public TBuffer {
virtual void ReadDouble(Double_t &d);
virtual void ReadCharP(Char_t *c);
virtual void ReadTString(TString &s);
virtual void ReadStdString(std::string &s);

virtual void WriteBool(Bool_t b);
virtual void WriteChar(Char_t c);
Expand All @@ -288,6 +289,7 @@ class TBufferFile : public TBuffer {
virtual void WriteDouble(Double_t d);
virtual void WriteCharP(const Char_t *c);
virtual void WriteTString(const TString &s);
virtual void WriteStdString(const std::string &s);

// Special basic ROOT objects and collections
virtual TProcessID *GetLastProcessID(TRefTable *reftable) const;
Expand Down
85 changes: 81 additions & 4 deletions io/io/src/TBufferFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <string.h>
#include <typeinfo>
#include <string>

#include "TFile.h"
#include "TBufferFile.h"
Expand Down Expand Up @@ -247,17 +248,93 @@ void TBufferFile::ReadLong(Long_t &l)
//_______________________________________________________________________
void TBufferFile::ReadTString(TString &s)
{
// Read string from TBuffer.
// Read TString from TBuffer.

s.Streamer(*this);
Int_t nbig;
UChar_t nwh;
*this >> nwh;
if (nwh == 0) {
s.UnLink();
s.Zero();
} else {
if (nwh == 255)
*this >> nbig;
else
nbig = nwh;

s.Clobber(nbig);
char *data = s.GetPointer();
data[nbig] = 0;
s.SetSize(nbig);
ReadFastArray(data, nbig);
}
}

//_______________________________________________________________________
void TBufferFile::WriteTString(const TString &s)
{
// Write string to TBuffer.
// Write TString to TBuffer.

Int_t nbig = s.Length();
UChar_t nwh;
if (nbig > 254) {
nwh = 255;
*this << nwh;
*this << nbig;
} else {
nwh = UChar_t(nbig);
*this << nwh;
}
const char *data = s.GetPointer();
WriteFastArray(data, nbig);
}

//_______________________________________________________________________
void TBufferFile::ReadStdString(std::string &s)
{
// Read std::string from TBuffer.

((TString&)s).Streamer(*this);
std::string *obj = &s;
Int_t nbig;
UChar_t nwh;
*this >> nwh;
if (nwh == 0) {
obj->clear();
} else {
if( obj->size() ) {
// Insure that the underlying data storage is not shared
(*obj)[0] = '\0';
}
if (nwh == 255) {
*this >> nbig;
obj->resize(nbig,'\0');
ReadFastArray((char*)obj->data(),nbig);
}
else {
obj->resize(nwh,'\0');
ReadFastArray((char*)obj->data(),nwh);
}
}
}

//_______________________________________________________________________
void TBufferFile::WriteStdString(const std::string &s)
{
// Write std::string to TBuffer.

if (s==0) return;
const std::string *obj = &s;
UChar_t nwh;
Int_t nbig = obj->length();
if (nbig > 254) {
nwh = 255;
*this << nwh;
*this << nbig;
} else {
nwh = UChar_t(nbig);
*this << nwh;
}
WriteFastArray(obj->data(),nbig);
}

//______________________________________________________________________________
Expand Down
4 changes: 3 additions & 1 deletion io/sql/inc/TBufferSQL2.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ friend class TSQLStructure;
virtual void ReadFloat(Float_t &f);
virtual void ReadDouble(Double_t &d);
virtual void ReadCharP(Char_t *c);
virtual void ReadTString(TString &s) ;
virtual void ReadTString(TString &s);
virtual void ReadStdString(std::string &s);

virtual void WriteBool(Bool_t b);
virtual void WriteChar(Char_t c);
Expand All @@ -303,6 +304,7 @@ friend class TSQLStructure;
virtual void WriteDouble(Double_t d);
virtual void WriteCharP(const Char_t *c);
virtual void WriteTString(const TString &s);
virtual void WriteStdString(const std::string &s);

virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object);
virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);
Expand Down
32 changes: 22 additions & 10 deletions io/sql/src/TBufferSQL2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2230,23 +2230,35 @@ void TBufferSQL2::ReadCharP(Char_t *c)
}

//________________________________________________________________________
void TBufferSQL2::ReadTString(TString &)
void TBufferSQL2::ReadTString(TString &s)
{
// Operator>>
// Read a TString

TBufferFile::ReadTString(s);
}

//________________________________________________________________________
void TBufferSQL2::WriteTString(const TString &s)
{
// Write a TString

//strcpy(str,(*fRowPtr)->GetField(*fIter));
//if (fIter != fColumnVec->end()) ++fIter;
printf("ERROR NOT IMPLEMENTED\n");
TBufferFile::WriteTString(s);
}

//________________________________________________________________________
void TBufferSQL2::ReadStdString(std::string &s)
{
// Read a std::string

TBufferFile::ReadStdString(s);
}

//________________________________________________________________________
void TBufferSQL2::WriteTString(const TString &)
void TBufferSQL2::WriteStdString(const std::string &s)
{
// Operator>>
// Write a std::string

//strcpy(str,(*fRowPtr)->GetField(*fIter));
//if (fIter != fColumnVec->end()) ++fIter;
printf("ERROR NOT IMPLEMENTED\n");
TBufferFile::WriteStdString(s);
}

// macro for right shift operator for basic types
Expand Down
8 changes: 7 additions & 1 deletion io/xml/inc/TBufferXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ friend class TKeyXML;

static TObject* ConvertFromXML(const char* str, Bool_t GenericLayout = kFALSE, Bool_t UseNamespaces = kFALSE);
static void* ConvertFromXMLAny(const char* str, TClass** cl = 0, Bool_t GenericLayout = kFALSE, Bool_t UseNamespaces = kFALSE);

Int_t GetIOVersion() const { return fIOVersion; }
void SetIOVersion(Int_t v) { fIOVersion = v; }

// suppress class writing/reading

Expand Down Expand Up @@ -200,6 +203,7 @@ friend class TKeyXML;
virtual void ReadDouble(Double_t &d);
virtual void ReadCharP(Char_t *c);
virtual void ReadTString(TString &s);
virtual void ReadStdString(std::string &s);

virtual void WriteBool(Bool_t b);
virtual void WriteChar(Char_t c);
Expand All @@ -216,6 +220,7 @@ friend class TKeyXML;
virtual void WriteDouble(Double_t d);
virtual void WriteCharP(const Char_t *c);
virtual void WriteTString(const TString &s);
virtual void WriteStdString(const std::string &s);

virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object);
virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);
Expand Down Expand Up @@ -334,10 +339,11 @@ friend class TKeyXML;
Bool_t fExpectedChain; //! flag to resolve situation when several elements of same basic type stored as FastArray
TClass* fExpectedBaseClass; //! pointer to class, which should be stored as parent of current
Int_t fCompressLevel; //! compression level and algorithm
Int_t fIOVersion; //! indicates format of ROOT xml file

static const char* fgFloatFmt; //! printf argument for floats and doubles, either "%f" or "%e" or "%10f" and so on

ClassDef(TBufferXML,1) //a specialized TBuffer to read/write to XML files
ClassDef(TBufferXML,2) //a specialized TBuffer to read/write to XML files
};

//______________________________________________________________________________
Expand Down
4 changes: 2 additions & 2 deletions io/xml/inc/TXMLFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ class TXMLFile : public TFile, public TXMLSetup {
Int_t fIOVersion; //! indicates format of ROOT xml file

Long64_t fKeyCounter; //! counter of created keys, used for keys id
ClassDef(TXMLFile, 2) //ROOT file in XML format

ClassDef(TXMLFile, 3) //ROOT file in XML format
};


Expand Down
Loading