GammaLib 2.0.0
Loading...
Searching...
No Matches
GTools.hpp File Reference

Gammalib tools definition. More...

#include <vector>
#include <string>
#include <complex>
#include <cmath>
#include <cfloat>

Go to the source code of this file.

Namespaces

namespace  gammalib
 

Functions

std::string gammalib::strip_whitespace (const std::string &arg)
 Strip leading and trailing whitespace from string.
 
std::string gammalib::strip_chars (const std::string &arg, const std::string &chars)
 Strip leading and trailing character from string.
 
std::string gammalib::rstrip_chars (const std::string &arg, const std::string &chars)
 Strip trailing character from string.
 
std::string gammalib::replace_segment (const std::string &arg, const std::string &segment, const std::string &replacement)
 Replace string segment in string.
 
std::string gammalib::expand_env (const std::string &arg)
 Expand environment variables in string.
 
std::string gammalib::filepath (const std::string &pathname, const std::string &filename)
 Build file path from path name and file name.
 
std::string gammalib::tmpnam (void)
 Return temporary file name.
 
std::string gammalib::getenv (const std::string &arg)
 Return value of environment variable.
 
std::string gammalib::str (const unsigned short int &value)
 Convert unsigned short integer value into string.
 
std::string gammalib::str (const unsigned int &value)
 Convert unsigned integer value into string.
 
std::string gammalib::str (const unsigned long int &value)
 Convert unsigned long integer value into string.
 
std::string gammalib::str (const unsigned long long int &value)
 Convert unsigned long long integer value into string.
 
std::string gammalib::str (const short int &value)
 Convert short integer value into string.
 
std::string gammalib::str (const int &value, const std::string &fmt="%d")
 Convert integer value into string.
 
std::string gammalib::str (const long int &value)
 Convert long integer value into string.
 
std::string gammalib::str (const long long int &value)
 Convert long long integer value into string.
 
std::string gammalib::str (const float &value, const int &precision=0)
 Convert single precision value into string.
 
std::string gammalib::str (const double &value, const int &precision=0)
 Convert double precision value into string.
 
std::string gammalib::str (const std::complex< double > &value, const int &precision=0)
 Convert complex value into string.
 
std::string gammalib::strdate (void)
 Return current date.
 
char * gammalib::tochar (const std::string &arg)
 Convert string to C string.
 
short gammalib::toshort (const std::string &arg)
 Convert string into short value.
 
unsigned short gammalib::toushort (const std::string &arg)
 Convert string into unsigned short value.
 
int gammalib::toint (const std::string &arg)
 Convert string into integer value.
 
unsigned int gammalib::touint (const std::string &arg)
 Convert string into unsigned integer value.
 
long gammalib::tolong (const std::string &arg)
 Convert string into long value.
 
unsigned long gammalib::toulong (const std::string &arg)
 Convert string into unsigned long value.
 
long long gammalib::tolonglong (const std::string &arg)
 Convert string into long long value.
 
unsigned long long gammalib::toulonglong (const std::string &arg)
 Convert string into unsigned long long value.
 
float gammalib::tofloat (const std::string &arg)
 Convert string into single precision value.
 
double gammalib::todouble (const std::string &arg)
 Convert string into double precision value.
 
std::string gammalib::toupper (const std::string &s)
 Convert string to upper case.
 
std::string gammalib::tolower (const std::string &s)
 Convert string to lower case.
 
std::vector< std::string > gammalib::split (const std::string &s, const std::string &sep)
 Split string.
 
std::string gammalib::fill (const std::string &s, const int &n)
 Fill string with n strings of same type.
 
std::string gammalib::left (const std::string &s, const int &n, const char &c=' ')
 Left justify string to achieve a length of n characters.
 
std::string gammalib::right (const std::string &s, const int &n, const char &c=' ')
 Right justify string to achieve a length of n characters.
 
std::string gammalib::centre (const std::string &s, const int &n, const char &c=' ')
 Centre string to achieve a length of n characters.
 
std::string gammalib::parformat (const std::string &s, const int &indent=0)
 Convert string in parameter format.
 
std::string gammalib::number (const std::string &noun, const int &number)
 Convert singular noun into number noun.
 
