35#include <sys/select.h>
37#include <sys/socket.h>
38#include <netinet/in.h>
67#if defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
69#include <sys/resource.h>
70#if defined(__APPLE__) && defined(__MACH__)
72#elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
75#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
85#define G_XML2STRING "gammalib::xml2string(std::string&)"
86#define G_HTTP_QUERY "gammalib::http_query(str::string&, std::string&)"
89#define G_PARFORMAT_LENGTH 29
90#define G_CHAR_BUFFER 256
114 const std::string& chars)
123 std::string::size_type start = arg.find_first_not_of(chars);
124 std::string::size_type stop = arg.find_last_not_of(chars);
127 if (start != std::string::npos && stop != std::string::npos) {
131 result = arg.substr(start, stop-start+1);
151 const std::string& chars)
160 std::string::size_type stop = arg.find_last_not_of(chars);
163 if (stop != std::string::npos) {
164 result = arg.substr(0, stop+1);
188 const std::string& segment,
189 const std::string& replacement)
192 std::string result = arg;
195 std::string::size_type pos = 0;
196 std::string::size_type start = 0;
199 while (start != std::string::npos) {
200 start = result.find(segment, pos);
201 if (start != std::string::npos) {
202 result = result.replace(start, segment.length(), replacement);
203 pos = start + replacement.length();
236 static const char* begin_delim[] = {
"$ENV{",
"$ENV(",
"${",
"$(",
"$",
"~" };
237 static const char* end_delim[] = {
"}",
")",
"}",
")",
"/",
"/" };
238 static const int num_delim = 6;
241 std::string result = arg;
245 bool in_quote =
false;
248 while (index < result.length()) {
252 if (result[index] ==
'\\') {
258 if (result[index] ==
'\'') {
259 in_quote = !in_quote;
272 size_t begin_length = 0;
274 for (; delim_idx < num_delim; ++delim_idx) {
275 size_t len = std::strlen(begin_delim[delim_idx]);
276 if (result.compare(index, len, begin_delim[delim_idx]) == 0) {
283 if (begin_length > 0) {
291 size_t i_start = index + begin_length;
292 size_t i_end = i_start;
293 size_t end_length = 0;
294 if (delim_idx == 4 || delim_idx == 5) {
295 while (i_end < result.length() &&
296 result.compare(i_end, 1,
"/") != 0 &&
297 result.compare(i_end, 1,
" ") != 0) {
302 end_length = std::strlen(end_delim[delim_idx]);
303 while (i_end < result.length() &&
304 result.compare(i_end, end_length, end_delim[delim_idx]) != 0) {
311 if (i_end < result.length() || delim_idx == 4) {
314 std::string name = result.substr(i_start, i_end-i_start);
315 size_t name_length = name.length();
318 const char* env = NULL;
321 if (delim_idx == 5) {
322 if (name_length == 0) {
323 if ((env = std::getenv(
"HOME")) == NULL) {
324 struct passwd *pw = getpwuid(getuid());
332 env = std::getenv(
"PWD");
334 else if (name ==
"-") {
335 env = std::getenv(
"OLDPWD");
338 struct passwd *pw = getpwnam(name.c_str());
348 env = std::getenv(name.c_str());
356 result.erase(index, begin_length+name_length+end_length);
359 std::string replace(env);
360 size_t replace_length = replace.length();
363 result.insert(index, replace);
366 index += replace_length;
413 const std::string& filename)
419 if (pathname.empty()) {
425 filepath = pathname +
"/" + filename;
443 char default_tmpdir[] =
"/tmp";
448 if ((tmpdir = std::getenv(
"TEMP")) == NULL) {
449 if ((tmpdir = std::getenv(
"TMP")) == NULL) {
450 if ((tmpdir = std::getenv(
"TMPDIR")) == NULL) {
451 tmpdir = default_tmpdir;
461 strcat(filename, tmpdir);
462 strcat(filename,
"/gammalibXXXXXX");
465 int fd = mkstemp(filename);
466 std::string tmpname(filename);
490 const char* ptr = std::getenv(arg.c_str());
494 env = std::string(ptr);
510 std::ostringstream s_value;
512 return s_value.str();
524 std::ostringstream s_value;
526 return s_value.str();
538 std::ostringstream s_value;
540 return s_value.str();
552 std::ostringstream s_value;
554 return s_value.str();
566 std::ostringstream s_value;
568 return s_value.str();
585 sprintf(buffer, fmt.c_str(), value);
588 std::string str_buffer(buffer);
603 std::ostringstream s_value;
605 return s_value.str();
617 std::ostringstream s_value;
619 return s_value.str();
637 std::ostringstream s_value;
642 s_value.precision(precision);
643 s_value.setf(std::ios::fixed, std::ios::floatfield);
646 s_value.precision(7);
653 std::string result = s_value.str();
674 std::ostringstream s_value;
679 s_value.precision(precision);
680 s_value.setf(std::ios::fixed, std::ios::floatfield);
683 s_value.precision(15);
690 std::string result = s_value.str();
708 const int& precision)
711 std::ostringstream s_value;
716 s_value.precision(precision);
717 s_value.setf(std::ios::fixed, std::ios::floatfield);
720 s_value.precision(15);
724 s_value << value.real();
725 if (value.imag() < 0.0) {
731 s_value << std::abs(value.imag()) <<
"j";
734 std::string result = s_value.str();
749 struct std::tm timeStruct;
754 now = std::time(NULL);
756 std::gmtime_r(&now, &timeStruct);
758 std::memcpy(&timeStruct, gmtime(&now),
sizeof(
struct tm));
762 std::sprintf(buffer,
"%04d-%02d-%02dT%02d:%02d:%02d",
763 timeStruct.tm_year + 1900,
764 timeStruct.tm_mon + 1,
771 std::string date = buffer;
789 char*
str =
new char[arg.length()+1];
792 for (std::size_t i = 0; i < arg.length(); ++i) {
797 str[arg.length()] =
'\0';
812 std::istringstream iss(arg);
814 iss >> std::dec >> result;
827 std::istringstream iss(arg);
828 unsigned short result;
829 iss >> std::dec >> result;
842 std::istringstream iss(arg);
844 iss >> std::dec >> result;
857 std::istringstream iss(arg);
859 iss >> std::dec >> result;
872 std::istringstream iss(arg);
874 iss >> std::dec >> result;
887 std::istringstream iss(arg);
888 unsigned long result;
889 iss >> std::dec >> result;
902 std::istringstream iss(arg);
904 iss >> std::dec >> result;
917 std::istringstream iss(arg);
918 unsigned long long result;
919 iss >> std::dec >> result;
932 std::istringstream iss(arg);
934 iss >> std::dec >> result;
947 std::istringstream iss(arg);
949 iss >> std::dec >> result;
963 std::transform(s.begin(), s.end(), s.begin(), ::toupper);
977 std::transform(s.begin(), s.end(), s.begin(), ::tolower);
1003 const std::string& sep)
1006 std::vector<std::string> result;
1009 std::size_t pos = 0;
1010 std::size_t len = s.length();
1013 while (pos < len && pos != std::string::npos) {
1017 std::size_t index = s.find_first_of(sep, pos);
1018 std::size_t n = std::string::npos;
1022 if (index != std::string::npos) {
1030 if (sep !=
" " && n == 0) {
1031 result.push_back(
"");
1034 result.push_back(s.substr(pos, n));
1038 pos = (index != std::string::npos) ? index + 1 : std::string::npos;
1043 if (sep !=
" " && pos == len) {
1044 result.push_back(
"");
1066 std::string result =
"";
1069 for (
int i = 0; i < n; ++i) {
1092 int n_right = n - s.length();
1095 std::string result = s +
fill(std::string(1,c), n_right);
1116 int n_left = n - s.length();
1119 std::string result =
fill(std::string(1,c), n_left) + s;
1140 int n_right = (n-s.length()) / 2;
1141 int n_left = n - s.length() - n_right;
1144 std::string result =
fill(std::string(1,c), n_left) + s +
1145 fill(std::string(1,c), n_right);
1169 std::string result =
" " + s +
" " +
fill(
".", n_right) +
": ";
1189 std::string result(noun);
1220 const double& epivot,
const double& gamma)
1230 double exponent = gamma + 1.0;
1231 if (std::abs(exponent) > 1.0e-11) {
1232 double xmin = emin / epivot;
1233 double xmax = emax / epivot;
1234 flux = epivot / exponent * (std::pow(xmax, exponent) -
1235 std::pow(xmin, exponent));
1238 double ratio = emax / emin;
1239 flux = epivot * std::log(ratio);
1268 const double& epivot,
const double& gamma)
1278 double exponent = gamma + 2.0;
1279 double epivot2 = epivot * epivot;
1280 if (std::abs(exponent) > 1.0e-11) {
1281 double xmin = emin / epivot;
1282 double xmax = emax / epivot;
1283 flux = epivot2 / exponent * (std::pow(xmax, exponent) -
1284 std::pow(xmin, exponent));
1287 double ratio = emax / emin;
1288 flux = epivot2 * (std::log(ratio));
1315 elogmean.
MeV(std::pow(10.0, 0.5 * (eloga + elogb)));
1334 bool result =
false;
1343 if (ret == 0 && S_ISDIR(info.st_mode)) {
1364 bool result =
false;
1367 if (
str.find(substring) != std::string::npos) {
1386 const std::string&
string)
1389 bool result = std::find(strings.begin(), strings.end(),
string) !=
1406 const std::string& message)
1409 #if defined(G_WARNINGS)
1412 std::string
warning =
"+++ WARNING in " + origin +
": " + message;
1415 std::cout <<
warning << std::endl;
1441 size_t length = arg.length();
1449 while (pos < length) {
1454 start = arg.find(
"&", pos);
1455 if (start != std::string::npos) {
1468 stop = arg.find(
";", pos);
1469 if (stop != std::string::npos) {
1473 result += arg.substr(start-len, len);
1477 std::string cref = arg.substr(start+1, stop-start-1);
1478 len = cref.length();
1483 if (len >= 2 && cref[0] ==
'#') {
1485 if (cref[1] ==
'x') {
1486 number = (int)std::strtol(cref.substr(2,len-2).c_str(), NULL, 16);
1492 result.push_back((
char)
number);
1495 std::string msg =
"Could not extract number from "
1496 "numerical character reference &"+
1506 if (cref ==
"quot") {
1507 result.push_back((
char)34);
1509 else if (cref ==
"amp") {
1510 result.push_back((
char)38);
1512 else if (cref ==
"apos") {
1513 result.push_back((
char)39);
1515 else if (cref ==
"lt") {
1516 result.push_back((
char)60);
1518 else if (cref ==
"gt") {
1519 result.push_back((
char)62);
1522 std::string msg =
"Unknown character entity reference "
1523 "&"+cref+
"; encountered in XML string \""+
1538 std::string msg =
"Missing ; character at end of character "
1539 "reference in XML string \""+arg+
"\".";
1550 result += arg.substr(pos, len);
1574 for (
int i = 0; i < arg.length(); ++i) {
1577 std::string character = arg.substr(i, 1);
1580 if (character ==
"\"") {
1581 character =
""";
1583 else if (character ==
"&") {
1584 character =
"&";
1586 else if (character ==
"'") {
1587 character =
"'";
1589 else if (character ==
"<") {
1592 else if (character ==
">") {
1597 result += character;
1624 for (
int i = 0; i < n; ++i) {
1626 if (element->
attribute(
"name") == name) {
1658 const std::string& name)
1670 for (
int i = 0; i < n; ++i) {
1672 if (element->
attribute(
"name") == name) {
1710 const std::string& name)
1722 for (
int i = 0; i < n; ++i) {
1724 if (element->
attribute(
"name") == name) {
1759 const std::string& name,
1760 const std::string& attribute)
1763 std::string value =
"";
1770 std::string msg =
"Attribute \""+attribute+
"\" not found in XML "
1771 "parameter \""+name+
"\". Please verify the XML "
1804 " child elements in XML file does not correspond "
1806 " elements. Please verify the XML format.";
1812 int npars = xml.
elements(
"parameter");
1814 std::string msg =
"Number of "+
gammalib::str(npars)+
" \"parameter\" "
1815 "child elements in XML file does not correspond to "
1817 " elements. Please verify the XML format.";
1840 const std::string& type)
1849 std::string msg =
"Model type \""+xml.
attribute(
"type")+
"\" is not "
1850 "the expected type \""+type+
"\". Please verify "
1875 const std::string& name,
1880 std::string msg =
"Parameter \""+name+
"\" not found in XML element."
1881 " Please verify the XML format.";
1885 std::string msg =
"Parameter \""+name+
"\" found "+
1887 " Please verify the XML format.";
1909 const std::string& filename)
1919 size_t access_length = fname.
path().length();
1924 if (access_length == 0) {
1925 if (xml_length > 0) {
1931 else if (fname.
path()[0] !=
'/') {
1935 if (access_length >= xml_length) {
1966 const std::string& filename)
1975 size_t access_length = fname.
path().length();
1977 if (xml_length > 0) {
1978 if (access_length == xml_length) {
1980 fname = fname.
file();
1983 else if (access_length > xml_length) {
1985 std::string relpath = fname.
path().substr(xml_length, access_length-xml_length);
2023 name = text->
text();
2028 ptr = node->
element(
"value", 0);
2032 value = text->
text();
2063 FD_SET(fd, &readset);
2067 if (timeout >= 1000) {
2068 tv.tv_sec = timeout/1000;
2073 tv.tv_usec = timeout*1000;
2077 int result = select(fd+1, &readset, NULL, NULL, &tv);
2083 else if (result > 0 && FD_ISSET(fd, &readset)) {
2089 if ((iof = fcntl(fd, F_GETFL, 0)) != -1) {
2090 fcntl(fd, F_SETFL, iof | O_NONBLOCK);
2094 result = ::recv(fd, buffer, len, flags);
2098 fcntl(fd, F_SETFL, iof);
2127 const double& cosdist,
const double& sindist,
2128 const double& roi,
const double& cosroi)
2135 if (rad > roi) arclength = 0.0;
2147 if (dist > roi) arclength = 0.0;
2153 double d = roi - dist;
2157 else if (rad <= d) {
2161 double cosrad = std::cos(rad);
2162 double sinrad = std::sin(rad);
2163 double cosang = (cosroi - cosdist*cosrad) / (sindist*sinrad);
2165 #if defined(G_CHECK_FOR_NAN)
2168 std::cout <<
"roi_arclength: NaN occured";
2169 std::cout <<
" rad=" << rad;
2170 std::cout <<
" sinrad=" << sinrad;
2171 std::cout <<
" cosrad=" << cosrad;
2172 std::cout <<
" sindist=" << sindist;
2173 std::cout <<
" cosdist=" << cosdist;
2174 std::cout <<
" cosang=" << cosang;
2175 std::cout << std::endl;
2212 bool identity =
false;
2216 identity = std::abs(a - b) <= std::abs(a * tol);
2220 else if (b != 0.0) {
2221 identity = std::abs(a - b) <= std::abs(b * tol);
2252 const int portno = 80;
2256 char response[4096];
2257 memset(message, 0,
sizeof(message));
2258 memset(response, 0,
sizeof(response));
2261 sprintf(message,
"GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", query.c_str(), host.c_str());
2264 int sockfd = socket(AF_INET, SOCK_STREAM, 0);
2266 std::string msg =
"Unable to open socket.";
2271 struct hostent* server = gethostbyname(host.c_str());
2272 if (server == NULL) {
2273 std::string msg =
"Unable to find host \""+host+
"\".";
2278 struct sockaddr_in serveraddr;
2279 memset(&serveraddr, 0,
sizeof(serveraddr));
2280 serveraddr.sin_family = AF_INET;
2281 memcpy(&serveraddr.sin_addr.s_addr, server->h_addr, server->h_length);
2282 serveraddr.sin_port = htons(portno);
2285 if (connect(sockfd, (
struct sockaddr*)&serveraddr,
sizeof(serveraddr)) < 0) {
2286 std::string msg =
"Unable to connect to socket for host \""+host+
"\".";
2291 write(sockfd, message, strlen(message));
2294 read(sockfd, response,
sizeof(response)-1);
2300 return std::string(response);
2304#if defined(G_USE_CURL)
2348 static std::string country;
2351 if (country.empty()) {
2357 if ((!force_query) && (access(filename.
url().c_str(), R_OK) == 0)) {
2360 #pragma omp critical(GammaLib_host_country)
2365 lock.l_type = F_RDLCK;
2366 lock.l_whence = SEEK_SET;
2369 lock.l_pid = getpid();
2370 int fd = open(filename.
url().c_str(), O_RDONLY);
2374 fcntl(fd, F_SETLKW, &lock);
2378 FILE* fptr = fopen(filename.
url().c_str(),
"r");
2386 fgets(line, n-1, fptr);
2397 lock.l_type = F_UNLCK;
2398 fcntl(fd, F_SETLK, &lock);
2414 #if defined(G_USE_CURL)
2415 #if defined(G_HAS_CURL)
2420 #if defined(G_HAS_PERL)
2421 sprintf(command,
"a=$(perl -e 'alarm shift; exec \"curl --silent"
2422 " http://ip-api.com/line/?fields=countryCode"
2423 " 2>/dev/null\"' \"1\";);echo $a");
2424 #elif defined(G_HAS_TIMEOUT)
2425 sprintf(command,
"timeout 1s curl --silent http://ip-api.com/line/"
2426 "?fields=countryCode 2>/dev/null");
2428 sprintf(command,
"curl --silent http://ip-api.com/line/?fields=countryCode"
2433 FILE* file = popen(command,
"r");
2437 if (fgets(output,
sizeof(output)-1, file) != NULL) {
2448 std::string response =
http_query(
"ip-api.com",
"line/?fields=countryCode");
2449 std::vector<std::string> lines =
split(response,
"\n");
2451 for (
int i = 0; i < lines.size(); ++i) {
2456 if ((lines[i] ==
"\n") || (lines[i] ==
"\r") || (lines[i] ==
" ")) {
2461 catch (
const std::exception& e) {
2468 if (country.length() == 2) {
2471 #pragma omp critical(GammaLib_host_country)
2476 FILE* fptr = fopen(filename.
url().c_str(),
"w");
2478 fprintf(fptr,
"%s\n", country.c_str());
2509 uid_t uid = geteuid();
2510 struct passwd* pw = getpwuid(uid);
2512 filename = std::string(pw->pw_dir) +
"/.gamma/" + name;
2519 char* home_ptr = std::getenv(
"HOME");
2520 if (home_ptr != NULL) {
2521 filename = std::string(home_ptr) +
"/.gamma/" + name;
2526 filename =
"~/.gamma/" + name;
2547 #if defined(__APPLE__) && defined(__MACH__)
2548 #ifdef MACH_TASK_BASIC_INFO
2549 struct mach_task_basic_info info;
2550 mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
2551 if (task_info(mach_task_self( ), MACH_TASK_BASIC_INFO,
2552 (task_info_t)&info, &infoCount) == KERN_SUCCESS) {
2553 rss = (size_t)info.resident_size;
2556 struct task_basic_info info;
2557 mach_msg_type_number_t info_count = TASK_BASIC_INFO_COUNT;
2558 if (task_info(mach_task_self(), TASK_BASIC_INFO,
2559 (task_info_t)&info, &info_count) == KERN_SUCCESS) {
2560 rss = (size_t)info.resident_size;
2564 #elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
2566 if ((fp = fopen(
"/proc/self/statm",
"r" )) != NULL) {
2567 if (fscanf( fp,
"%*s%ld", &rss ) == 1) {
2568 rss *= (size_t)sysconf(_SC_PAGESIZE);
2591 double time = omp_get_wtime();
2593 double time = double(clock()) / (double)CLOCKS_PER_SEC;
Energy value class definition.
Exception handler interface definition.
Filename class interface definition.
FITS file class interface definition.
Mathematical function definitions.
XML element node class interface definition.
Abstract XML node base class interface definition.
XML text node class interface definition.
Class that handles energies in a unit independent way.
double MeV(void) const
Return energy in MeV.
double log10MeV(void) const
Return log10 of energy in MeV.
std::string path(void) const
Return access path.
std::string file(void) const
Return name of file.
std::string url(void) const
Return Uniform Resource Locator (URL)
bool is_empty(void) const
Signal if filename is empty.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
Abstract XML node base class.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
GFilename filename(void) const
Return filename of XML file.
virtual int elements(void) const
Return number of GXMLElement children of node.
const std::string & text(void) const
Return text.
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.
char * tochar(const std::string &arg)
Convert string to C string.
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 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.
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.
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.
double acos(const double &arg)
Computes acos by avoiding NaN due to rounding errors.
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.
unsigned short toushort(const std::string &arg)
Convert string into unsigned short value.
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.