MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IOUtils.h File Reference
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <meteoio/dataClasses/Coords.h>
#include <meteoio/dataClasses/Date.h>
#include <meteoio/IOExceptions.h>
#include <meteoio/meteoLaws/Meteoconst.h>

Go to the source code of this file.

Namespaces

 mio
 
 mio::IOUtils
 

Enumerations

enum  mio::IOUtils::ProcessingLevel {
  mio::IOUtils::raw = 1, mio::IOUtils::filtered = 1 << 1, mio::IOUtils::resampled = 1 << 2, mio::IOUtils::generated = 1 << 3,
  mio::IOUtils::num_of_levels = 1 << 4
}
 
enum  mio::IOUtils::ThrowOptions { mio::IOUtils::dothrow, mio::IOUtils::nothrow }
 

Functions

std::string mio::getLibVersion ()
 Return the library version. More...
 
double mio::IOUtils::C_TO_K (const double &T)
 
double mio::IOUtils::K_TO_C (const double &T)
 
bool mio::IOUtils::checkEpsilonEquality (const double &val1, const double &val2, const double &epsilon)
 Check whether two values are equal regarding a certain epsilon environment (within certain radius of each other) More...
 
size_t mio::IOUtils::seek (const Date &soughtdate, const std::vector< MeteoData > &vecM, const bool &exactmatch=true)
 Search for an element at a given date in a vector of MeteoData. The position of the matching date is returned or IOUtils::npos if not found. If exactmatch=false, the position of the first element after soughtdate is returned (or IOUtils::npos if this is not possible / relevant). More...
 
double mio::IOUtils::bearing_to_angle (const double &bearing)
 Converts a compass bearing to a trigonometric angle. More...
 
double mio::IOUtils::angle_to_bearing (const double &angle)
 Converts a trigonometric angle to a compass bearing. More...
 
double mio::IOUtils::bearing (std::string bearing_str)
 Converts a string bearing to a compass bearing. More...
 
std::string mio::IOUtils::bearing (double bearing)
 Converts a compass bearing to a string bearing. More...
 
std::string mio::IOUtils::getLogName ()
 Retrieve the user name This checks various environment variables (USERNAME, USER, LOGNAME). More...
 
std::string mio::IOUtils::getHostName ()
 Retrieve the name of the computer running the binary. More...
 
void mio::IOUtils::trim (std::string &s)
 Removes trailing and leading whitespaces, tabs and newlines from a string. More...
 
void mio::IOUtils::stripComments (std::string &str)
 
bool mio::IOUtils::readKeyValuePair (const std::string &in_line, const std::string &delimiter, std::string &key, std::string &value, const bool &setToUpperCase=false)
 read a string line, parse it and save it into a map object, that is passed by reference More...
 
void mio::IOUtils::toUpper (std::string &str)
 
std::string mio::IOUtils::strToUpper (std::string str)
 
void mio::IOUtils::toLower (std::string &str)
 
std::string mio::IOUtils::strToLower (std::string str)
 
bool mio::IOUtils::isNumeric (std::string str, const unsigned int &nBase)
 
size_t mio::IOUtils::readLineToVec (const std::string &line_in, std::vector< double > &vec_data)
 
size_t mio::IOUtils::readLineToVec (const std::string &line_in, std::vector< std::string > &vecString)
 
size_t mio::IOUtils::readLineToVec (const std::string &line_in, std::vector< std::string > &vecString, const char &delim)
 
template<class T >
bool mio::IOUtils::convertString (T &t, const std::string &str, std::ios_base &(*f)(std::ios_base &)=std::dec)
 Convert a string to the requested type (template function). More...
 
template<>
bool mio::IOUtils::convertString< double > (double &t, const std::string &str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< std::string > (std::string &t, const std::string &str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< bool > (bool &t, const std::string &str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< unsigned int > (unsigned int &t, const std::string &str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< Coords > (Coords &t, const std::string &str, std::ios_base &(*f)(std::ios_base &))
 
bool mio::IOUtils::convertString (Date &t, const std::string &str, const double &time_zone, std::ios_base &(*f)(std::ios_base &))
 
template<class T >
void mio::IOUtils::getValueForKey (const std::map< std::string, std::string > &properties, const std::string &key, T &t, const ThrowOptions &options=IOUtils::dothrow)
 Returns, with the requested type, the value associated to a key (template function). More...
 
template<class T >
void mio::IOUtils::getValueForKey (const std::map< std::string, std::string > &properties, const std::string &key, std::vector< T > &vecT, const ThrowOptions &options=IOUtils::dothrow)
 Returns, with the requested type, the value associated to a key (template function). More...
 
template<class T >
mio::IOUtils::standardizeNodata (const T &value, const double &plugin_nodata)
 Standardize a given value to use MeteoIO's internal nodata value (if applicable) More...
 
void mio::IOUtils::getProjectionParameters (const Config &cfg, std::string &coordin, std::string &coordinparam, std::string &coordout, std::string &coordoutparam)
 A function that parses a Config object for COORSYS, COORDPARAM keywords in [Input] and [Output] section and sets the respective strings to the values of those keywords. More...
 
void mio::IOUtils::getTimeZoneParameters (const Config &cfg, double &tz_in, double &tz_out)
 A function that parses a Config object for the time_zone keyword and returns the timezone. More...
 
void mio::IOUtils::getArraySliceParams (const size_t &dimx, const size_t &nbworkers, const size_t &wk, size_t &startx, size_t &nx)
 Returns the parameters for splitting an array in several, balanced sub-arrays. This is mostly usefull for parallel calculations, where an array will be split and sent to different workers. More...
 
double mio::IOUtils::unitsPrefix (const char &prefix)
 Convert a textual representation of a unit prefix (like 'm' or 'G') to multiplying factor. More...
 
double mio::IOUtils::unitsConversion (const double &val, std::string unitIn, std::string unitOut)
 Performs simple unit conversion (supports temperature, prefixes and exponents) NOTE "composite" units such as 'K/m' or 'N/m2' are currently NOT supported. More...
 

Variables

const double mio::IOUtils::nodata = -999.0
 This is the internal nodata value. More...
 
const unsigned int mio::IOUtils::unodata = static_cast<unsigned int>(-1)
 
const int mio::IOUtils::inodata = -999
 
const short int mio::IOUtils::snodata = -999
 
const size_t mio::IOUtils::npos = static_cast<size_t>(-1)
 npos is the out-of-range value More...
 
const double mio::IOUtils::grid_epsilon = 5.
 What is an acceptable small distance on a grid, in meters. More...
 
const double mio::IOUtils::lon_epsilon = grid_epsilon / Cst::earth_R0 * Cst::to_deg
 in degrees. Small angle for longitudes, so sin(x)=x More...
 
const double mio::IOUtils::lat_epsilon = lon_epsilon
 in degrees. Small angle for latitudes. More...