Program Listing for File Utils.h#
↰ Return to documentation for file (src/main/cpp/lib/Utils.h)
#ifndef UTILS_H_
#define UTILS_H_
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <iostream>
#include <stdexcept>
#include <climits>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <unistd.h>
#define TO_STRING_HELPER(a) #a
#define TO_STRING(a) TO_STRING_HELPER(a)
namespace Util
{
std::string
read_file (const std::string & fpath);
void
write_file (const std::string & fpath, const std::string & content);
std::vector<std::string>
split (const std::string & str, const std::string & delims,
bool remove_empty = true, bool quoted_names = true);
std::string
strip (const std::string & str);
inline std::string
get_cwd (void)
{
char cwd[1000];
getcwd (cwd, sizeof(cwd));
return std::string (cwd);
}
inline bool
double_equal (double a, double b, int ulp = 15)
{
double eps = std::numeric_limits<double>::epsilon (), min =
std::numeric_limits<double>::min ();
return std::abs (a - b) <= eps * std::abs (a + b) * ulp
|| std::abs (a - b) < min;
}
const std::string BLANKS = " \t";
}
#endif /* UTILS_H_ */