28 fName=
"FairGenericParIo";
34 if (!
pFile) {
return kFALSE; }
36 if (pPar->InheritsFrom(
"FairParGenericSet")) {
42 Error(
"init(FairParSet*)",
43 "%s does not inherit from FairParGenericSet",pPar->GetName());
50 if (!
pFile) {
return -1; }
51 if (pPar->InheritsFrom(
"FairParGenericSet")) {
54 Error(
"write(FairParSet*)",
55 "%s does not inherit from FairParGenericSet",pPar->GetName());
60 type
t,
const Char_t* format,TString& line, Int_t&
length)
63 const Int_t st=
sizeof(
t);
64 const Int_t maxbuf=8000;
65 const Int_t bufSizeExt=10000*st;
69 Int_t l=0, bufSize=bufSizeExt;
70 UChar_t* val=
new UChar_t[bufSize];
71 Ssiz_t
m=line.Last(
'\\');
73 sscanf(line.Data(),format,&
t);
74 memcpy(&val[l],&t,st);
78 pFile->getline(buf,maxbuf);
79 if (buf[0]!=
'/' && buf[0]!=
'#') {
82 if (m>0) { s=
s(0,s.Length()-2); }
83 if ((bufSize-1000)<l) {
85 UChar_t* va=
new UChar_t[bufSize];
90 Char_t* ss=strtok((Char_t*)s.Data(),
d);
93 memcpy(&val[l],&t,st);
98 }
while (buf[0]!=
'#' && !
pFile->eof() && m>0);
125 if (!
pFile) {
return kFALSE; }
127 pFile->seekg(0,ios::beg);
128 Text_t*
name=(Char_t*)pPar->GetName();
131 const Int_t maxbuf=8000;
134 TString
s, pName, pVal, pType;
136 while (buf[0]!=
'#' && !
pFile->eof()) {
137 pFile->getline(buf,maxbuf);
138 if (buf[0]!=
'/' && buf[0]!=
'#') {
142 Error(
"readCond(FairParGenericSet*)",
143 "%s:\n Missing backslash for parameter %s",name,pName.Data());
148 s=
s(n+1,s.Length()-n-1);
149 s=s.Strip(s.kLeading);
150 if (pName.CompareTo(
"author")==0 || pName.CompareTo(
"description")==0) {
158 pFile->getline(buf,maxbuf);
171 if (pName.CompareTo(
"author")==0) {
173 }
else if (pName.CompareTo(
"description")==0) {
179 s=
s(n+1,s.Length()-n-1);
180 s=s.Strip(s.kLeading);
181 if (pType.CompareTo(
"Text_t")==0) {
188 pFile->getline(buf,maxbuf);
201 pVal=pVal.Strip(pVal.kLeading);
202 if (pVal.Length()>0) {
203 paramList->
add(pName.Data(),pVal.Data());
206 const UChar_t* val=0;
208 if (pType.CompareTo(
"Int_t")==0) {
211 }
else if (pType.CompareTo(
"Float_t")==0) {
214 }
else if (pType.CompareTo(
"Double_t")==0) {
217 }
else if (pType.CompareTo(
"Char_t")==0) {
221 Error(
"readCond(FairParGenericSet*)",
222 "%s:\n Parameter %s with unsupported type %s",
223 name,pName.Data(),pType.Data());
230 memcpy(pValue,val,length);
231 paramList->
getList()->Add(obj);
232 if (val) {
delete [] val; }
237 Bool_t allFound=pPar->
getParams(paramList);
241 printf(
"%s initialized from Ascii file\n",name);
253 const Text_t* name=pPar->GetName();
256 *
pFile<<
"# Class: "<<name<<
"\n# Context: "<<context<<
"\n";
258 *
pFile<<
"["<<name<<
"]\n";
260 *
pFile<<
"//-----------------------------------------------------------"
261 "-----------------\n";
264 TList* pList=paramList->
getList();
270 if (po->
isBasicType()&&strcmp(pType,
"UChar_t")!=0) {
271 if (strcmp(pType,
"Text_t")==0) {
272 TString val((Char_t*)pValue,po->
getLength());
273 val.ReplaceAll(
"\n",
" \\\n");
274 *
pFile<<po->GetName()<<
": "<<pType<<
" \\\n "<<val.Data()<<std::endl;
278 *
pFile<<po->GetName()<<
": "<<pType<<
" ";
280 *
pFile<<po->GetName()<<
": "<<pType<<
" \\\n ";
282 if (strcmp(pType,
"Char_t")==0) {
284 }
else if (strcmp(pType,
"Int_t")==0) {
286 }
else if (strcmp(pType,
"Float_t")==0) {
288 }
else if (strcmp(pType,
"Double_t")==0) {
293 Error(
"writeCond(FairParGenericSet*)",
294 "Type %s of parameter %s not supported by ASCII I/O",
295 pType,po->GetName());
304 Error(
"writeCond(FairParGenericSet*)",
305 "Output is not writable");