include/common.h
branchpyrit
changeset 78 9569e9f35374
parent 52 a6413a3d741d
child 83 e3a2a5b26abb
equal deleted inserted replaced
77:dbe8438d5dca 78:9569e9f35374
    29 
    29 
    30 #include <stdio.h>
    30 #include <stdio.h>
    31 #include <stdarg.h>
    31 #include <stdarg.h>
    32 #include <float.h>
    32 #include <float.h>
    33 #include <pthread.h>
    33 #include <pthread.h>
       
    34 #include <string>
       
    35 
       
    36 using namespace std;
    34 
    37 
    35 #ifdef PYRIT_DOUBLE
    38 #ifdef PYRIT_DOUBLE
    36 # define Float double
    39 # define Float double
    37 # define Eps DBL_EPSILON
    40 # define Eps DBL_EPSILON
    38 # define Inf DBL_MAX
    41 # define Inf DBL_MAX
   105 		else
   108 		else
   106 			return c;
   109 			return c;
   107 	}
   110 	}
   108 }
   111 }
   109 
   112 
       
   113 inline void trim(string& s)
       
   114 {
       
   115 	const char *ws = " \n";
       
   116 	string::size_type pos = s.find_last_not_of(ws);
       
   117 	if (pos != string::npos)
       
   118 	{
       
   119 		s.erase(pos + 1);
       
   120 		pos = s.find_first_not_of(ws);
       
   121 		if (pos != string::npos)
       
   122 			s.erase(0, pos);
       
   123 	}
       
   124 	else
       
   125 		s.erase(s.begin(), s.end());
       
   126 }
       
   127 
   110 #endif
   128 #endif