|
|
Go to the documentation of this file.
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);
80std::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, ' ');
91std::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);
112 std::string res=rString;
113 std::transform(res.begin(), res.end(), res.begin(),
114 []( unsigned char c){ return std::tolower(c); });
121std::string StringSubstitute( const std::string& rString, const std::string& rFrom, const std::string& rTo) {
126 while(pos<rString.length()) {
127 std::size_t next=rString.find(rFrom,pos);
128 if(next==std::string::npos) break;
129 res.append(rString.substr(pos, next-pos));
131 pos=next+rFrom.length();
134 if(pos<rString.length())
135 res.append(rString.substr(pos));
142 return std::string(FAUDES_VERSION);
147 return std::string(FAUDES_PLUGINS);
153 "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, Changming Yang, Yang Yi, Jorgos Zaddach, Hao Zhou, Christian Zwick, et al";
156#define XLITSTR(x) LITSTR(x)
161#ifdef FAUDES_BUILDENV
162 res = res + std::string(FAUDES_BUILDENV);
164 res = res + std::string( "generic");
166#ifdef FAUDES_BUILDTIME
167 res = res + std::string( " ") + std::string(FAUDES_BUILDTIME);
169 res = res + std::string( " ") + std::string(FAUDES_CONFIG_TIMESTAMP);
177 const std::string& rOutFile, const std::string& rOutFormat, const std::string& rDotExec)
179 std::string format=rOutFormat;
182 if(rOutFile.rfind( '.')+1 < rOutFile.size()) {
183 format=rOutFile.substr(rOutFile.rfind( '.')+1);
187 if (format == "canon");
188 else if (format == "dot");
189 else if (format == "xdot");
190 else if (format == "cmap");
191 else if (format == "dia");
192 else if (format == "fig");
193 else if (format == "gd");
194 else if (format == "gd2");
195 else if (format == "gif");
196 else if (format == "hpgl");
197 else if (format == "imap");
198 else if (format == "cmapx");
199 else if (format == "ismap");
200 else if (format == "jpg");
201 else if (format == "jpeg");
202 else if (format == "mif");
203 else if (format == "mp");
204 else if (format == "pcl");
205 else if (format == "pic");
206 else if (format == "plain");
207 else if (format == "plain-ext");
208 else if (format == "png");
209 else if (format == "ps");
210 else if (format == "ps2");
211 else if (format == "svg");
212 else if (format == "svgz");
213 else if (format == "vrml");
214 else if (format == "vtx");
215 else if (format == "wbmp");
216 else if (format == "eps");
217 else if (format == "pdf");
219 std::stringstream errstr;
220 errstr << "Dot output format \"" << format << "\" unknown";
221 throw Exception( "faudes::ProcessDot", errstr.str(), 3);
223 std::string dotcommand = rDotExec + " -T"+format+ " \""+rDotFile+ "\" -o \""+rOutFile+ "\"";
224 if(system(dotcommand.c_str()) != 0) {
226 "Error in running " + dotcommand, 3);
234 static bool ready= false;
235 static bool known= false;
236 if(known) return ready;
238 std::string testdot = rDotExec + " -V";
239 ready = (system(testdot.c_str()) == 0);
248 char filename[]= "faudes_temp_XXXXXX";
253 filedes= mkstemp(filename);
255 FD_DF( "faudes::CreateTempFile(): error");
259 res=std::string(filename);
277 char* tmpname = _mktemp(filename);
280 FD_DF( "faudes::CreateTempFile(): error");
283 fopen_s(&file,tmpname, "w");
285 FD_DF( "faudes::CreateTempFile(): error");
289 res=std::string(tmpname);
291 FD_DF( "faudes::CreateTempFile(): " << res);
299 if(seppos==std::string::npos) return res;
300 res=rFullPath.substr(0,seppos+1);
306 std::string res=rFullPath;
308 if(seppos==std::string::npos) return res;
309 res=rFullPath.substr(seppos+1);
315 std::string res=rFullPath;
317 if(seppos!=std::string::npos) {
318 res=res.substr(seppos+1);
320 std::size_t dotpos = res.find_last_of( ".");
321 if(dotpos!=std::string::npos) {
322 res=res.substr(0,dotpos);
329 std::string res=rFullPath;
331 if(seppos!=std::string::npos) {
332 res=res.substr(seppos+1);
334 std::size_t dotpos = res.find_last_of( ".");
335 if(dotpos!=std::string::npos)
336 if(dotpos +1 < res.size()) {
337 return res.substr(dotpos+1,res.size()-dotpos-1);
339 return std::string();
343std::string PrependPath( const std::string& rLeft, const std::string& rRight) {
346 return std::string(rRight);
348 return std::string(rLeft);
354 if(seppos!=std::string::npos)
355 sepchar=rLeft.at(seppos);
357 std::string res=rLeft;
358 if(res.at(res.length()-1)!=sepchar)
359 res.append(1,sepchar);
360 if(rRight.at(0)!=sepchar){
364 if(rRight.length()<=1) {
367 res.append(rRight,1,std::string::npos);
375 thedir=opendir(rDirectory.c_str());
376 if(thedir) closedir(thedir);
380 DWORD fattr = GetFileAttributesA( faudes_extpath(rDirectory).c_str());
382 (fattr!=INVALID_FILE_ATTRIBUTES) && (fattr & FILE_ATTRIBUTE_DIRECTORY);
389 std::set< std::string > res;
392 struct dirent *theent;
393 thedir=opendir(rDirectory.c_str());
394 if(!thedir) return res;
395 while((theent=readdir(thedir))) {
396 std::string fname(theent->d_name);
397 if(fname== ".") continue;
398 if(fname== "..") continue;
405 WIN32_FIND_DATA data;
406 hf = FindFirstFile((rDirectory+ "\\*.*").c_str(), &data);
407 if (hf != INVALID_HANDLE_VALUE) {
409 std::string fname(data.cFileName);
410 if(fname== ".") continue;
411 if(fname== "..") continue;
413 } while (FindNextFile(hf, &data));
424 fp.open(rFilename.c_str(), std::ios::in | std::ios::binary);
430 return remove(rFilename.c_str()) == 0;
434bool FileCopy( const std::string& rFromFile, const std::string& rToFile) {
435 std::ifstream froms(rFromFile.c_str(), std::ios::binary);
436 std::ofstream tos(rToFile.c_str(), std::ios::binary);
437 tos << froms.rdbuf();
439 return !(froms.fail() || tos.fail());
475 DoWrite(message,cntnow,cntdone,verb);
478 (void) cntnow; (void) cntdone;
479 if( mVerb<verb) return;
481 if(!sout) sout=&std::cout;
490void Print( int v, const std::string& message) {
492 std::ostringstream line;
493 line << "FAUDES_PRINT: " << message << std::endl;
498void Print( const std::string& message) {
516 mspCount= new std::map<std::string,long int>();
517 mspMax= new std::map<std::string,long int>();
525 long int cnt = ((*mspCount)[rTypeName]+=1);
530 (*mspCount)[rTypeName]-=1;
536#ifdef FAUDES_DEBUG_CODE
544 std::map<std::string,long int>::iterator cit;
554#ifdef FAUDES_DEBUG_CODE
556class ExitFunctionInstall {
559 static ExitFunctionInstall mInstance;
560 ExitFunctionInstall( void) {
563 std::atexit(ExitFunction);
568bool ExitFunctionInstall::mDone= false;
569ExitFunctionInstall ExitFunctionInstall::mInstance;
580 std::string filename=rSource;
582 if(filename== "") filename= "faudes_dump";
586 std::string::size_type pos=0;
587 for(;pos<filename.length();pos++)
588 if(filename.at(pos)== '.') filename.at(pos)= '_';
590 filename.append( ".prot");
594 filename.insert(0, "tmp_");
620void TestProtocol( const std::string& rMessage, const std::string& rData) {
635 fp.open(prot.c_str(), std::ios::in | std::ios::binary);
643 fr.open(ref.c_str(), std::ios::in | std::ios::binary);
647 fr.open(ref.c_str(), std::ios::in | std::ios::binary);
662 if(fp.eof() && fr.eof()) { break; }
663 if(!fp.good() || !fr.good()) { dline=cline; break;}
665 if( cp== '\r' && cr == '\r') continue;
666 if( cp== '\r' && fp.eof()){ dline=cline; break;}
667 if( cp== '\r') cp = fp.get();
668 if( cr== '\r' && fr.eof()){ dline=cline; break;}
669 if( cr== '\r') cr = fr.get();
671 if( cr== '\n') cline++;
673 if( cp!= cr ){dline=cline; break;}
675 } catch(std::ios::failure&) {
702 throw Exception( "LoopCallback", "break on application request", 110);
#define FAUDES_WRITE_CONSOLE(message)
static ConsoleOut * G(void)
static ConsoleOut * smpInstance
virtual void DoWrite(const std::string &message, long int cntnow=0, long int cntdone=0, int verb=1)
virtual ~ConsoleOut(void)
const std::string & Filename(void)
virtual void Write(const std::string &message, long int cntnow=0, long int cntdone=0, int verb=1)
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)
bool DotReady(const std::string &rDotExec)
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 ToLowerCase(const std::string &rString)
void Print(int v, const std::string &message)
std::string gTestProtocolFr
std::string ExtractBasename(const std::string &rFullPath)
bool DirectoryExists(const std::string &rDirectory)
bool FileExists(const std::string &rFilename)
std::string ExtractSuffix(const std::string &rFullPath)
std::string CollapsString(const std::string &rString, unsigned int len)
libFAUDES 2.34e
--- 2026.03.16
--- c++ api documentaion by doxygen
|