MeteoIODoc  2.10.0
IOUtils.cc File Reference
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctype.h>
#include <unistd.h>
#include <algorithm>
#include <meteoio/IOUtils.h>
#include <meteoio/MathOptim.h>
#include <meteoio/Config.h>
#include <meteoio/dataClasses/MeteoData.h>
#include <meteoio/dataClasses/CoordsAlgorithms.h>

Namespaces

 mio
 
 mio::IOUtils
 

Functions

std::string mio::getLibVersion (const bool &short_version=false)
 Return the library version. 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...
 
void mio::IOUtils::stripComments (std::string &str)
 
void mio::IOUtils::stripComments (std::string &str, const char &comment_mk)
 
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::replace_all (std::string &input, const std::string &search, const std::string &format)
 Replace a substring within a given string by another one. More...
 
bool mio::IOUtils::isWhitespace (const char &c)
 
bool mio::IOUtils::isTwoSpaces (const char &a, const char &b)
 
bool mio::IOUtils::isTwoTabs (const char &a, const char &b)
 
bool mio::IOUtils::isInvalidChar (const char &c)
 
bool mio::IOUtils::isQuote (const char &c)
 
bool mio::IOUtils::isSpecialChar (const char &c, const std::set< char > &specialChars)
 
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...
 
void mio::IOUtils::toUpper (std::string &str)
 
void mio::IOUtils::toLower (std::string &str)
 
std::string mio::IOUtils::strToUpper (std::string str)
 
std::string mio::IOUtils::strToLower (std::string str)
 
bool mio::IOUtils::isNumeric (std::string str, const unsigned int &nBase)
 
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...
 
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...
 
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<>
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< double > (double &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 &))
 
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<>
bool mio::IOUtils::convertString< Coords > (Coords &t, std::string str, std::ios_base &(*f)(std::ios_base &))
 
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...
 
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::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

static const char mio::IOUtils::ALPHANUM [] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
 
static const char mio::IOUtils::NUM [] = "0123456789"