#if !defined UTILITY_H #define UTILITY_H// diverse utility functions // Abs() // Sign() // Max(a,b) returns the max of a and b // Round(x,n) rundet auf n Stellen nach dem Komma // triml() returns string without leading blanks /////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /* CVS history $Author: halo $ at $Date: 1999-09-29 18:21:21 $ $Revision: 1.1 $ //////////////////////////////////////////////////////////////////////////////// // M.D. 14/11/96 // M.D. 29/1/97 Max added //$Log: not supported by cvs2svn $ //Revision 1.4 1997/12/05 12:40:36 dahlinge //utility.h: #define added //getGeoParam: bug fixed after change of database table layout //(In Geometry_objects_had the column trans_index was removed) // * Revision 1.3 1997/09/08 08:17:34 dahlinge * cvs keyword expansions corrected * */ //////////////////////////////////////////////////////////////////////////////// template inline T Abs(T a){ return (a>0) ? a : -a;} template inline int Sign(T a){ return (a>=0) ? 1 : -1;} template inline T Round(T a, int n){ return Sign(a)*(floor(Abs(a)*pow(10,n) + 0.5) / pow(10,n)); } template inline T Max(T a, T b){ return (a>b) ? a : b;} //######################### triml ######################### // returns string without leading blanks inline char* triml(char* c){ size_t n; for (n=0; n < strlen(c); n++){ if (c[n] != ' ' && c[n] !='\t' && c[n]) break; } return (char*)(c+n); } #endif