// RooStringVar implements a string values RooAbsArg
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "TObjString.h"
#include "TTree.h"
#include "RooStringVar.h"
#include "RooStreamParser.h"
#include "RooMsgService.h"
ClassImp(RooStringVar)
RooStringVar::RooStringVar(const char *name, const char *title, const char* value, Int_t size) :
RooAbsString(name, title, size)
{
if(!isValidString(value)) {
coutW(InputArguments) << "RooStringVar::RooStringVar(" << GetName()
<< "): initial contents too long and ignored" << endl ;
} else {
strcpy(_value,value) ;
}
setValueDirty() ;
setShapeDirty() ;
}
RooStringVar::RooStringVar(const RooStringVar& other, const char* name) :
RooAbsString(other, name)
{
}
RooStringVar::~RooStringVar()
{
}
RooStringVar::operator TString()
{
return TString(_value) ;
}
void RooStringVar::setVal(const char* value)
{
if (!isValidString(value)) {
coutW(InputArguments) << "RooStringVar::setVal(" << GetName() << "): new string too long and ignored" << endl ;
} else {
if (value) {
strcpy(_value,value) ;
} else {
_value[0] = 0 ;
}
}
}
RooAbsArg& RooStringVar::operator=(const char* newValue)
{
if (!isValidString(newValue)) {
coutW(InputArguments) << "RooStringVar::operator=(" << GetName() << "): new string too long and ignored" << endl ;
} else {
if (newValue) {
strcpy(_value,newValue) ;
} else {
_value[0] = 0 ;
}
}
return *this ;
}
Bool_t RooStringVar::readFromStream(istream& is, Bool_t compact, Bool_t verbose)
{
TString token,errorPrefix("RooStringVar::readFromStream(") ;
errorPrefix.Append(GetName()) ;
errorPrefix.Append(")") ;
RooStreamParser parser(is,errorPrefix) ;
TString newValue ;
Bool_t ret(kFALSE) ;
if (compact) {
parser.readString(newValue,kTRUE) ;
} else {
newValue = parser.readLine() ;
}
if (!isValidString(newValue)) {
if (verbose)
coutW(InputArguments) << "RooStringVar::readFromStream(" << GetName()
<< "): new string too long and ignored" << endl ;
} else {
strcpy(_value,newValue) ;
}
return ret ;
}
void RooStringVar::writeToStream(ostream& os, Bool_t ) const
{
os << getVal() ;
}
Last change: Wed Jun 25 08:34:19 2008
Last generated: 2008-06-25 08:34
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.