utils.h
469 Bytes
#ifndef UTILS_H
#define UTILS_H
#include <string.h>
#include <errno.h>
#include <string>
#include <list>
#include <limits>
template<typename T> int check(int rc)
{
if (rc < 0)
{
char *err = strerror(errno);
std::string msg(err);
throw T(msg);
}
return rc;
}
std::list<std::string> split(const std::string &input, const char sep, size_t max = std::numeric_limits<int>::max(), bool keep_empty_parts = true);
#endif // UTILS_H