44 if(number>= std::numeric_limits<Int>::max())
return "inf";
45 if(number<= std::numeric_limits<Int>::min()+1)
return "-inf";
47 std::stringstream sstr;
56 std::stringstream sstr;
57 sstr <<
"0x" << std::setbase(16) << number;
65 if(number>= std::numeric_limits<Float>::max())
return "inf";
66 if(number<= -1*std::numeric_limits<Float>::max())
return "-inf";
67 std::stringstream sstr;
68 if(number == static_cast<Float>( static_cast<Int>(number) )) {
69 sstr << static_cast<Int>(number);
80 std::string
ExpandString(
const std::string& rString,
unsigned int len) {
83 std::string::size_type xtra = (std::string::size_type) len - rString.length();
84 if ((xtra > 0) && (xtra < 10000)) {
85 res.append(xtra,
' ');
91 std::string
CollapsString(
const std::string& rString,
unsigned int len) {
92 if(len <=1)
return rString;
93 if(rString.length() <= len)
return rString;
95 int ctail = len-chead;
96 return rString.substr(0,chead) +
"..." + rString.substr(rString.length()-ctail,ctail);
102 unsigned long ul = strtoul (rString.c_str(), &end, 0);
103 unsigned long idxmax = std::numeric_limits<Idx>::max();
105 throw Exception(
"atoidx",
"Idx overflow", 600);
111 std::string
StringSubstitute(
const std::string& rString,
const std::string& rFrom,
const std::string& rTo) {
116 while(pos<rString.length()) {
117 std::size_t next=rString.find(rFrom,pos);
118 if(next==std::string::npos)
break;
119 res.append(rString.substr(pos, next-pos));
121 pos=next+rFrom.length();
124 if(pos<rString.length())
125 res.append(rString.substr(pos));
132 return std::string(FAUDES_VERSION);
137 return std::string(FAUDES_PLUGINS);
143 "Ramon Barakat, Ruediger Berndt, Christian Breindl, Christine Baier, Tobias Barthel, Christoph Doerr, Marc Duevel, Norman Franchi, Rainer Hartmann, Jochen Hellenschmidt, Stefan Jacobi, Matthias Leinfelder, Tomas Masopust, Michael Meyer, Andreas Mohr, Thomas Moor, Mihai Musunoi, Bernd Opitz, Katja Pelaic, Irmgard Petzoldt, Sebastian Perk, Thomas Rempel, Daniel Ritter, Berno Schlein, Ece Schmidt, Klaus Schmidt, Anne-Kathrin Schmuck, Sven Schneider, Matthias Singer, Ulas Turan, Christian Wamser, Zhengying Wang, Thomas Wittmann, Shi Xiaoxun, Jorgos Zaddach, Hao Zhou, Christian Zwick, et al";
149 const std::string& rOutFile,
const std::string& rOutFormat,
const std::string& rDotExec)
151 std::string format=rOutFormat;
154 if(rOutFile.rfind(
'.')+1 < rOutFile.size()) {
155 format=rOutFile.substr(rOutFile.rfind(
'.')+1);
159 if (format ==
"canon");
160 else if (format ==
"dot");
161 else if (format ==
"xdot");
162 else if (format ==
"cmap");
163 else if (format ==
"dia");
164 else if (format ==
"fig");
165 else if (format ==
"gd");
166 else if (format ==
"gd2");
167 else if (format ==
"gif");
168 else if (format ==
"hpgl");
169 else if (format ==
"imap");
170 else if (format ==
"cmapx");
171 else if (format ==
"ismap");
172 else if (format ==
"jpg");
173 else if (format ==
"jpeg");
174 else if (format ==
"mif");
175 else if (format ==
"mp");
176 else if (format ==
"pcl");
177 else if (format ==
"pic");
178 else if (format ==
"plain");
179 else if (format ==
"plain-ext");
180 else if (format ==
"png");
181 else if (format ==
"ps");
182 else if (format ==
"ps2");
183 else if (format ==
"svg");
184 else if (format ==
"svgz");
185 else if (format ==
"vrml");
186 else if (format ==
"vtx");
187 else if (format ==
"wbmp");
188 else if (format ==
"eps");
189 else if (format ==
"pdf");
191 std::stringstream errstr;
192 errstr <<
"Dot output format \"" << format <<
"\" unknown";
193 throw Exception(
"faudes::ProcessDot", errstr.str(), 3);
195 std::string dotcommand = rDotExec +
" -T"+format+
" \""+rDotFile+
"\" -o \""+rOutFile+
"\"";
196 if(system(dotcommand.c_str()) != 0) {
198 "Error in running " + dotcommand, 3);
206 char filename[]=
"faudes_temp_XXXXXX";
211 filedes= mkstemp(filename);
213 FD_DF(
"faudes::CreateTempFile(): error");
217 res=std::string(filename);
219 #ifdef FAUDES_WINDOWS
235 char* tmpname = _mktemp(filename);
238 FD_DF(
"faudes::CreateTempFile(): error");
241 fopen_s(&file,tmpname,
"w");
243 FD_DF(
"faudes::CreateTempFile(): error");
247 res=std::string(tmpname);
249 FD_DF(
"faudes::CreateTempFile(): " << res);
257 return std::remove(rFileName.c_str()) == 0;
265 if(seppos==std::string::npos)
return res;
266 res=rFullPath.substr(0,seppos+1);
272 std::string res=rFullPath;
274 if(seppos==std::string::npos)
return res;
275 res=rFullPath.substr(seppos+1);
281 std::string res=rFullPath;
283 if(seppos!=std::string::npos) {
284 res=res.substr(seppos+1);
286 std::size_t dotpos = res.find_last_of(
".");
287 if(dotpos!=std::string::npos) {
288 res=res.substr(0,dotpos);
295 std::string res=rFullPath;
297 if(seppos!=std::string::npos) {
298 res=res.substr(seppos+1);
300 std::size_t dotpos = res.find_last_of(
".");
301 if(dotpos!=std::string::npos)
302 if(dotpos +1 < res.size()) {
303 return res.substr(dotpos+1,res.size()-dotpos-1);
305 return std::string();
309 std::string
PrependDirectory(
const std::string& rDirectory,
const std::string& rFileName) {
310 std::string res=rDirectory;
313 if(res.at(res.length()-1)!=sepchar)
314 res.append(1,sepchar);
315 res.append(rFileName);
323 thedir=opendir(rDirectory.c_str());
324 if(thedir) closedir(thedir);
327 #ifdef FAUDES_WINDOWS
328 DWORD fattr = GetFileAttributesA(rDirectory.c_str());
330 (fattr!=INVALID_FILE_ATTRIBUTES) && (fattr & FILE_ATTRIBUTE_DIRECTORY);
337 std::set< std::string > res;
340 struct dirent *theent;
341 thedir=opendir(rDirectory.c_str());
342 if(!thedir)
return res;
343 while((theent=readdir(thedir))) {
344 std::string fname(theent->d_name);
345 if(fname==
".")
continue;
346 if(fname==
"..")
continue;
351 #ifdef FAUDES_WINDOWS
353 WIN32_FIND_DATA data;
354 hf = FindFirstFile((rDirectory+
"\\*.*").c_str(), &data);
355 if (hf != INVALID_HANDLE_VALUE) {
357 std::string fname(data.cFileName);
358 if(fname==
".")
continue;
359 if(fname==
"..")
continue;
361 }
while (FindNextFile(hf, &data));
375 fp.open(rFilename.c_str(), std::ios::in | std::ios::binary);
381 return remove(rFilename.c_str()) == 0;
385 bool FileCopy(
const std::string& rFromFile,
const std::string& rToFile) {
386 std::ifstream froms(rFromFile.c_str(), std::ios::binary);
387 std::ofstream tos(rToFile.c_str(), std::ios::binary);
388 tos << froms.rdbuf();
390 return !(froms.fail() || tos.fail());
424 DoWrite(message,cntnow,cntdone);
427 (void) cntnow; (void) cntdone;
429 if(!sout) sout=&std::cout;
444 mspCount=
new std::map<std::string,long int>();
445 mspMax=
new std::map<std::string,long int>();
453 long int cnt = ((*mspCount)[rTypeName]+=1);
458 (*mspCount)[rTypeName]-=1;
464 #ifdef FAUDES_DEBUG_CODE
472 std::map<std::string,long int>::iterator cit;
482 #ifdef FAUDES_DEBUG_CODE
484 class ExitFunctionInstall {
487 static ExitFunctionInstall mInstance;
488 ExitFunctionInstall(
void) {
496 bool ExitFunctionInstall::mDone=
false;
497 ExitFunctionInstall ExitFunctionInstall::mInstance;
508 std::string filename=rSource;
510 if(filename==
"") filename=
"faudes_dump";
514 std::string::size_type pos=0;
515 for(;pos<filename.length();pos++)
516 if(filename.at(pos)==
'.') filename.at(pos)=
'_';
518 filename.append(
".prot");
522 filename.insert(0,
"tmp_");
548 void TestProtocol(
const std::string& rMessage,
const std::string& rData) {
563 fp.open(prot.c_str(), std::ios::in | std::ios::binary);
571 fr.open(ref.c_str(), std::ios::in | std::ios::binary);
575 fr.open(ref.c_str(), std::ios::in | std::ios::binary);
590 if(fp.eof() && fr.eof()) {
break; }
591 if(!fp.good() || !fr.good()) { dline=cline;
break;}
593 if( cp==
'\r' && cr ==
'\r')
continue;
594 if( cp==
'\r' && fp.eof()){ dline=cline;
break;}
595 if( cp==
'\r') cp = fp.get();
596 if( cr==
'\r' && fr.eof()){ dline=cline;
break;}
597 if( cr==
'\r') cr = fr.get();
599 if( cr==
'\n') cline++;
601 if( cp!= cr ){dline=cline;
break;}
603 }
catch(std::ios::failure&) {
630 throw Exception(
"LoopCallback",
"break on application request", 110);