cfl_utils.cpp
Go to the documentation of this file.
1 /** @file cfl_utils.cpp C-level utility functions */
2 
3 /* FAU Discrete Event Systems Library (libfaudes)
4 
5  Copyright (C) 2006 Bernd Opitz
6  Copyright (C) 2008-2010 Thomas Moor
7  Exclusive copyright is granted to Klaus Schmidt
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 */
24 
25 
26 #include "cfl_utils.h"
27 
28 
29 // Debug includes
30 #include "cfl_attributes.h"
31 #include "cfl_registry.h"
32 #include "cfl_types.h"
33 #include "cfl_elementary.h"
34 
35 
36 // c++ file io
37 #include <fstream>
38 
39 
40 namespace faudes {
41 
42 // ToStringInteger(number)
43 std::string ToStringInteger(Int number) {
44  if(number>= std::numeric_limits<Int>::max()) return "inf";
45  if(number<= std::numeric_limits<Int>::min()+1) return "-inf";
46  std::string res;
47  std::stringstream sstr;
48  sstr << number;
49  sstr >> res;
50  return res;
51 }
52 
53 // ToStringInteger16(number)
54 std::string ToStringInteger16(Int number) {
55  std::string res;
56  std::stringstream sstr;
57  sstr << "0x" << std::setbase(16) << number;
58  sstr >> res;
59  return res;
60 }
61 
62 // ToStringFloat(number)
63 // todo: check range, prevent sci notation
64 std::string ToStringFloat(Float 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);
70  } else {
71  sstr << std::fixed;
72  sstr << number;
73  }
74  std::string res;
75  sstr >> res;
76  return res;
77 }
78 
79 // ExpandString(rString, len)
80 std::string ExpandString(const std::string& rString, unsigned int len) {
81  std::string res;
82  res = rString;
83  std::string::size_type xtra = (std::string::size_type) len - rString.length();
84  if ((xtra > 0) && (xtra < 10000)) {
85  res.append(xtra, ' ');
86  }
87  return res;
88 }
89 
90 // CollapseString(rString, len)
91 std::string CollapsString(const std::string& rString, unsigned int len) {
92  if(len <=1) return rString;
93  if(rString.length() <= len) return rString;
94  int chead = len/2;
95  int ctail = len-chead;
96  return rString.substr(0,chead) + "..." + rString.substr(rString.length()-ctail,ctail);
97 }
98 
99 // ToIdx(rString)
100 Idx ToIdx(const std::string& rString) {
101  char * end;
102  unsigned long ul = strtoul (rString.c_str(), &end, 0);
103  unsigned long idxmax = std::numeric_limits<Idx>::max();
104  if(ul > idxmax) {
105  throw Exception("atoidx", "Idx overflow", 600);
106  }
107  return (Idx) ul;
108 }
109 
110 // String Substitution
111 std::string StringSubstitute(const std::string& rString,const std::string& rFrom,const std::string& rTo) {
112  // prep result
113  std::string res;
114  std::size_t pos=0;
115  // loop over occurences of "from"
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));
120  res.append(rTo);
121  pos=next+rFrom.length();
122  }
123  // get end
124  if(pos<rString.length())
125  res.append(rString.substr(pos));
126  // done
127  return res;
128 }
129 
130 // VersionString()
131 std::string VersionString() {
132  return std::string(FAUDES_VERSION);
133 }
134 
135 // FDPluginsString()
136 std::string PluginsString() {
137  return std::string(FAUDES_PLUGINS);
138 }
139 
140 // FDContributorsString()
141 std::string ContributorsString() {
142  return
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";
144 }
145 
146 
147 // ProcessDot(infile,outfile,format)
148 void ProcessDot(const std::string& rDotFile,
149  const std::string& rOutFile, const std::string& rOutFormat, const std::string& rDotExec)
150 {
151  std::string format=rOutFormat;
152  // guess format from filename
153  if(format=="") {
154  if(rOutFile.rfind('.')+1 < rOutFile.size()) {
155  format=rOutFile.substr(rOutFile.rfind('.')+1);
156  }
157  }
158  // test format
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");
190  else {
191  std::stringstream errstr;
192  errstr << "Dot output format \"" << format << "\" unknown";
193  throw Exception("faudes::ProcessDot", errstr.str(), 3);
194  }
195  std::string dotcommand = rDotExec + " -T"+format+" \""+rDotFile+"\" -o \""+rOutFile+"\"";
196  if(system(dotcommand.c_str()) != 0) {
197  throw Exception("faudes::ProcessDot",
198  "Error in running " + dotcommand, 3);
199  }
200 }
201 
202 
203 // CreateTempFile(void)
204 // todo: sys dependant, report, investigate threads
205 std::string CreateTempFile(void) {
206  char filename[]= "faudes_temp_XXXXXX";
207  std::string res;
208 #ifdef FAUDES_POSIX
209  // use mkstemp on recent Posix systems
210  int filedes = -1;
211  filedes= mkstemp(filename);
212  if(filedes==-1) {
213  FD_DF("faudes::CreateTempFile(): error");
214  return res;
215  }
216  close(filedes);
217  res=std::string(filename);
218 #endif
219 #ifdef FAUDES_WINDOWS
220  // mimique mkstemp on Windows/MinGW
221  /*
222  int filedes = -1;
223  #define _S_IREAD 256
224  #define _S_IWRITE 128
225  mktemp(filename);
226  filedes=open(filename,O_RDWR|O_BINARY|O_CREAT|O_EXCL|_O_SHORT_LIVED, _S_IREAD|_S_IWRITE);
227  if(filedes==-1) {
228  FD_DF("faudes::CreateTempFile(): error");
229  return "";
230  }
231  close(filedes);
232  res=std::string(filename);
233  */
234  // win32 API
235  char* tmpname = _mktemp(filename);
236  FILE* file;
237  if(tmpname==NULL) {
238  FD_DF("faudes::CreateTempFile(): error");
239  return res;
240  }
241  fopen_s(&file,tmpname,"w");
242  if(file==NULL) {
243  FD_DF("faudes::CreateTempFile(): error");
244  return "";
245  }
246  fclose(file);
247  res=std::string(tmpname);
248 #endif
249  FD_DF("faudes::CreateTempFile(): " << res);
250  return(res);
251 }
252 
253 
254 
255 // ExtractPath
256 std::string ExtractDirectory(const std::string& rFullPath) {
257  std::string res="";
258  std::size_t seppos = rFullPath.find_last_of(faudes_pathseps());
259  if(seppos==std::string::npos) return res;
260  res=rFullPath.substr(0,seppos+1);
261  return res;
262 }
263 
264 // ExtractFilename
265 std::string ExtractFilename(const std::string& rFullPath) {
266  std::string res=rFullPath;
267  std::size_t seppos = rFullPath.find_last_of(faudes_pathseps());
268  if(seppos==std::string::npos) return res;
269  res=rFullPath.substr(seppos+1);
270  return res;
271 }
272 
273 // ExtractBasename
274 std::string ExtractBasename(const std::string& rFullPath) {
275  std::string res=rFullPath;
276  std::size_t seppos = res.find_last_of(faudes_pathseps());
277  if(seppos!=std::string::npos) {
278  res=res.substr(seppos+1);
279  }
280  std::size_t dotpos = res.find_last_of(".");
281  if(dotpos!=std::string::npos) {
282  res=res.substr(0,dotpos);
283  }
284  return res;
285 }
286 
287 // ExtractSuffix
288 std::string ExtractSuffix(const std::string& rFullPath) {
289  std::string res=rFullPath;
290  std::size_t seppos = res.find_last_of(faudes_pathseps());
291  if(seppos!=std::string::npos) {
292  res=res.substr(seppos+1);
293  }
294  std::size_t dotpos = res.find_last_of(".");
295  if(dotpos!=std::string::npos)
296  if(dotpos +1 < res.size()) {
297  return res.substr(dotpos+1,res.size()-dotpos-1);
298  }
299  return std::string();
300 }
301 
302 // PrependPath
303 std::string PrependPath(const std::string& rLeft, const std::string& rRight) {
304  // bail out in trivial args
305  if(rLeft=="")
306  return std::string(rRight);
307  if(rRight=="")
308  return std::string(rLeft);
309  // system default
310  char sepchar=faudes_pathsep().at(0);
311  // user overwrite by left argument
312  std::size_t seppos;
313  seppos=rLeft.find_last_of(faudes_pathseps());
314  if(seppos!=std::string::npos)
315  sepchar=rLeft.at(seppos);
316  // go doit
317  std::string res=rLeft;
318  if(res.at(res.length()-1)!=sepchar)
319  res.append(1,sepchar);
320  if(rRight.at(0)!=sepchar){
321  res.append(rRight);
322  return res;
323  }
324  if(rRight.length()<=1) {
325  return res;
326  }
327  res.append(rRight,1,std::string::npos);
328  return res;
329 }
330 
331 // Test directory
332 bool DirectoryExists(const std::string& rDirectory) {
333 #ifdef FAUDES_POSIX
334  DIR *thedir;
335  thedir=opendir(rDirectory.c_str());
336  if(thedir) closedir(thedir);
337  return thedir!= 0;
338 #endif
339 #ifdef FAUDES_WINDOWS
340  DWORD fattr = GetFileAttributesA(rDirectory.c_str());
341  return
342  (fattr!=INVALID_FILE_ATTRIBUTES) && (fattr & FILE_ATTRIBUTE_DIRECTORY);
343 #endif
344  return false;
345 }
346 
347 // scan directory
348 std::set< std::string > ReadDirectory(const std::string& rDirectory) {
349  std::set< std::string > res;
350 #ifdef FAUDES_POSIX
351  DIR *thedir;
352  struct dirent *theent;
353  thedir=opendir(rDirectory.c_str());
354  if(!thedir) return res;
355  while((theent=readdir(thedir))) {
356  std::string fname(theent->d_name);
357  if(fname==".") continue;
358  if(fname=="..") continue;
359  res.insert(fname);
360  }
361  closedir(thedir);
362 #endif
363 #ifdef FAUDES_WINDOWS
364  HANDLE hf;
365  WIN32_FIND_DATA data;
366  hf = FindFirstFile((rDirectory+"\\*.*").c_str(), &data);
367  if (hf != INVALID_HANDLE_VALUE) {
368  do {
369  std::string fname(data.cFileName);
370  if(fname==".") continue;
371  if(fname=="..") continue;
372  res.insert(fname);
373  } while (FindNextFile(hf, &data));
374  FindClose(hf);
375  }
376 #endif
377  return res;
378 }
379 
380 
381 
382 
383 
384 // Test file
385 bool FileExists(const std::string& rFilename) {
386  std::fstream fp;
387  fp.open(rFilename.c_str(), std::ios::in | std::ios::binary);
388  return fp.good();
389 }
390 
391 // Delete file
392 bool FileDelete(const std::string& rFilename) {
393  return remove(rFilename.c_str()) == 0;
394 }
395 
396 // Copy file
397 bool FileCopy(const std::string& rFromFile, const std::string& rToFile) {
398  std::ifstream froms(rFromFile.c_str(), std::ios::binary);
399  std::ofstream tos(rToFile.c_str(), std::ios::binary);
400  tos << froms.rdbuf();
401  tos.flush();
402  return !(froms.fail() || tos.fail());
403 }
404 
405 // ConsoleOut class
406 // Note: console-out is not re-entrant; for multithreaded applications
407 // you must derive a class that has built-in mutexes;
408 ConsoleOut::ConsoleOut(void) : pStream(NULL), mMute(false) , mVerb(0) {
409  pInstance=this;
410 }
412  if(pStream) { pStream->flush(); delete pStream; }
413  if(this==smpInstance) smpInstance=NULL;
414 }
416  if(!smpInstance) smpInstance= new ConsoleOut();
417  return smpInstance->pInstance;
418 }
420  std::string fname = smpInstance->pInstance->Filename();
422  smpInstance->pInstance=out;
424  smpInstance->pInstance->ToFile(fname);
425 }
426 void ConsoleOut::ToFile(const std::string& filename) {
427  if(pStream) { pStream->flush(); delete pStream; }
428  pStream=NULL;
429  mFilename=filename;
430  if(mFilename=="") return;
431  pStream = new std::ofstream();
432  pStream->open(mFilename.c_str(),std::ios::app);
433 }
434  void ConsoleOut::Write(const std::string& message,long int cntnow, long int cntdone, int verb) {
435  if(mMute) return;
436  if(mVerb<verb) return;
437  DoWrite(message,cntnow,cntdone,verb);
438 }
439  void ConsoleOut::DoWrite(const std::string& message,long int cntnow, long int cntdone, int verb) {
440  (void) cntnow; (void) cntdone; (void) verb;
441  std::ostream* sout=pStream;
442  if(!sout) sout=&std::cout; // tmoor: used to be std::cerr, using std::cout to facilitate emscripten/js
443  *sout << message;
444  sout->flush();
445 }
446 
447 // global instance
449 
450 
451 
452 // debugging: objectcount
453 std::map<std::string,long int>* ObjectCount::mspMax=NULL;
454 std::map<std::string,long int>* ObjectCount::mspCount=NULL;
455 bool ObjectCount::msDone=false;
457  mspCount= new std::map<std::string,long int>();
458  mspMax= new std::map<std::string,long int>();
459  msDone=true;
460 }
461 void ObjectCount::Init(void) {
462  if(!msDone) ObjectCount();
463 }
464 void ObjectCount::Inc(const std::string& rTypeName) {
465  if(!msDone) ObjectCount();
466  long int cnt = ((*mspCount)[rTypeName]+=1);
467  if((*mspMax)[rTypeName]<cnt) (*mspMax)[rTypeName]=cnt;
468 }
469 void ObjectCount::Dec(const std::string& rTypeName) {
470  if(!msDone) ObjectCount();
471  (*mspCount)[rTypeName]-=1;
472 }
473 
474 
475 // debugging: report on exit function
476 void ExitFunction(void){
477 #ifdef FAUDES_DEBUG_CODE
478  FAUDES_WRITE_CONSOLE("faudes::ExitFunction():");
479  // be sure its up and running
481  // get rid of all registry prototypes
482  //TypeRegistry::G()->ClearAll();
483  //FunctionRegistry::G()->Clear();
484  // prepare report
485  std::map<std::string,long int>::iterator cit;
486  cit=ObjectCount::mspCount->begin();
487  for(;cit!=ObjectCount::mspCount->end();cit++) {
488  FAUDES_WRITE_CONSOLE( cit->first << ": #" << ToStringInteger(cit->second) <<
489  " (max #" << (*ObjectCount::mspMax)[cit->first] << ")");
490  }
491 #endif
492 }
493 
494 
495 #ifdef FAUDES_DEBUG_CODE
496 // report on exit install
497 class ExitFunctionInstall {
498 private:
499  static bool mDone;
500  static ExitFunctionInstall mInstance;
501  ExitFunctionInstall(void) {
502  if(mDone) return;
503  FAUDES_WRITE_CONSOLE("ExitFunctionInstall()");
504  std::atexit(ExitFunction);
505  mDone=true;
506  }
507 };
508 // exit function: global data
509 bool ExitFunctionInstall::mDone=false;
510 ExitFunctionInstall ExitFunctionInstall::mInstance;
511 #endif
512 
513 // test protocol: token writer and file
515 std::string gTestProtocolFr;
516 
517 // test protocol: setup
518 std::string TestProtocol(const std::string& rSource) {
519  if(gTestProtocolTw) return gTestProtocolFr;
520  // set up filename
521  std::string filename=rSource;
522  // fix empty source
523  if(filename=="") filename="faudes_dump";
524  // remove directory
525  filename=ExtractFilename(filename);
526  // remove extension
527  std::string::size_type pos=0;
528  for(;pos<filename.length();pos++)
529  if(filename.at(pos)=='.') filename.at(pos)='_';
530  // append extension
531  filename.append(".prot");
532  // record nominal case
533  gTestProtocolFr=filename;
534  // prepend prefix
535  filename.insert(0,"tmp_");
536  // initialise token writer
537  gTestProtocolTw= new TokenWriter(filename);
538  // report filename
539  return gTestProtocolFr;
540 }
541 
542 // test protocol: dump
543 void TestProtocol(const std::string& rMessage, const Type& rData, bool full) {
544  if(!gTestProtocolTw) return;
545  gTestProtocolTw->WriteComment("%%% test mark: " + rMessage);
546  if(full) rData.Write(*gTestProtocolTw);
547  else rData.SWrite(*gTestProtocolTw);
551  *gTestProtocolTw << "\n";
552 }
553 void TestProtocol(const std::string& rMessage, bool data) {
554  Boolean fbool(data);
555  TestProtocol(rMessage,fbool,true);
556 }
557 void TestProtocol(const std::string& rMessage, long int data) {
558  Integer fint(data);
559  TestProtocol(rMessage,fint,true);
560 }
561 void TestProtocol(const std::string& rMessage, const std::string& rData) {
562  String fstr(rData);
563  TestProtocol(rMessage,fstr,true);
564 }
565 
566 // test protocol: compare
567 bool TestProtocol(void) {
568  // bail out on no protocol
569  if(!gTestProtocolTw) return true;
570  // close protocol file
571  std::string prot=gTestProtocolTw->FileName();
572  delete gTestProtocolTw;
573  gTestProtocolTw=NULL;
574  // open protocol
575  std::fstream fp;
576  fp.open(prot.c_str(), std::ios::in | std::ios::binary);
577  if(!fp.good()) {
578  FAUDES_WRITE_CONSOLE("TestProtocol(): could not open protocol \"" << prot << "\"");
579  return false;
580  }
581  // open reference
582  std::string ref=gTestProtocolFr;
583  std::fstream fr;
584  fr.open(ref.c_str(), std::ios::in | std::ios::binary);
585  if(!fr.good()) {
586  ref="data"+faudes_pathsep()+ref;
587  fr.clear(); // mingw's runtime will not clear on open
588  fr.open(ref.c_str(), std::ios::in | std::ios::binary);
589  }
590  if(!fr.good()) {
591  FAUDES_WRITE_CONSOLE("TestProtocol(): could not open/find reference \"" << gTestProtocolFr << "\"");
592  return true;
593  }
594  // perform comparision
595  int dline=-1;
596  int cline=1;
597  try{
598  while(true) {
599  // read next char
600  char cp = fp.get();
601  char cr= fr.get();
602  // eof
603  if(fp.eof() && fr.eof()) { break; }
604  if(!fp.good() || !fr.good()) { dline=cline; break;}
605  // cheap normalize cr/lf: ignore \r (assume no double \r
606  if( cp=='\r' && cr =='\r') continue;
607  if( cp=='\r' && fp.eof()){ dline=cline; break;}
608  if( cp=='\r') cp = fp.get();
609  if( cr=='\r' && fr.eof()){ dline=cline; break;}
610  if( cr=='\r') cr = fr.get();
611  // count lines
612  if( cr=='\n') cline++;
613  // sense mitmatch
614  if( cp!= cr ){dline=cline; break;}
615  }
616  } catch(std::ios::failure&) {
617  throw Exception("TestProtocol()", "io error at line " + ToStringInteger(cline), 1);
618  }
619  // done
620  if(dline>=0) {
621  FAUDES_WRITE_CONSOLE("TestProtocol(): using reference " << ref << "");
622  FAUDES_WRITE_CONSOLE("TestProtocol(): found difference at line " << dline << "");
623  }
624  return dline== -1;
625 }
626 
627 
628 
629 // declare loop callback
630 static bool (*gBreakFnct)(void)=0;
631 
632 // set loop callback
633 void LoopCallback( bool pBreak(void)) {
634  gBreakFnct=pBreak;
635 }
636 
637 // do loop callback
638 // note: this function is meant to be "quiet" during normal
639 // operation in order not to mess up console logging
640 void LoopCallback(void){
641  if(!gBreakFnct) return;
642  if(! (*gBreakFnct)() ) return;
643  throw Exception("LoopCallback", "break on application request", 110);
644 }
645 
646 } // namespace faudes
Classes AttributeVoid and AttributeFlags
#define FAUDES_WRITE_CONSOLE(message)
Debug: output macro for optional redirection of all console output.
#define FD_DF(message)
Debug: optional report on user functions.
Runtime interface, elementary types.
const std::string & faudes_pathseps(void)
const std::string & faudes_pathsep(void)
Runtime interface, registry for faudes-types and functions.
Runtime interface, faudes types.
C-level utilities functions.
Elementary type.
Console Out.
Definition: cfl_utils.h:319
static ConsoleOut * G(void)
Acess static instance.
Definition: cfl_utils.cpp:415
ConsoleOut * pInstance
Redirect.
Definition: cfl_utils.h:353
std::ofstream * pStream
Private output stream.
Definition: cfl_utils.h:346
virtual void DoWrite(const std::string &message, long int cntnow=0, long int cntdone=0, int verb=0)
Writing hook.
Definition: cfl_utils.cpp:439
virtual void Write(const std::string &message, long int cntnow=0, long int cntdone=0, int verb=0)
Write a std::string message (optional progress report and verbosity)
Definition: cfl_utils.cpp:434
static ConsoleOut * smpInstance
Private static instance.
Definition: cfl_utils.h:355
virtual ~ConsoleOut(void)
Destructor.
Definition: cfl_utils.cpp:411
const std::string & Filename(void)
Query filename.
Definition: cfl_utils.h:328
ConsoleOut(void)
Constructor.
Definition: cfl_utils.cpp:408
bool mMute
Mute flag.
Definition: cfl_utils.h:350
std::string mFilename
Private record file name.
Definition: cfl_utils.h:348
void Redirect(ConsoleOut *out)
Redirect.
Definition: cfl_utils.cpp:419
void ToFile(const std::string &filename)
Redirect to file.
Definition: cfl_utils.cpp:426
Faudes exception class.
Elementary type.
static bool msDone
Definition: cfl_utils.h:377
static void Init(void)
Definition: cfl_utils.cpp:461
static void Inc(const std::string &rTypeName)
Definition: cfl_utils.cpp:464
static void Dec(const std::string &rTypeName)
Definition: cfl_utils.cpp:469
static std::map< std::string, long int > * mspCount
Definition: cfl_utils.h:375
static std::map< std::string, long int > * mspMax
Definition: cfl_utils.h:374
Elementary type.
A TokenWriter writes sequential tokens to a file, a string or stdout.
std::string FileName(void) const
Get the filename.
void WriteComment(const std::string &rComment)
Write comment in faudes format.
Base class of all libFAUDES objects that participate in the run-time interface.
Definition: cfl_types.h:239
void Write(const Type *pContext=0) const
Write configuration data to console.
Definition: cfl_types.cpp:139
void SWrite(TokenWriter &rTw) const
Write statistics comment to TokenWriter.
Definition: cfl_types.cpp:256
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
void ProcessDot(const std::string &rDotFile, const std::string &rOutFile, const std::string &rOutFormat, const std::string &rDotExec)
Convenience function: process dot file to graphics output.
Definition: cfl_utils.cpp:148
std::string VersionString()
Return FAUDES_VERSION as std::string.
Definition: cfl_utils.cpp:131
std::string ExtractDirectory(const std::string &rFullPath)
Extract directory from (full) path; i.e., remove the last separator and anything thereafer.
Definition: cfl_utils.cpp:256
void LoopCallback(bool pBreak(void))
Definition: cfl_utils.cpp:633
std::string PrependPath(const std::string &rLeft, const std::string &rRight)
Prepend one path before another.
Definition: cfl_utils.cpp:303
std::string ExtractBasename(const std::string &rFullPath)
Extract file basename from full path.
Definition: cfl_utils.cpp:274
Idx ToIdx(const std::string &rString)
Convert a string to Idx.
Definition: cfl_utils.cpp:100
TokenWriter * gTestProtocolTw
Definition: cfl_utils.cpp:514
std::string CreateTempFile(void)
Create a temp file, length 0.
Definition: cfl_utils.cpp:205
bool FileCopy(const std::string &rFromFile, const std::string &rToFile)
Copy file.
Definition: cfl_utils.cpp:397
std::string PluginsString()
Return FAUDES_PLUGINS as std::string.
Definition: cfl_utils.cpp:136
std::string ExpandString(const std::string &rString, unsigned int len)
Fill string with spaces up to a given length if length of the string is smaller than given length par...
Definition: cfl_utils.cpp:80
static bool(* gBreakFnct)(void)=0
Definition: cfl_utils.cpp:630
std::string ExtractFilename(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_utils.cpp:265
bool FileDelete(const std::string &rFilename)
Delete file.
Definition: cfl_utils.cpp:392
std::string ToStringFloat(Float number)
float to string
Definition: cfl_utils.cpp:64
std::string CollapsString(const std::string &rString, unsigned int len)
Limit length of string, return head and tail of string.
Definition: cfl_utils.cpp:91
std::string ToStringInteger16(Int number)
integer to string base 16
Definition: cfl_utils.cpp:54
double Float
Type definition for real type.
std::string ExtractSuffix(const std::string &rFullPath)
Extract extension from full path, i.e.
Definition: cfl_utils.cpp:288
std::string ContributorsString()
Return contributors as std::string.
Definition: cfl_utils.cpp:141
std::string ToStringInteger(Int number)
integer to string
Definition: cfl_utils.cpp:43
std::set< std::string > ReadDirectory(const std::string &rDirectory)
Read the contents of the specified directors.
Definition: cfl_utils.cpp:348
std::string StringSubstitute(const std::string &rString, const std::string &rFrom, const std::string &rTo)
Substitute globally in string.
Definition: cfl_utils.cpp:111
std::string gTestProtocolFr
Definition: cfl_utils.cpp:515
bool DirectoryExists(const std::string &rDirectory)
Test existence of directory.
Definition: cfl_utils.cpp:332
std::string TestProtocol(const std::string &rSource)
Test Protocol.
Definition: cfl_utils.cpp:518
void ExitFunction(void)
Definition: cfl_utils.cpp:476
bool FileExists(const std::string &rFilename)
Test existence of file.
Definition: cfl_utils.cpp:385
long int Int
Type definition for integer type (let target system decide, minimum 32bit)

libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen