GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
geotess::CPPUtils Class Reference

Basic static utility functions and variables. More...

#include <CPPUtils.h>

Public Member Functions

 CPPUtils ()
 Default constructor. More...
 
virtual ~CPPUtils ()
 Protected destructor ... More...
 
virtual int class_size () const
 Returns the class size. More...
 

Static Public Member Functions

static void addPathSeparator (string &path)
 If the supplied path does not already end with a path separator, append it to the end. More...
 
static string btos (bool b)
 
static string class_name ()
 Returns the class name. More...
 
template<typename T >
static T * copyArray (T *a, int n)
 Return a deep copy of the specified array. More...
 
template<typename T >
static void delete2DArray (T **&a)
 Deletes the input 2D array reference and sets it to null. More...
 
template<typename T >
static void delete2DArrayOfArrays (T **&a, int ni)
 Deletes the input 2D array of arrays reference and sets it to null. More...
 
template<typename T >
static void delete3DArray (T ***&a)
 Deletes the input 3D array reference and sets it to null. More...
 
static string dtos (double d, const string &frmt="%.14f")
 
static bool fileExists (const string &fileName)
 
static string ftos (float f, const string &frmt="%.6f")
 
static const string getOpSys ()
 Returns the operating system type. More...
 
static void getProperties (const string &str, map< string, string > &props)
 Retrieves all properties defined in the input string str and saves them into the property map props. More...
 
static bool getProperty (const map< string, string > &props, const string &tag, string &value)
 Retrieves the "value" associated with "tag" from the property map "props". More...
 
static string insertPathSeparator (const string &dir, const string &name)
 combine the two path components together, inserting a path separator only if necessary. More...
 
static bool isBigEndian ()
 Return true if file read / write system is big endian. More...
 
static bool isint (const string &i)
 Returns True if string i can be represented as an integer. More...
 
static string itos (int i, const string &frmt="%d")
 Static functions that returns the input integer, float, double, or boolean, as a string. More...
 
static string lowercase_string (const string &str)
 These functions convert the input string to all lower/upper case characters. More...
 
static string ltos (LONG_INT l, const string &frmt="%llu")
 
template<typename T >
static void minmax (const vector< T > &v, T &mn, T &mx)
 Returns the minimum (mn) and maximum (mx) of the input vector v. More...
 
template<typename T >
static T ** new2DArray (int ni, int nj)
 Returns a new intrinsic 2D array of size [ni][nj]. More...
 
template<typename T >
static T ** new2DArrayOfArrays (int ni, int nj)
 Create a 2D array of arrays (Java style). More...
 
template<typename T >
static T *** new3DArray (int ni, int nj, int nk)
 Returns a new intrinsic 3D array of size [ni][nj]. More...
 
static void removeEOL (string &s)
 Removes '/r', '/n', or '/r/n' from the end of the input string if it exists. More...
 
static void removePathSeparator (string &path)
 If the supplied path ends with a path separator, remove it. More...
 
template<typename T >
static void resetArray (int n, T *array, T val)
 Resets all n entries in array to val. More...
 
static bool stob (const string &b)
 
static double stod (const string &d, const string &frmt="%lf")
 
static float stof (const string &f, const string &frmt="%f")
 
static int stoi (const string &i, const string &frmt="%d")
 Static functions that returns the input string as an integer, float, double, or boolean. More...
 
static LONG_INT stol (const string &i64, const string &frmt="%llu")
 
static string stringReplaceAll (const string &sf, const string &sr, const string &s)
 Replaces all occurrences of sf in string s with sr on output and returns the new string. More...
 
static double toDegrees (double a)
 Returns input radian measure in degrees. More...
 
static void tokenizeString (const string &str, const string &delim, vector< string > &tokens)
 This function tokenizes the input string, str, into a set of tokens given a set of delimiters specified in delim. More...
 
static double toRadians (double a)
 Returns input degrees measure in radians. More...
 
