47 void RooNameSet::strdup(Int_t& dstlen,
char* &dstbuf,
const char* src)
49 dstlen = src ? std::strlen(src) : 0;
51 char *buf = dstlen ?
new char[dstlen] : 0;
52 if (buf) std::strcpy(buf, src);
60 RooNameSet::RooNameSet() : _len(0), _nameList(0)
67 RooNameSet::RooNameSet(
const RooArgSet& argSet) : _len(0), _nameList(0)
75 RooNameSet::RooNameSet(
const RooNameSet& other) :
76 TObject(other), RooPrintable(other), _len(0), _nameList(0)
78 strdup(_len, _nameList, other._nameList);
84 RooNameSet::~RooNameSet()
92 RooNameSet& RooNameSet::operator=(
const RooNameSet& other)
95 if (&other ==
this || _nameList == other._nameList)
return *
this;
97 strdup(_len, _nameList, other._nameList);
105 Bool_t RooNameSet::operator==(
const RooNameSet& other)
const
108 if (&other ==
this || _nameList == other._nameList)
return kTRUE;
110 return _nameList && other._nameList &&
111 0 == std::strcmp(_nameList, other._nameList);
116 Bool_t RooNameSet::operator<(
const RooNameSet& other)
const
118 if (&other ==
this)
return kFALSE;
119 if (!_nameList)
return other._nameList;
120 if (!other._nameList)
return kFALSE;
121 return std::strcmp(_nameList, other._nameList) < 0;
126 void RooNameSet::extendBuffer(Int_t inc)
129 assert(inc > 0 || _len >= -inc);
130 int newsz = _len + inc;
131 if (newsz <= 1 || !_len) newsz = 0;
132 char* newbuf = newsz ?
new char[newsz] : 0;
133 if (newbuf && _nameList) {
134 std::strncpy(newbuf, _nameList, std::min(_len, newsz));
135 newbuf[newsz - 1] = 0;
144 void RooNameSet::setNameList(
const char* givenList)
146 strdup(_len, _nameList, givenList);
152 void RooNameSet::refill(
const RooArgSet& argSet)
157 if (0 == argSet.getSize())
return;
159 RooArgList tmp(argSet);
163 for (RooFIter it = tmp.fwdIterator(); 0 != (arg = it.next());
164 _len += 1 + std::strlen(arg->GetName())) { }
165 if (_len <= 1) _len = 0;
167 _nameList = _len ?
new char[_len] : 0;
171 for (RooFIter it = tmp.fwdIterator(); 0 != (arg = it.next()); ) {
172 const char *name = arg->GetName();
173 std::strcpy(p, name);
187 RooArgSet* RooNameSet::select(
const RooArgSet& list)
const
189 RooArgSet* output =
new RooArgSet;
190 if (!_nameList || !std::strlen(_nameList))
return output;
195 strdup(dummy, tmp, _nameList);
197 char* token = std::strtok(tmp,
":");
199 RooAbsArg* arg = list.find(token);
200 if (arg) output->add(*arg);
201 token = std::strtok(0,
":");
211 void RooNameSet::printName(std::ostream& os)
const
219 void RooNameSet::printTitle(std::ostream& os)
const
227 void RooNameSet::printClassName(std::ostream& os)
const
229 os << IsA()->GetName();
235 void RooNameSet::printValue(std::ostream& os)
const