double gammalib::plaw_photon_flux (const double &emin, const double &emax, const double &epivot, const double &gamma)
 Compute photon flux between two energies for a power law.
 
double gammalib::plaw_energy_flux (const double &emin, const double &emax, const double &epivot, const double &gamma)
 Compute energy flux between two energies for a power law.
 
GEnergy gammalib::elogmean (const GEnergy &a, const GEnergy &b)
 Computes log mean energy.
 
bool gammalib::dir_exists (const std::string &dirname)
 Checks if directory exists.
 
bool gammalib::is_infinite (const double &x)
 Signal if argument is infinite.
 
bool gammalib::is_notanumber (const double &x)
 Signal if argument is not a number.
 
bool gammalib::contains (const std::string &str, const std::string &substring)
 Checks if a substring is in a string.
 
bool gammalib::contains (const std::vector< std::string > &strings, const std::string &string)
 Checks if a string is contained in a vector of strings.
 
void gammalib::warning (const std::string &origin, const std::string &message)
 Emits warning.
 
std::string gammalib::xml2str (const std::string &arg)
 Convert XML character references in string to characters.
 
std::string gammalib::str2xml (const std::string &arg)
 Convert special characters in string to XML character references.
 
bool gammalib::xml_has_par (const GXmlElement &xml, const std::string &name)
 Checks if parameter with given name in XML element exists.
 
GXmlElementgammalib::xml_need_par (const std::string &origin, GXmlElement &xml, const std::string &name)
 Return pointer to parameter with given name in XML element.
 
const GXmlElementgammalib::xml_get_par (const std::string &origin, const GXmlElement &xml, const std::string &name)
 Return pointer to parameter with given name in XML element.
 
std::string gammalib::xml_get_attr (const std::string &origin, const GXmlElement &xml, const std::string &name, const std::string &attribute)
 Return attribute value for a given parameter in XML element.
 
void gammalib::xml_check_parnum (const std::string &origin, const GXmlElement &xml, const int &number)
 Checks number of parameters.
 
void gammalib::xml_check_type (const std::string &origin, GXmlElement &xml, const std::string &type)
 Checks the model type.
 
void gammalib::xml_check_par (const std::string &origin, const std::string &name, const int &number)
 Checks whether a parameter has occured once.
 
GFilename gammalib::xml_file_expand (const GXmlElement &xml, const std::string &filename)
 Expand file name provided as XML attribute for loading.
 
GFilename gammalib::xml_file_reduce (const GXmlElement &xml, const std::string &filename)
 Reduce file name provided for writing as XML attribute.
 
void gammalib::xml_get_name_value_pair (const GXmlNode *node, std::string &name, std::string &value)
 Extract name / value pair from XML node.
 
int gammalib::recv (int fd, char *buffer, int len, int flags, int timeout)
 Checks whether a parameter has occured once.
 
double gammalib::roi_arclength (const double &rad, const double &dist, const double &cosdist, const double &sindist, const double &roi, const double &cosroi)
 Returns length of circular arc within circular ROI.
 
bool gammalib::compare (const double &a, const double &b, const double &tol)
 Compare two floating point values with tolerance.
 
std::string gammalib::http_query (const std::string &host, const std::string &query)
 Return response to a HTTP query.
 
std::string gammalib::host_country (const bool &force_query=false)
 Return two-digit host country code.
 
GFilename gammalib::gamma_filename (const std::string &name)
 Returns filename in .gamma directory.
 

Variables

const double gammalib::MeV2erg = 1.6021765e-6
 
const double gammalib::erg2MeV = 624150.96
 
const double gammalib::MeV2Angstrom = 1.239841875e-2
 
const double gammalib::pc2cm = 3.08568025e18
 
const double gammalib::sec_in_day = 86400.0
 
const double gammalib::sec2day = 1.0 / sec_in_day
 
const double gammalib::tai2tt = 32.184
 
const double gammalib::mec2 = 0.5109989461
 
const double gammalib::speed_of_light = 299792458.0
 

Detailed Description

Gammalib tools definition.

Author
Juergen Knoedlseder

Definition in file GTools.hpp.