GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

 gammalib
 

Functions

std::string gammalib::strip_whitespace (const std::string &arg)
 Strip leading and trailing whitespace from string. More...
 
std::string gammalib::strip_chars (const std::string &arg, const std::string &chars)
 Strip leading and trailing character from string. More...
 
std::string gammalib::rstrip_chars (const std::string &arg, const std::string &chars)
 Strip trailing character from string. More...
 
std::string gammalib::replace_segment (const std::string &arg, const std::string &segment, const std::string &replacement)
 Replace string segment in string. More...
 
std::string gammalib::expand_env (const std::string &arg)
 Expand environment variables in string. More...
 
std::string gammalib::filepath (const std::string &pathname, const std::string &filename)
 Build file path from path name and file name. More...
 
std::string gammalib::str (const unsigned short int &value)
 Convert unsigned short integer value into string. More...
 
std::string gammalib::str (const unsigned int &value)
 Convert unsigned integer value into string. More...
 
std::string gammalib::str (const unsigned long int &value)
 Convert unsigned long integer value into string. More...
 
std::string gammalib::str (const unsigned long long int &value)
 Convert unsigned long long integer value into string. More...
 
std::string gammalib::str (const short int &value)
 Convert short integer value into string. More...
 
std::string gammalib::str (const int &value)
 Convert integer value into string. More...
 
std::string gammalib::str (const long int &value)
 Convert long integer value into string. More...
 
std::string gammalib::str (const long long int &value)
 Convert long long integer value into string. More...
 
std::string gammalib::str (const float &value, const int &precision=0)
 Convert single precision value into string. More...
 
std::string gammalib::str (const double &value, const int &precision=0)
 Convert double precision value into string. More...
 
std::string gammalib::str (const std::complex< double > &value, const int &precision=0)
 Convert complex value into string. More...
 
char * gammalib::tochar (const std::string &arg)
 Convert string to C string. More...
 
short gammalib::toshort (const std::string &arg)
 Convert string into short value. More...
 
unsigned short gammalib::toushort (const std::string &arg)
 Convert string into unsigned short value. More...
 
int gammalib::toint (const std::string &arg)
 Convert string into integer value. More...
 
unsigned int gammalib::touint (const std::string &arg)
 Convert string into unsigned integer value. More...
 
long gammalib::tolong (const std::string &arg)
 Convert string into long value. More...
 
unsigned long gammalib::toulong (const std::string &arg)
 Convert string into unsigned long value. More...
 
long long gammalib::tolonglong (const std::string &arg)
 Convert string into long long value. More...
 
unsigned long long gammalib::toulonglong (const std::string &arg)
 Convert string into unsigned long long value. More...
 
float gammalib::tofloat (const std::string &arg)
 Convert string into single precision value. More...
 
double gammalib::todouble (const std::string &arg)
 Convert string into double precision value. More...
 
std::string gammalib::toupper (const std::string &s)
 Convert string to upper case. More...
 
std::string gammalib::tolower (const std::string &s)
 Convert string to lower case. More...
 
std::vector< std::string > gammalib::split (const std::string &s, const std::string &sep)
 Split string. More...
 
std::string gammalib::fill (const std::string &s, const int &n)
 Fill string with n strings of same type. More...
 
std::string gammalib::left (const std::string &s, const int &n, const char &c= ' ')
 Left justify string to achieve a length of n characters. More...
 
std::string gammalib::right (const std::string &s, const int &n, const char &c= ' ')
 Right justify string to achieve a length of n characters. More...
 
std::string gammalib::centre (const std::string &s, const int &n, const char &c= ' ')
 Centre string to achieve a length of n characters. More...
 
std::string gammalib::parformat (const std::string &s, const int &indent=0)
 Convert string in parameter format. More...
 
std::string gammalib::number (const std::string &noun, const int &number)
 Convert singular noun into number noun. More...
 
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. More...
 
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. More...
 
GEnergy gammalib::elogmean (const GEnergy &a, const GEnergy &b)
 Computes log mean energy. More...
 
bool gammalib::dir_exists (const std::string &dirname)
 Checks if directory exists. More...
 
bool gammalib::is_infinite (const double &x)
 Signal if argument is infinite. More...
 
bool gammalib::is_notanumber (const double &x)
 Signal if argument is not a number. More...
 
bool gammalib::contains (const std::string &str, const std::string &substring)
 Checks if a substring is in a string. More...
 
bool gammalib::contains (const std::vector< std::string > strings, const std::string &string)
 Checks if a string is contained in a vector of strings. More...
 
void gammalib::warning (const std::string &origin, const std::string &message)
 Emits warning. More...
 
std::string gammalib::xml2str (const std::string &arg)
 Convert XML character references in string to characters. More...
 
std::string gammalib::str2xml (const std::string &arg)
 Convert special characters in string to XML character references. More...
 
bool gammalib::xml_has_par (const GXmlElement &xml, const std::string &name)
 Checks if parameter with given name in XML element exists. More...
 
GXmlElementgammalib::xml_need_par (const std::string &origin, GXmlElement &xml, const std::string &name)
 Return pointer to parameter with given name in XML element. More...
 
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. More...
 
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. More...
 
void gammalib::xml_check_par (const std::string &origin, const std::string &name, const int &number)
 Checks whether a parameter has occured once. More...
 
GFilename gammalib::xml_file_expand (const GXmlElement &xml, const std::string &filename)
 Expand file name provided as XML attribute for loading. More...
 
GFilename gammalib::xml_file_reduce (const GXmlElement &xml, const std::string &filename)
 Reduce file name provided for writing as XML attribute. More...
 
void gammalib::xml_get_name_value_pair (const GXmlNode *node, std::string &name, std::string &value)
 Extract name / value pair from XML node. More...
 
int gammalib::recv (int fd, char *buffer, int len, int flags, int timeout)
 Checks whether a parameter has occured once. More...
 
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. More...
 

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
 

Detailed Description

Gammalib tools definition.

Author
Juergen Knoedlseder

Definition in file GTools.hpp.