GeoTessCPP
2.2.3
Software to facilitate storage and retrieval of 3D information about the Earth.
|
Go to the documentation of this file.
38 #ifndef CPPUTILS_OBJECT_H
39 #define CPPUTILS_OBJECT_H
124 static void removeEOL(
string& s);
130 static void addPathSeparator(
string& path);
136 static string insertPathSeparator(
const string& dir,
const string& name);
142 static void removePathSeparator(
string& path);
148 static string itos(
int i,
const string& frmt =
"%d");
150 static string ftos(
float f,
const string& frmt =
"%.6f");
151 static string dtos(
double d,
const string& frmt =
"%.14f");
158 static int stoi(
const string& i,
const string& frmt =
"%d");
160 static float stof(
const string& f,
const string& frmt =
"%f");
161 static double stod(
const string& d,
const string& frmt =
"%lf");
162 static bool stob(
const string& b);
169 static string trim(
const string& str,
170 const string& delim =
" \t");
172 const string& delim =
" \t");
174 const string& delim =
" \t");
192 map<string, string>& props);
207 const string& tag,
string& value);
217 vector<string>& tokens);
229 template <
typename T>
230 static void minmax(
const vector<T>& v, T& mn, T& mx);
235 static double toDegrees(
double a);
240 static double toRadians(
double a);
245 template <
typename T>
249 for (
int i = 0; i < ni; ++i)
261 template <
typename T>
265 a[0] =
new T [ni*nj];
266 for (
int i=1; i<ni; ++i) a[i] = &a[0][i*nj];
278 template <
typename T>
281 T*** a =
new T** [ni];
282 a[0] =
new T* [ni*nj];
283 a[0][0] =
new T [ni*nj*nk];
284 for (
int i = 0; i < ni; ++i)
287 for (
int j = 0; j < nj; ++j)
288 a[i][j] = &a[0][0][(i*nj + j)*nk];
297 template <
typename T>
298 static void delete2DArray(T**& a);
303 template <
typename T>
308 for (
int i = 0; i < ni; ++i)
delete [] a[i];
317 template <
typename T>
318 static void delete3DArray(T***& a);
323 template <
typename T>
326 for (
int i = 0; i < n; ++i) array[i] = val;
332 template <
typename T>
336 for (
int i=0; i<n; ++i)
376 f.open(fileName.c_str(), ios::in);
394 inline double CPPUtils::toDegrees(
double a)
396 return RAD_TO_DEG * a;
404 inline double CPPUtils::toRadians(
double a)
406 return DEG_TO_RAD * a;
412 template <
typename T>
413 inline void CPPUtils::delete2DArray(T**& a)
426 template <
typename T>
427 inline void CPPUtils::delete3DArray(T***& a)
441 inline void CPPUtils::removeEOL(
string& s)
443 if (s.size() && (s[s.length() - 1] ==
'\n')) s.erase(s.length() - 1);
444 if (s.size() && (s[s.length() - 1] ==
'\r')) s.erase(s.length() - 1);
447 inline void CPPUtils::removePathSeparator(
string& s)
449 if (s.size() && (s[s.length() - 1] == CPPUtils::FILE_SEP)) s.erase(s.length() - 1);
452 inline void CPPUtils::addPathSeparator(
string& s)
454 if ( s.find_last_of(CPPUtils::FILE_SEP) != s.length() - 1 )
455 s += CPPUtils::FILE_SEP;
458 inline string CPPUtils::insertPathSeparator(
const string& dir,
const string& name)
463 while (path.size() && (path[path.length() - 1] == CPPUtils::FILE_SEP))
464 path.erase(path.length() - 1, 1);
466 if (path.length() > 0)
467 path = path+CPPUtils::FILE_SEP;
470 while (nm.size() && (nm[0] == CPPUtils::FILE_SEP))
471 nm.erase((
unsigned)0, 1);
479 template <
typename T>
480 void CPPUtils::minmax(
const vector<T>& v, T& mn, T& mx)
492 for (
int i = 1; i < v.size(); i++)
494 if (mn > v[i]) mn = v[i];
495 if (mx < v[i]) mx = v[i];
502 #endif // CPPUTILS_OBJECT_H
static string ltos(LONG_INT l, const string &frmt="%llu")
static string dtos(double d, const string &frmt="%.14f")
static bool stob(const string &b)
static string btos(bool b)
static T ** new2DArray(int ni, int nj)
static double stod(const string &d, const string &frmt="%lf")
static void tokenizeString(const string &str, const string &delim, vector< string > &tokens)
static string class_name()
static string lowercase_string(const string &str)
static T ** new2DArrayOfArrays(int ni, int nj)
static void resetArray(int n, T *array, T val)
virtual int class_size() const
static string ftos(float f, const string &frmt="%.6f")
static char const FILE_SEP
static string trimRight(const string &str, const string &delim=" \t")
static const string getOpSys()
static bool isBigEndian()
static void getProperties(const string &str, map< string, string > &props)
static string stringReplaceAll(const string &sf, const string &sr, const string &s)
static string trim(const string &str, const string &delim=" \t")
static T *** new3DArray(int ni, int nj, int nk)
static bool getProperty(const map< string, string > &props, const string &tag, string &value)
static T * copyArray(T *a, int n)
static LONG_INT stol(const string &i64, const string &frmt="%llu")
static void delete2DArrayOfArrays(T **&a, int ni)
Basic static utility functions and variables.
static bool isint(const string &i)
static string uppercase_string(const string &str)
static string const NEWLINE
static string itos(int i, const string &frmt="%d")
static int stoi(const string &i, const string &frmt="%d")
static string trimLeft(const string &str, const string &delim=" \t")
static bool fileExists(const string &fileName)
static float stof(const string &f, const string &frmt="%f")