MeteoIODoc  2.10.0
IOUtils.h File Reference
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#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::OperationMode {
  mio::IOUtils::STD , mio::IOUtils::VSTATIONS , mio::IOUtils::GRID_1DINTERPOLATE , mio::IOUtils::GRID_EXTRACT ,
  mio::IOUtils::GRID_EXTRACT_PTS , mio::IOUtils::GRID_SMART , mio::IOUtils::GRID_ALL , mio::IOUtils::GRID_RESAMPLE
}
 Keywords for mode of operation. Please keep all the GRID_xxx last! More...
 
enum  mio::IOUtils::ThrowOptions { mio::IOUtils::dothrow , mio::IOUtils::nothrow }
 

Functions

std::string mio::getLibVersion (const bool &short_version=false)
 Return the library version. More...
 
double mio::IOUtils::C_TO_K (const double &T)
 
double mio::IOUtils::K_TO_C (const double &T)
 
double mio::IOUtils::UV_TO_DW (const double &U, const double &V)
 From wind speed components (u,v) to wind direction, following standard meteorological definitions: U is positive with positive easting/longitude. V is positive with positive northing/latitude. Direction is the angle the wind comes from. More...
 
double mio::IOUtils::VWDW_TO_U (const double &VW, const double &DW)
 From wind speed and direction to u component (west-to-east) More...
 
double mio::IOUtils::VWDW_TO_V (const double &VW, const double &DW)
 From wind speed and direction to v component (south-to-north) More...
 
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...
 
std::string mio::IOUtils::getDomainName ()
 Retrieve the domain 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...
 
std::string mio::IOUtils::trim (const std::string &s)
 Removes trailing and leading whitespaces, tabs and newlines from a string. More...
 
void mio::IOUtils::stripComments (std::string &str)
 
void mio::IOUtils::stripComments (std::string &str, const char &comment_mk)
 
void mio::IOUtils::replace_all (std::string &input, const std::string &search, const std::string &format)
 Replace a substring within a given string by another one. More...
 
void mio::IOUtils::removeDuplicateWhitespaces (std::string &line)
 Removes consecutive occurrences of spaces and tabs. More...
 
void mio::IOUtils::replaceWhitespaces (std::string &line, const char &rep='\0')
 Replaces spaces and tabs with a single character or removes them. More...
 
void mio::IOUtils::replaceInvalidChars (std::string &line, const char &rep='\0')
 Replaces invalid characters with a single character or removes them. More...
 
void mio::IOUtils::removeQuotes (std::string &line)
 Removes single and double quotation marks. More...
 
void mio::IOUtils::removeChars (std::string &line, const std::set< char > &specialChars)
 Removes any character present in the provided set from the given line. More...
 
void mio::IOUtils::cleanFieldName (std::string &field, const bool &clean_whitespaces=true, const char &rep='-')
 Cleans up a string to be usable as, for example, a parameter name. More...
 
size_t mio::IOUtils::count (const std::string &input, const std::string &search)
 count how many times a substring appears in a string More...
 
size_t mio::IOUtils::FNV_hash (const std::string &text)
 Fowler/Noll/Vo hash function (FNV-1a) More...
 
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::readLineToSet (const std::string &line_in, std::set< std::string > &setString)
 
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)
 
size_t mio::IOUtils::readLineToVec (const std::string &line_in, std::vector< double > &vecRet, const char &delim)
 
template<class T >
std::string mio::IOUtils::toString (const T &t)
 
template<class T >
bool mio::IOUtils::convertString (T &t, 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, std::string str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< std::string > (std::string &t, std::string str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< bool > (bool &t, std::string str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< char > (char &t, std::string str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< unsigned int > (unsigned int &t, std::string str, std::ios_base &(*f)(std::ios_base &))
 
template<>
bool mio::IOUtils::convertString< Coords > (Coords &t, std::string str, std::ios_base &(*f)(std::ios_base &))
 
bool mio::IOUtils::convertString (Date &t, std::string str, const double &time_zone, std::ios_base &(*f)(std::ios_base &))
 Convert a string to a date (template specialization of convertString) More...
 
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...
 
template<class T >
static void mio::IOUtils::parseArg (const std::pair< std::string, std::string > &arg, const std::string &algo, T &val)
 Parse a given named argument. 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::getProjectionParameters (const Config &cfg, std::string &coordin, std::string &coordinparam)
 A function that parses a Config object for COORSYS, COORDPARAM keywords in the [Input] 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...
 
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 char mio::IOUtils::cnodata = std::numeric_limits<char>::max()
 
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...