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, Stefan Goetz, 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, Yiheng Tang, Ulas Turan, Christian Wamser, Zhengying Wang, Thomas Wittmann, Shi Xiaoxun, Yang Yi, Jorgos Zaddach, Hao Zhou, Christian Zwick, et al";
149 #ifdef FAUDES_BUILDENV
150 res = res + std::string(FAUDES_BUILDENV);
152 res = res + std::string(
"generic");
154 #ifdef FAUDES_BUILDTIME
155 res = res + std::string(
" ") + std::string(FAUDES_BUILDTIME);
157 res = res + std::string(
" ") + std::string(FAUDES_CONFIG_TIMESTAMP);
165 const std::string& rOutFile,
const std::string& rOutFormat,
const std::string& rDotExec)
167 std::string format=rOutFormat;
170 if(rOutFile.rfind(
'.')+1 < rOutFile.size()) {
171 format=rOutFile.substr(rOutFile.rfind(
'.')+1);
175 if (format ==
"canon");
176 else if (format ==
"dot");
177 else if (format ==
"xdot");
178 else if (format ==
"cmap");
179 else if (format ==
"dia");
180 else if (format ==
"fig");
181 else if (format ==
"gd");
182 else if (format ==
"gd2");
183 else if (format ==
"gif");
184 else if (format ==
"hpgl");
185 else if (format ==
"imap");
186 else if (format ==
"cmapx");
187 else if (format ==
"ismap");
188 else if (format ==
"jpg");
189 else if (format ==
"jpeg");
190 else if (format ==
"mif");
191 else if (format ==
"mp");
192 else if (format ==
"pcl");
193 else if (format ==
"pic");
194 else if (format ==
"plain");
195 else if (format ==
"plain-ext");
196 else if (format ==
"png");
197 else if (format ==
"ps");
198 else if (format ==
"ps2");
199 else if (format ==
"svg");
200 else if (format ==
"svgz");
201 else if (format ==
"vrml");
202 else if (format ==
"vtx");
203 else if (format ==
"wbmp");
204 else if (format ==
"eps");
205 else if (format ==
"pdf");
207 std::stringstream errstr;
208 errstr <<
"Dot output format \"" << format <<
"\" unknown";
209 throw Exception(
"faudes::ProcessDot", errstr.str(), 3);
211 std::string dotcommand = rDotExec +
" -T"+format+
" \""+rDotFile+
"\" -o \""+rOutFile+
"\"";
212 if(system(dotcommand.c_str()) != 0) {
214 "Error in running " + dotcommand, 3);
222 char filename[]=
"faudes_temp_XXXXXX";
227 filedes= mkstemp(filename);
229 FD_DF(
"faudes::CreateTempFile(): error");
233 res=std::string(filename);
235 #ifdef FAUDES_WINDOWS
251 char* tmpname = _mktemp(filename);
254 FD_DF(
"faudes::CreateTempFile(): error");
257 fopen_s(&file,tmpname,
"w");
259 FD_DF(
"faudes::CreateTempFile(): error");
263 res=std::string(tmpname);
265 FD_DF(
"faudes::CreateTempFile(): " << res);
275 if(seppos==std::string::npos)
return res;
276 res=rFullPath.substr(0,seppos+1);
282 std::string res=rFullPath;
284 if(seppos==std::string::npos)
return res;
285 res=rFullPath.substr(seppos+1);
291 std::string res=rFullPath;
293 if(seppos!=std::string::npos) {
294 res=res.substr(seppos+1);
296 std::size_t dotpos = res.find_last_of(
".");
297 if(dotpos!=std::string::npos) {
298 res=res.substr(0,dotpos);
305 std::string res=rFullPath;
307 if(seppos!=std::string::npos) {
308 res=res.substr(seppos+1);
310 std::size_t dotpos = res.find_last_of(
".");
311 if(dotpos!=std::string::npos)
312 if(dotpos +1 < res.size()) {
313 return res.substr(dotpos+1,res.size()-dotpos-1);
315 return std::string();
319 std::string
PrependPath(
const std::string& rLeft,
const std::string& rRight) {
322 return std::string(rRight);
324 return std::string(rLeft);
330 if(seppos!=std::string::npos)
331 sepchar=rLeft.at(seppos);
333 std::string res=rLeft;
334 if(res.at(res.length()-1)!=sepchar)
335 res.append(1,sepchar);
336 if(rRight.at(0)!=sepchar){
340 if(rRight.length()<=1) {
343 res.append(rRight,1,std::string::npos);
351 thedir=opendir(rDirectory.c_str());
352 if(thedir) closedir(thedir);
355 #ifdef FAUDES_WINDOWS
356 DWORD fattr = GetFileAttributesA(rDirectory.c_str());
358 (fattr!=INVALID_FILE_ATTRIBUTES) && (fattr & FILE_ATTRIBUTE_DIRECTORY);
365 std::set< std::string > res;
368 struct dirent *theent;
369 thedir=opendir(rDirectory.c_str());
370 if(!thedir)
return res;
371 while((theent=readdir(thedir))) {
372 std::string fname(theent->d_name);
373 if(fname==
".")
continue;
374 if(fname==
"..")
continue;
379 #ifdef FAUDES_WINDOWS
381 WIN32_FIND_DATA data;
382 hf = FindFirstFile((rDirectory+
"\\*.*").c_str(), &data);
383 if (hf != INVALID_HANDLE_VALUE) {
385 std::string fname(data.cFileName);
386 if(fname==
".")
continue;
387 if(fname==
"..")
continue;
389 }
while (FindNextFile(hf, &data));
403 fp.open(rFilename.c_str(), std::ios::in | std::ios::binary);
409 return remove(rFilename.c_str()) == 0;
413 bool FileCopy(
const std::string& rFromFile,
const std::string& rToFile) {
414 std::ifstream froms(rFromFile.c_str(), std::ios::binary);
415 std::ofstream tos(rToFile.c_str(), std::ios::binary);
416 tos << froms.rdbuf();
418 return !(froms.fail() || tos.fail());
450 void ConsoleOut::Write(
const std::string& message,
long int cntnow,
long int cntdone,
int verb) {
452 if(
mVerb<verb)
return;
453 DoWrite(message,cntnow,cntdone,verb);
456 (void) cntnow; (void) cntdone; (void) verb;
458 if(!sout) sout=&std::cout;
473 mspCount=
new std::map<std::string,long int>();
474 mspMax=
new std::map<std::string,long int>();
482 long int cnt = ((*mspCount)[rTypeName]+=1);
487 (*mspCount)[rTypeName]-=1;
493 #ifdef FAUDES_DEBUG_CODE
501 std::map<std::string,long int>::iterator cit;
511 #ifdef FAUDES_DEBUG_CODE
513 class ExitFunctionInstall {
516 static ExitFunctionInstall mInstance;
517 ExitFunctionInstall(
void) {
525 bool ExitFunctionInstall::mDone=
false;
526 ExitFunctionInstall ExitFunctionInstall::mInstance;
537 std::string filename=rSource;
539 if(filename==
"") filename=
"faudes_dump";
543 std::string::size_type pos=0;
544 for(;pos<filename.length();pos++)
545 if(filename.at(pos)==
'.') filename.at(pos)=
'_';
547 filename.append(
".prot");
551 filename.insert(0,
"tmp_");
577 void TestProtocol(
const std::string& rMessage,
const std::string& rData) {
592 fp.open(prot.c_str(), std::ios::in | std::ios::binary);
600 fr.open(ref.c_str(), std::ios::in | std::ios::binary);
604 fr.open(ref.c_str(), std::ios::in | std::ios::binary);
619 if(fp.eof() && fr.eof()) {
break; }
620 if(!fp.good() || !fr.good()) { dline=cline;
break;}
622 if( cp==
'\r' && cr ==
'\r')
continue;
623 if( cp==
'\r' && fp.eof()){ dline=cline;
break;}
624 if( cp==
'\r') cp = fp.get();
625 if( cr==
'\r' && fr.eof()){ dline=cline;
break;}
626 if( cr==
'\r') cr = fr.get();
628 if( cr==
'\n') cline++;
630 if( cp!= cr ){dline=cline;
break;}
632 }
catch(std::ios::failure&) {
659 throw Exception(
"LoopCallback",
"break on application request", 110);
#define FAUDES_WRITE_CONSOLE(message)
static ConsoleOut * G(void)
virtual void DoWrite(const std::string &message, long int cntnow=0, long int cntdone=0, int verb=0)
virtual void Write(const std::string &message, long int cntnow=0, long int cntdone=0, int verb=0)
static ConsoleOut * smpInstance
virtual ~ConsoleOut(void)
const std::string & Filename(void)
void Redirect(ConsoleOut *out)
void ToFile(const std::string &filename)
static void Inc(const std::string &rTypeName)
static void Dec(const std::string &rTypeName)
static std::map< std::string, long int > * mspCount
static std::map< std::string, long int > * mspMax
std::string FileName(void) const
void WriteComment(const std::string &rComment)
void Write(const Type *pContext=0) const
void SWrite(TokenWriter &rTw) const
std::string VersionString()
std::string ExtractDirectory(const std::string &rFullPath)
void LoopCallback(bool pBreak(void))
std::string PrependPath(const std::string &rLeft, const std::string &rRight)
Idx ToIdx(const std::string &rString)
TokenWriter * gTestProtocolTw
void ProcessDot(const std::string &rDotFile, const std::string &rOutFile, const std::string &rOutFormat, const std::string &rDotExec)
std::string CreateTempFile(void)
bool FileCopy(const std::string &rFromFile, const std::string &rToFile)
std::string PluginsString()
std::string ExpandString(const std::string &rString, unsigned int len)
static bool(* gBreakFnct)(void)=0
std::string BuildString()
bool FileDelete(const std::string &rFilename)
std::string ToStringFloat(Float number)
std::string ExtractFilename(const std::string &rFullPath)
std::string ToStringInteger16(Int number)
std::string ContributorsString()
std::string ToStringInteger(Int number)
std::set< std::string > ReadDirectory(const std::string &rDirectory)
std::string StringSubstitute(const std::string &rString, const std::string &rFrom, const std::string &rTo)
std::string gTestProtocolFr
std::string ExtractBasename(const std::string &rFullPath)
bool DirectoryExists(const std::string &rDirectory)
std::string TestProtocol(const std::string &rSource)
bool FileExists(const std::string &rFilename)
std::string ExtractSuffix(const std::string &rFullPath)
std::string CollapsString(const std::string &rString, unsigned int len)