-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.hpp
More file actions
42 lines (36 loc) · 885 Bytes
/
utils.hpp
File metadata and controls
42 lines (36 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef MY_RASPBERRYPI_UTILS_H
#define MY_RASPBERRYPI_UTILS_H
#include <stdexcept>
#include <exception>
#include <iostream>
#include <sstream>
namespace pi
{
#define DEBUG(x) do{ std::cout << x << std::endl; }while(false);
template<typename T>
inline std::string toString(const T& in)
{
std::stringstream ss;
ss << in;
return ss.str();
}
template<typename T>
inline T fromString(const std::string& in)
{
std::stringstream ss(in);
T out;
ss >> out;
return out;
}
class Inception : public std::runtime_error
{
public:
inline Inception(const std::string& in="",
const std::string& line = toString(__LINE__) ,
const std::string& func = toString(__PRETTY_FUNCTION__) ):std::runtime_error(in + " (" + line + ") " + func)
{
}
virtual ~Inception() noexcept {}
};
}
#endif // MY_RASPBERRYPI_UTILS_H