18 Int_t TAttr::_debug = 0;
42 TString tk(key);tk.ToLower();tk.ReplaceAll(
" ",
"");tk.ReplaceAll(
"\t",
"");
44 TString tv(val);tv = tv.Strip(TString::kBoth) ;tv.ReplaceAll(
"\t",
"");
45 if (tv ==
".remove") {
46 TObject *t = FindObject(tk.Data());
47 if (t) {Remove(t);
delete t;}
49 TNamed *t =
new TNamed(tk.Data(),tv.Data());
54 Info(
"SetAttr",
"(\"%s\",\"%s\",\")",tk.Data(),tv.Data());
60 TListIter iter(att,kIterBackward);
61 int add=0;
const TNamed *tn=0;
62 while ((tn = (
const TNamed*)iter())) {AddFirst(
new TNamed(*tn));add++;}
68 TString ts; ts+=val;
SetAttr(key, ts.Data());
73 TString ts; ts+=val;
return SetAttr(key, ts.Data());
78 TString ts; ts+=val;
return SetAttr(key, ts.Data());
82 const char *TAttr::SAttr(
const char *key)
const
85 tey.ToLower(); tey.ReplaceAll(
" ",
""); tey.ReplaceAll(
"\t",
"");
86 TObject *att = FindObject(tey.Data());
88 int n = att->GetUniqueID();
89 att->SetUniqueID(n+1);
90 if (n<13) Info(
"Found",
"%s = %s\n",att->GetName(),att->GetTitle());
92 return (att)? att->GetTitle():
"";
95 Long_t TAttr::IAttr(
const char *key)
const
97 const char *val = SAttr(key);
98 if (!val || !val[0])
return 0;
99 if (isdigit(*val))
return strtol(val,0,10);
100 return strtoul(val,0,10);
103 ULong_t TAttr::UAttr(
const char *key)
const
105 return (UInt_t)IAttr(key);
108 double TAttr::DAttr(
const char *key)
const
110 const char *val = SAttr(key);
112 if (!val[0])
return 0;
113 return strtod(val,0);
116 void TAttr::PrintAttr()
const
118 if (!First())
return;
120 printf(
"PrintAttr() for %s::%s\n",ClassName(),GetName());
123 while ((
object = next())) {
125 printf(
" %2d - %s = %s\n",n,object->GetName(),
object->GetTitle());
127 printf(
"PrintAttr() ==============================================\n");
void SetAttr(const char *key, const char *val)