String.cxx

Go to the documentation of this file.
00001 // @(#)root/base:$Id: String.cxx 36061 2010-10-04 16:05:51Z pcanal $
00002 // Author: Philippe Canal 03/09/2003
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun, Fons Rademakers and al.           *
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 // std::string helper utilities                                         //
00015 //                                                                      //
00016 //////////////////////////////////////////////////////////////////////////
00017 
00018 #include "RConfig.h"
00019 #include <string>
00020 #include "TBuffer.h"
00021 #include "TString.h"
00022 
00023 namespace std {} using namespace std;
00024 
00025 void std_string_streamer(TBuffer &b, void *objadd) 
00026 {
00027    // Streamer function for std::string object.
00028    string *obj = (string*)objadd;
00029    Int_t   nbig;
00030    UChar_t nwh;
00031    if (b.IsReading()) {
00032       b >> nwh;
00033       ;
00034       if (nwh == 0)  {
00035          obj->clear();
00036       } else {
00037          if( obj->size() ) {
00038             // Insure that the underlying data storage is not shared
00039             (*obj)[0] = '\0';
00040          }
00041          if (nwh == 255)  {
00042             b >> nbig;
00043             obj->resize(nbig,'\0');
00044             b.ReadFastArray((char*)obj->data(),nbig);
00045          }
00046          else  {
00047             obj->resize(nwh,'\0');
00048             b.ReadFastArray((char*)obj->data(),nwh);
00049          }
00050       }
00051    } else if ( obj ) {
00052       nbig = obj->length();
00053       if (nbig > 254) {
00054          nwh = 255;
00055          b << nwh;
00056          b << nbig;
00057       } else {
00058          nwh = UChar_t(nbig);
00059          b << nwh;
00060       }
00061       b.WriteFastArray(obj->data(),nbig);
00062    }
00063 }
00064 
00065 // Declare the streamer to the string TClass object
00066 RootStreamer(string,std_string_streamer);
00067 
00068 // Set a version number of the string TClass object
00069 RootClassVersion(string,2);
00070 
00071 

Generated on Tue Jul 5 14:11:18 2011 for ROOT_528-00b_version by  doxygen 1.5.1