40#if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \
41 (defined __cplusplus && __cplusplus >= 201103L))
42#define gammalib_snprintf(O,S,F,A) std::snprintf(O,S,F,A)
43#define gammalib_vsnprintf(O,S,F,A) std::vsnprintf(O,S,F,A)
45#define gammalib_snprintf(O,S,F,A) std::sprintf(O,F,A)
46#define gammalib_vsnprintf(O,S,F,A) std::vsprintf(O,F,A)
60 const double pc2cm = 3.08568025e18;
64 const double mec2 = 0.5109989461;
72 const std::string& chars);
74 const std::string& chars);
76 const std::string& segment,
77 const std::string& replacement);
78 std::string
expand_env(
const std::string& arg);
79 std::string
filepath(
const std::string& pathname,
80 const std::string& filename);
82 std::string
getenv(
const std::string& arg);
83 std::string
str(
const unsigned short int& value);
84 std::string
str(
const unsigned int& value);
85 std::string
str(
const unsigned long int& value);
86 std::string
str(
const unsigned long long int& value);
87 std::string
str(
const short int& value);
88 std::string
str(
const int& value,
const std::string& fmt =
"%d");
89 std::string
str(
const long int& value);
90 std::string
str(
const long long int& value);
91 std::string
str(
const float& value,
const int& precision = 0);
92 std::string
str(
const double& value,
const int& precision = 0);
93 std::string
str(
const std::complex<double>& value,
94 const int& precision = 0);
96 short toshort(
const std::string& arg);
97 unsigned short toushort(
const std::string& arg);
98 int toint(
const std::string& arg);
99 unsigned int touint(
const std::string& arg);
100 long tolong(
const std::string& arg);
101 unsigned long toulong(
const std::string& arg);
103 unsigned long long toulonglong(
const std::string& arg);
104 float tofloat(
const std::string& arg);
105 double todouble(
const std::string& arg);
106 std::string
toupper(
const std::string& s);
107 std::string
tolower(
const std::string& s);
108 std::vector<std::string>
split(
const std::string& s,
const std::string& sep);
109 std::string
fill(
const std::string& s,
const int& n);
110 std::string
left(
const std::string& s,
const int& n,
111 const char& c =
' ');
112 std::string
right(
const std::string& s,
const int& n,
113 const char& c =
' ');
114 std::string
centre(
const std::string& s,
const int& n,
115 const char& c =
' ');
116 std::string
parformat(
const std::string& s,
const int& indent = 0);
117 std::string
number(
const std::string& noun,
const int&
number);
121 const double& epivot,
122 const double& gamma);
125 const double& epivot,
126 const double& gamma);
132 const std::string& substring);
133 bool contains(
const std::vector<std::string>& strings,
134 const std::string&
string);
135 void warning(
const std::string& origin,
136 const std::string& message);
137 std::string
xml2str(
const std::string& arg);
138 std::string
str2xml(
const std::string& arg);
140 const std::string& name);
143 const std::string& name);
146 const std::string& name);
149 const std::string& name,
150 const std::string& attribute);
156 const std::string& type);
158 const std::string& name,
161 const std::string& filename);
163 const std::string& filename);
168 const std::string& tag,
169 const std::string& name,
170 const std::string& value);
171 int recv(
int fd,
char *buffer,
int len,
int flags,
175 const double& cosdist,
176 const double& sindist,
178 const double& cosroi);
182 std::string
http_query(
const std::string& host,
183 const std::string& query);
184 std::string
host_country(
const bool& force_query =
false);
205 return (x < -DBL_MAX || x > DBL_MAX);
235 return ((*(uint8_t *)&e) == 1);
Class that handles energies in a unit independent way.
Abstract XML node base class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
GFilename gamma_filename(const std::string &name)
Returns filename in .gamma directory.
bool is_infinite(const double &x)
Signal if argument is infinite.
double 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.
std::string strdate(void)
Return current date.
std::string http_query(const std::string &host, const std::string &query)
Return response to a HTTP query.
bool is_notanumber(const double &x)
Signal if argument is not a number.
GEnergy elogmean(const GEnergy &a, const GEnergy &b)
Computes log mean energy.
long tolong(const std::string &arg)
Convert string into long value.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double todouble(const std::string &arg)
Convert string into double precision value.
std::string 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.
std::string order(const int &number)
Convert number into order noun.
std::string left(const std::string &s, const int &n, const char &c=' ')
Left justify string to achieve a length of n characters.
bool compare(const double &a, const double &b, const double &tol)
Compare two floating point values with tolerance.
std::string right(const std::string &s, const int &n, const char &c=' ')
Right justify string to achieve a length of n characters.
std::string replace_segment(const std::string &arg, const std::string &segment, const std::string &replacement)
Replace string segment in string.
std::string filepath(const std::string &pathname, const std::string &filename)
Build file path from path name and file name.
bool little_endian(void)
Signal if architecture stores integers as little endian.
std::string tolower(const std::string &s)
Convert string to lower case.
unsigned long long toulonglong(const std::string &arg)
Convert string into unsigned long long value.
int toint(const std::string &arg)
Convert string into integer value.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
std::string rstrip_chars(const std::string &arg, const std::string &chars)
Strip trailing character from string.
std::string xml2str(const std::string &arg)
Convert XML character references in string to characters.
GFilename xml_file_reduce(const GXmlElement &xml, const std::string &filename)
Reduce file name provided for writing as XML attribute.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
std::string str2xml(const std::string &arg)
Convert special characters in string to XML character references.
double 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.
float tofloat(const std::string &arg)
Convert string into single precision value.
std::string expand_env(const std::string &arg)
Expand environment variables in string.
unsigned long toulong(const std::string &arg)
Convert string into unsigned long value.
const double MeV2Angstrom
bool dir_exists(const std::string &dirname)
Checks if directory exists.
unsigned int touint(const std::string &arg)
Convert string into unsigned integer value.
bool contains(const std::string &str, const std::string &substring)
Checks if a substring is in a string.
std::string host_country(const bool &force_query=false)
Return two-digit host country code.
short toshort(const std::string &arg)
Convert string into short value.
double get_current_clock(void)
Get current clock in seconds.
std::string centre(const std::string &s, const int &n, const char &c=' ')
Centre string to achieve a length of n characters.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
std::string tmpnam(void)
Return temporary file name.
void xml_get_name_value_pair(const GXmlNode *node, std::string &name, std::string &value)
Extract name / value pair from XML node.
void warning(const std::string &origin, const std::string &message)
Emits warning.
const GXmlElement * xml_get_element_by_attribute(const GXmlElement *element, const std::string &tag, const std::string &name, const std::string &value)
Return XML element for a given tag and name/value attribute.
unsigned short toushort(const std::string &arg)
Convert string into unsigned short value.
const double speed_of_light
double 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.
std::string fill(const std::string &s, const int &n)
Fill string with n strings of same type.
std::string getenv(const std::string &arg)
Return value of environment variable.
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
void xml_check_par(const std::string &origin, const std::string &name, const int &number)
Checks whether a parameter has occured once.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
int recv(int fd, char *buffer, int len, int flags, int timeout)
Checks whether a parameter has occured once.
std::string toupper(const std::string &s)
Convert string to upper case.
GFilename xml_file_expand(const GXmlElement &xml, const std::string &filename)
Expand file name provided as XML attribute for loading.
long long tolonglong(const std::string &arg)
Convert string into long long value.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.
std::string strip_chars(const std::string &arg, const std::string &chars)
Strip leading and trailing character from string.
size_t get_current_rss(void)
Get current resident set size (physical memory use) in Bytes.