static string trim (const string &str, const string &delim=" \t")
 These functions return the input string (str) without any leading (trimLeft) or trailing (trimRight) delimiters (delim ... More...
 
static string trimLeft (const string &str, const string &delim=" \t")
 
static string trimRight (const string &str, const string &delim=" \t")
 
static string uppercase_string (const string &str)
 

Static Public Attributes

static char const FILE_SEP
 Path separator. More...
 
static string const NEWLINE
 End-of-line string. More...
 
static const int SBOL
 Standard sizes of basic intrinsics. More...
 
static const int SBYT
 
static const int SDBL
 
static const int SFLT
 
static const int SINT
 
static const int SLNG
 
static const int SSHT
 

Detailed Description

Basic static utility functions and variables.

The CPPUtils class provides basic system level static utility functions for GeoTess.

Constructor & Destructor Documentation

geotess::CPPUtils::CPPUtils ( )
inline

Default constructor.

virtual geotess::CPPUtils::~CPPUtils ( )
inlinevirtual

Protected destructor ...

made virtual as is usual practice.

Member Function Documentation

void geotess::CPPUtils::addPathSeparator ( string &  path)
inlinestatic

If the supplied path does not already end with a path separator, append it to the end.

On windows, use '\', otherwise '/'.

static string geotess::CPPUtils::btos ( bool  b)
static
static string geotess::CPPUtils::class_name ( )
inlinestatic

Returns the class name.

Returns
class name
virtual int geotess::CPPUtils::class_size ( ) const
inlinevirtual

Returns the class size.

template<typename T >
static T* geotess::CPPUtils::copyArray ( T *  a,
int  n 
)
inlinestatic

Return a deep copy of the specified array.

template<typename T >
void geotess::CPPUtils::delete2DArray ( T **&  a)
inlinestatic

Deletes the input 2D array reference and sets it to null.

Delete and set to NULL a 2D array that was created with new2DArray()

template<typename T >
static void geotess::CPPUtils::delete2DArrayOfArrays ( T **&  a,
int  ni 
)
inlinestatic

Deletes the input 2D array of arrays reference and sets it to null.

template<typename T >
void geotess::CPPUtils::delete3DArray ( T ***&  a)
inlinestatic

Deletes the input 3D array reference and sets it to null.

Delete and set to NULL a 3D array that was created with new2DArray()

static string geotess::CPPUtils::dtos ( double  d,
const string &  frmt = "%.14f" 
)
static
static bool geotess::CPPUtils::fileExists ( const string &  fileName)
inlinestatic
static string geotess::CPPUtils::ftos ( float  f,
const string &  frmt = "%.6f" 
)
static
static const string geotess::CPPUtils::getOpSys ( )
static

Returns the operating system type.

static void geotess::CPPUtils::getProperties ( const string &  str,
map< string, string > &  props 
)
static

Retrieves all properties defined in the input string str and saves them into the property map props.

The properties must be of the form "name = value; name = value; ..." where the name value associations are set into the property map. All "names" are lower-cased into the property map. "values" are simply assigned without case change. All name and value pairs are stripped of leading and trailing blanks before placement into the property map. All properties must be separated by a semi-colon.

Parameters
strInput semicolon separated string of properties.
propsInput map that will be filled with the properties name –> value associations.
static bool geotess::CPPUtils::getProperty ( const map< string, string > &  props,
const string &  tag,
string &  value 
)
static

Retrieves the "value" associated with "tag" from the property map "props".

If the "tag" is found in props then true is returned and "value" is set. Otherwise, false is returned.

Parameters
propsThe input properties map (name = value).
tagThe input key for which an associated value will be sought.
valueThe returned value associated with the input tag ... if one was found.
Returns
True if the value was set.
string geotess::CPPUtils::insertPathSeparator ( const string &  dir,
const string &  name 
)
inlinestatic

combine the two path components together, inserting a path separator only if necessary.

static bool geotess::CPPUtils::isBigEndian ( )
static

Return true if file read / write system is big endian.

static bool geotess::CPPUtils::isint ( const string &  i)
static

Returns True if string i can be represented as an integer.

static string geotess::CPPUtils::itos ( int  i,
const string &  frmt = "%d" 
)
static

Static functions that returns the input integer, float, double, or boolean, as a string.

static string geotess::CPPUtils::lowercase_string ( const string &  str)
static

These functions convert the input string to all lower/upper case characters.

static string geotess::CPPUtils::ltos ( LONG_INT  l,
const string &  frmt = "%llu" 
)
static
template<typename T >
void geotess::CPPUtils::minmax ( const vector< T > &  v,
T &  mn,
T &  mx 
)
static

Returns the minimum (mn) and maximum (mx) of the input vector v.

Returns the minimum (mn) and maximum (mx) of the input v.

template<typename T >
static T** geotess::CPPUtils::new2DArray ( int  ni,
int  nj 
)
inlinestatic

Returns a new intrinsic 2D array of size [ni][nj].

Parameters
niFirst array dimension size.
njSecond array dimension size.
Returns
The new 2D array.
template<typename T >
static T** geotess::CPPUtils::new2DArrayOfArrays ( int  ni,
int  nj 
)
inlinestatic

Create a 2D array of arrays (Java style).

template<typename T >
static T*** geotess::CPPUtils::new3DArray ( int  ni,
int  nj,
int  nk 
)
inlinestatic

Returns a new intrinsic 3D array of size [ni][nj].

Parameters
niFirst array dimension size.
njSecond array dimension size.
nkThird array dimension size.
Returns
The new 2D array.
void geotess::CPPUtils::removeEOL ( string &  s)
inlinestatic

Removes '/r', '/n', or '/r/n' from the end of the input string if it exists.

void geotess::CPPUtils::removePathSeparator ( string &  path)
inlinestatic

If the supplied path ends with a path separator, remove it.

On windows, use '\', otherwise '/'.

template<typename T >
static void geotess::CPPUtils::resetArray ( int  n,
T *  array,
val 
)
inlinestatic

Resets all n entries in array to val.

static bool geotess::CPPUtils::stob ( const string &  b)
static
static double geotess::CPPUtils::stod ( const string &  d,
const string &  frmt = "%lf" 
)
static
static float geotess::CPPUtils::stof ( const string &  f,
const string &  frmt = "%f" 
)
static
static int geotess::CPPUtils::stoi ( const string &  i,
const string &  frmt = "%d" 
)
static

Static functions that returns the input string as an integer, float, double, or boolean.

static LONG_INT geotess::CPPUtils::stol ( const string &  i64,
const string &  frmt = "%llu" 
)
static
static string geotess::CPPUtils::stringReplaceAll ( const string &  sf,
const string &  sr,
const string &  s 
)
static

Replaces all occurrences of sf in string s with sr on output and returns the new string.

double geotess::CPPUtils::toDegrees ( double  a)
inlinestatic

Returns input radian measure in degrees.

Returns
Input radian measure in degrees.
static void geotess::CPPUtils::tokenizeString ( const string &  str,
const string &  delim,
vector< string > &  tokens 
)
static

This function tokenizes the input string, str, into a set of tokens given a set of delimiters specified in delim.

For example, the string "May 15, 2002 5:56:20 pm" tokenized with the set of delimiters " ,:" would yield the set of 7 tokens given as "May", "15", "2002", "5", "56", "20", and "pm".

double geotess::CPPUtils::toRadians ( double  a)
inlinestatic

Returns input degrees measure in radians.

Returns
Input degrees measure in radians.
static string geotess::CPPUtils::trim ( const string &  str,
const string &  delim = " \t" 
)
static

These functions return the input string (str) without any leading (trimLeft) or trailing (trimRight) delimiters (delim ...

defaults to a space and a tab).

static string geotess::CPPUtils::trimLeft ( const string &  str,
const string &  delim = " \t" 
)
static
static string geotess::CPPUtils::trimRight ( const string &  str,
const string &  delim = " \t" 
)
static
static string geotess::CPPUtils::uppercase_string ( const string &  str)
static

Member Data Documentation

char const geotess::CPPUtils::FILE_SEP
static

Path separator.

'\' on Windows, '/' on unix-type systems.

string const geotess::CPPUtils::NEWLINE
static

End-of-line string.

"\r\n" on Windows, "\r" on MacOSX, "\n" on unix-type systems.

const int geotess::CPPUtils::SBOL
static

Standard sizes of basic intrinsics.

const int geotess::CPPUtils::SBYT
static
const int geotess::CPPUtils::SDBL
static
const int geotess::CPPUtils::SFLT
static
const int geotess::CPPUtils::SINT
static
const int geotess::CPPUtils::SLNG
static
const int geotess::CPPUtils::SSHT
static

The documentation for this class was generated from the following file: