cfl_helper.cpp
Go to the documentation of this file.
1 /** @file cfl_helper.cpp Helper 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_helper.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 // RemoveFile(void)
255 // todo: sys dependant *
256 bool RemoveFile(const std::string& rFileName) {
257  return std::remove(rFileName.c_str()) == 0;
258 }
259 
260 
261 // ExtractPath
262 std::string ExtractDirectory(const std::string& rFullPath) {
263  std::string res="";
264  std::size_t seppos = rFullPath.find_last_of(faudes_pathseps());
265  if(seppos==std::string::npos) return res;
266  res=rFullPath.substr(0,seppos+1);
267  return res;
268 }
269 
270 // ExtractFilename
271 std::string ExtractFilename(const std::string& rFullPath) {
272  std::string res=rFullPath;
273  std::size_t seppos = rFullPath.find_last_of(faudes_pathseps());
274  if(seppos==std::string::npos) return res;
275  res=rFullPath.substr(seppos+1);
276  return res;
277 }
278 
279 // ExtractBasename
280 std::string ExtractBasename(const std::string& rFullPath) {
281  std::string res=rFullPath;
282  std::size_t seppos = res.find_last_of(faudes_pathseps());
283  if(seppos!=std::string::npos) {
284  res=res.substr(seppos+1);
285  }
286  std::size_t dotpos = res.find_last_of(".");
287  if(dotpos!=std::string::npos) {
288  res=res.substr(0,dotpos);
289  }
290  return res;
291 }
292 
293 // ExtractExtension
294 std::string ExtractExtension(const std::string& rFullPath) {
295  std::string res=rFullPath;
296  std::size_t seppos = res.find_last_of(faudes_pathseps());
297  if(seppos!=std::string::npos) {
298  res=res.substr(seppos+1);
299  }
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);
304  }
305  return std::string();
306 }
307 
308 // PrependPath
309 std::string PrependDirectory(const std::string& rDirectory, const std::string& rFileName) {
310  std::string res=rDirectory;
311  char sepchar=faudes_pathsep().at(0);
312  if(res!="")
313  if(res.at(res.length()-1)!=sepchar)
314  res.append(1,sepchar);
315  res.append(rFileName);
316  return res;
317 }
318 
319 // Test directory
320 bool DirectoryExists(const std::string& rDirectory) {
321 #ifdef FAUDES_POSIX
322  DIR *thedir;
323  thedir=opendir(rDirectory.c_str());
324  if(thedir) closedir(thedir);
325  return thedir!= 0;
326 #endif
327 #ifdef FAUDES_WINDOWS
328  DWORD fattr = GetFileAttributesA(rDirectory.c_str());
329  return
330  (fattr!=INVALID_FILE_ATTRIBUTES) && (fattr & FILE_ATTRIBUTE_DIRECTORY);
331 #endif
332  return false;
333 }
334 
335 // scan directory
336 std::set< std::string > ReadDirectory(const std::string& rDirectory) {
337  std::set< std::string > res;
338 #ifdef FAUDES_POSIX
339  DIR *thedir;
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;
347  res.insert(fname);
348  }
349  closedir(thedir);
350 #endif
351 #ifdef FAUDES_WINDOWS
352  HANDLE hf;
353  WIN32_FIND_DATA data;
354  hf = FindFirstFile((rDirectory+"\\*.*").c_str(), &data);
355  if (hf != INVALID_HANDLE_VALUE) {
356  do {
357  std::string fname(data.cFileName);
358  if(fname==".") continue;
359  if(fname=="..") continue;
360  res.insert(fname);
361  } while (FindNextFile(hf, &data));
362  FindClose(hf);
363  }
364 #endif
365  return res;
366 }
367 
368 
369 
370 
371 
372 // Test file
373 bool FileExists(const std::string& rFilename) {
374  std::fstream fp;
375  fp.open(rFilename.c_str(), std::ios::in | std::ios::binary);
376  return fp.good();
377 }
378 
379 // Delete file
380 bool FileDelete(const std::string& rFilename) {
381  return remove(rFilename.c_str()) == 0;
382 }
383 
384 // Copy file
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();
389  tos.flush();
390  return !(froms.fail() || tos.fail());
391 }
392 
393 // ConsoleOut class
394 // Note: console-out is not re-entrant; for multithreaded applications
395 // you must derive a class that has built-in mutexes;
396 ConsoleOut::ConsoleOut(void) : pStream(NULL), mMute(false) , mVerb(0) {
397  pInstance=this;
398 }
400  if(pStream) { pStream->flush(); delete pStream; }
401  if(this==smpInstance) smpInstance=NULL;
402 }
404  if(!smpInstance) smpInstance= new ConsoleOut();
405  return smpInstance->pInstance;
406 }
408  std::string fname = smpInstance->pInstance->Filename();
410  smpInstance->pInstance=out;
412  smpInstance->pInstance->ToFile(fname);
413 }
414 void ConsoleOut::ToFile(const std::string& filename) {
415  if(pStream) { pStream->flush(); delete pStream; }
416  pStream=NULL;
417  mFilename=filename;
418  if(mFilename=="") return;
419  pStream = new std::ofstream();
420  pStream->open(mFilename.c_str(),std::ios::app);
421 }
422  void ConsoleOut::Write(const std::string& message,long int cntnow, long int cntdone, int verb) {
423  if(mMute) return;
424  if(mVerb<verb) return;
425  DoWrite(message,cntnow,cntdone,verb);
426 }
427  void ConsoleOut::DoWrite(const std::string& message,long int cntnow, long int cntdone, int verb) {
428  (void) cntnow; (void) cntdone; (void) verb;
429  std::ostream* sout=pStream;
430  if(!sout) sout=&std::cout; // tmoor: used to be std::cerr, using std::cout to facilitate emscripten/js
431  *sout << message;
432  sout->flush();
433 }
434 
435 // global instance
437 
438 
439 
440 // debugging: objectcount
441 std::map<std::string,long int>* ObjectCount::mspMax=NULL;
442 std::map<std::string,long int>* ObjectCount::mspCount=NULL;
443 bool ObjectCount::msDone=false;
445  mspCount= new std::map<std::string,long int>();
446  mspMax= new std::map<std::string,long int>();
447  msDone=true;
448 }
449 void ObjectCount::Init(void) {
450  if(!msDone) ObjectCount();
451 }
452 void ObjectCount::Inc(const std::string& rTypeName) {
453  if(!msDone) ObjectCount();
454  long int cnt = ((*mspCount)[rTypeName]+=1);
455  if((*mspMax)[rTypeName]<cnt) (*mspMax)[rTypeName]=cnt;
456 }
457 void ObjectCount::Dec(const std::string& rTypeName) {
458  if(!msDone) ObjectCount();
459  (*mspCount)[rTypeName]-=1;
460 }
461 
462 
463 // debugging: report on exit function
464 void ExitFunction(void){
465 #ifdef FAUDES_DEBUG_CODE
466  FAUDES_WRITE_CONSOLE("faudes::ExitFunction():");
467  // be sure its up and running
469  // get rid of all registry prototypes
470  //TypeRegistry::G()->ClearAll();
471  //FunctionRegistry::G()->Clear();
472  // prepare report
473  std::map<std::string,long int>::iterator cit;
474  cit=ObjectCount::mspCount->begin();
475  for(;cit!=ObjectCount::mspCount->end();cit++) {
476  FAUDES_WRITE_CONSOLE( cit->first << ": #" << ToStringInteger(cit->second) <<
477  " (max #" << (*ObjectCount::mspMax)[cit->first] << ")");
478  }
479 #endif
480 }
481 
482 
483 #ifdef FAUDES_DEBUG_CODE
484 // report on exit install
485 class ExitFunctionInstall {
486 private:
487  static bool mDone;
488  static ExitFunctionInstall mInstance;
489  ExitFunctionInstall(void) {
490  if(mDone) return;
491  FAUDES_WRITE_CONSOLE("ExitFunctionInstall()");
492  std::atexit(ExitFunction);
493  mDone=true;
494  }
495 };
496 // exit function: global data
497 bool ExitFunctionInstall::mDone=false;
498 ExitFunctionInstall ExitFunctionInstall::mInstance;
499 #endif
500 
501 // test protocol: token writer and file
503 std::string gTestProtocolFr;
504 
505 // test protocol: setup
506 std::string TestProtocol(const std::string& rSource) {
507  if(gTestProtocolTw) return gTestProtocolFr;
508  // set up filename
509  std::string filename=rSource;
510  // fix empty source
511  if(filename=="") filename="faudes_dump";
512  // remove directory
513  filename=ExtractFilename(filename);
514  // remove extension
515  std::string::size_type pos=0;
516  for(;pos<filename.length();pos++)
517  if(filename.at(pos)=='.') filename.at(pos)='_';
518  // append extension
519  filename.append(".prot");
520  // record nominal case
521  gTestProtocolFr=filename;
522  // prepend prefix
523  filename.insert(0,"tmp_");
524  // initialise token writer
525  gTestProtocolTw= new TokenWriter(filename);
526  // report filename
527  return gTestProtocolFr;
528 }
529 
530 // test protocol: dump
531 void TestProtocol(const std::string& rMessage, const Type& rData, bool full) {
532  if(!gTestProtocolTw) return;
533  gTestProtocolTw->WriteComment("%%% test mark: " + rMessage);
534  if(full) rData.Write(*gTestProtocolTw);
535  else rData.SWrite(*gTestProtocolTw);
539  *gTestProtocolTw << "\n";
540 }
541 void TestProtocol(const std::string& rMessage, bool data) {
542  Boolean fbool(data);
543  TestProtocol(rMessage,fbool,true);
544 }
545 void TestProtocol(const std::string& rMessage, long int data) {
546  Integer fint(data);
547  TestProtocol(rMessage,fint,true);
548 }
549 void TestProtocol(const std::string& rMessage, const std::string& rData) {
550  String fstr(rData);
551  TestProtocol(rMessage,fstr,true);
552 }
553 
554 // test protocol: compare
555 bool TestProtocol(void) {
556  // bail out on no protocol
557  if(!gTestProtocolTw) return true;
558  // close protocol file
559  std::string prot=gTestProtocolTw->FileName();
560  delete gTestProtocolTw;
561  gTestProtocolTw=NULL;
562  // open protocol
563  std::fstream fp;
564  fp.open(prot.c_str(), std::ios::in | std::ios::binary);
565  if(!fp.good()) {
566  FAUDES_WRITE_CONSOLE("TestProtocol(): could not open protocol \"" << prot << "\"");
567  return false;
568  }
569  // open reference
570  std::string ref=gTestProtocolFr;
571  std::fstream fr;
572  fr.open(ref.c_str(), std::ios::in | std::ios::binary);
573  if(!fr.good()) {
574  ref="data"+faudes_pathsep()+ref;
575  fr.clear(); // mingw's runtime will not clear on open
576  fr.open(ref.c_str(), std::ios::in | std::ios::binary);
577  }
578  if(!fr.good()) {
579  FAUDES_WRITE_CONSOLE("TestProtocol(): could not open/find reference \"" << gTestProtocolFr << "\"");
580  return true;
581  }
582  // perform comparision
583  int dline=-1;
584  int cline=1;
585  try{
586  while(true) {
587  // read next char
588  char cp = fp.get();
589  char cr= fr.get();
590  // eof
591  if(fp.eof() && fr.eof()) { break; }
592  if(!fp.good() || !fr.good()) { dline=cline; break;}
593  // cheap normalize cr/lf: ignore \r (assume no double \r
594  if( cp=='\r' && cr =='\r') continue;
595  if( cp=='\r' && fp.eof()){ dline=cline; break;}
596  if( cp=='\r') cp = fp.get();
597  if( cr=='\r' && fr.eof()){ dline=cline; break;}
598  if( cr=='\r') cr = fr.get();
599  // count lines
600  if( cr=='\n') cline++;
601  // sense mitmatch
602  if( cp!= cr ){dline=cline; break;}
603  }
604  } catch(std::ios::failure&) {
605  throw Exception("TestProtocol()", "io error at line " + ToStringInteger(cline), 1);
606  }
607  // done
608  if(dline>=0) {
609  FAUDES_WRITE_CONSOLE("TestProtocol(): using reference " << ref << "");
610  FAUDES_WRITE_CONSOLE("TestProtocol(): found difference at line " << dline << "");
611  }
612  return dline== -1;
613 }
614 
615 
616 
617 // declare loop callback
618 static bool (*gBreakFnct)(void)=0;
619 
620 // set loop callback
621 void LoopCallback( bool pBreak(void)) {
622  gBreakFnct=pBreak;
623 }
624 
625 // do loop callback
626 // note: this function is meant to be "quiet" during normal
627 // operation in order not to mess up console logging
628 void LoopCallback(void){
629  if(!gBreakFnct) return;
630  if(! (*gBreakFnct)() ) return;
631  throw Exception("LoopCallback", "break on application request", 110);
632 }
633 
634 } // 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.
Helper functions.
FAUDES_API const std::string & faudes_pathsep(void)
Definition: cfl_platform.h:185
FAUDES_API const std::string & faudes_pathseps(void)
Definition: cfl_platform.h:179
Runtime interface, registry for faudes-types and functions.
Runtime interface, faudes types.
Elementary type.
Console Out.
Definition: cfl_helper.h:324
static ConsoleOut * G(void)
Acess static instance.
Definition: cfl_helper.cpp:403
ConsoleOut * pInstance
Redirect.
Definition: cfl_helper.h:358
std::ofstream * pStream
Private output stream.
Definition: cfl_helper.h:351
virtual void DoWrite(const std::string &message, long int cntnow=0, long int cntdone=0, int verb=0)
Writing hook.
Definition: cfl_helper.cpp:427
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_helper.cpp:422
static ConsoleOut * smpInstance
Private static instance.
Definition: cfl_helper.h:360
virtual ~ConsoleOut(void)
Destructor.
Definition: cfl_helper.cpp:399
const std::string & Filename(void)
Query filename.
Definition: cfl_helper.h:333
ConsoleOut(void)
Constructor.
Definition: cfl_helper.cpp:396
bool mMute
Mute flag.
Definition: cfl_helper.h:355
std::string mFilename
Private record file name.
Definition: cfl_helper.h:353
void Redirect(ConsoleOut *out)
Redirect.
Definition: cfl_helper.cpp:407
void ToFile(const std::string &filename)
Redirect to file.
Definition: cfl_helper.cpp:414
Faudes exception class.
Elementary type.
static bool msDone
Definition: cfl_helper.h:382
static void Init(void)
Definition: cfl_helper.cpp:449
static void Inc(const std::string &rTypeName)
Definition: cfl_helper.cpp:452
static void Dec(const std::string &rTypeName)
Definition: cfl_helper.cpp:457
static std::map< std::string, long int > * mspCount
Definition: cfl_helper.h:380
static std::map< std::string, long int > * mspMax
Definition: cfl_helper.h:379
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_helper.cpp:148
std::string VersionString()
Return FAUDES_VERSION as std::string.
Definition: cfl_helper.cpp:131
std::string ExtractDirectory(const std::string &rFullPath)
Extract directory from full path.
Definition: cfl_helper.cpp:262
bool RemoveFile(const std::string &rFileName)
Delete a file.
Definition: cfl_helper.cpp:256
void LoopCallback(bool pBreak(void))
Definition: cfl_helper.cpp:621
std::string ExtractExtension(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_helper.cpp:294
std::string ExtractBasename(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_helper.cpp:280
Idx ToIdx(const std::string &rString)
Convert a string to Idx.
Definition: cfl_helper.cpp:100
TokenWriter * gTestProtocolTw
Definition: cfl_helper.cpp:502
std::string CreateTempFile(void)
Create a temp file, length 0.
Definition: cfl_helper.cpp:205
bool FileCopy(const std::string &rFromFile, const std::string &rToFile)
Copy file.
Definition: cfl_helper.cpp:385
std::string PluginsString()
Return FAUDES_PLUGINS as std::string.
Definition: cfl_helper.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_helper.cpp:80
std::string PrependDirectory(const std::string &rDirectory, const std::string &rFileName)
Construct full path from directory and filename.
Definition: cfl_helper.cpp:309
static bool(* gBreakFnct)(void)=0
Definition: cfl_helper.cpp:618
std::string ExtractFilename(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_helper.cpp:271
bool FileDelete(const std::string &rFilename)
Delete file.
Definition: cfl_helper.cpp:380
std::string ToStringFloat(Float number)
float to string
Definition: cfl_helper.cpp:64
std::string CollapsString(const std::string &rString, unsigned int len)
Limit length of string, return head and tail of string.
Definition: cfl_helper.cpp:91
std::string ToStringInteger16(Int number)
integer to string base 16
Definition: cfl_helper.cpp:54
double Float
Type definition for real type.
std::string ContributorsString()
Return contributors as std::string.
Definition: cfl_helper.cpp:141
std::string ToStringInteger(Int number)
integer to string
Definition: cfl_helper.cpp:43
std::set< std::string > ReadDirectory(const std::string &rDirectory)
Read the contents of the specified directors.
Definition: cfl_helper.cpp:336
std::string StringSubstitute(const std::string &rString, const std::string &rFrom, const std::string &rTo)
Substitute in string.
Definition: cfl_helper.cpp:111
std::string gTestProtocolFr
Definition: cfl_helper.cpp:503
bool DirectoryExists(const std::string &rDirectory)
Test existence of directory.
Definition: cfl_helper.cpp:320
std::string TestProtocol(const std::string &rSource)
Test Protocol.
Definition: cfl_helper.cpp:506
void ExitFunction(void)
Definition: cfl_helper.cpp:464
bool FileExists(const std::string &rFilename)
Test existence of file.
Definition: cfl_helper.cpp:373
long int Int
Type definition for integer type (let target system decide, minimum 32bit)

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen