-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.h
56 lines (41 loc) · 1 KB
/
utils.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef UTILS_H
#define UTILS_H
#include "RuntimeExceptionWithBacktrace.h"
// macht aus blah "blah"
#define _STR(x) _VAL(x)
#define _VAL(x) #x
#define ANSI_DEFAULT "\x1b[0m"
#define ANSI_RED "\x1b[31m"
#define ANSI_REDBOLD "\x1b[31;1m"
#define ANSI_GREEN "\x1b[32m"
#define ANSI_GREENBOLD "\x1b[32;1m"
extern const std::string NOT_SET;
extern bool cfg_debug;
extern int cfg_max_channels;
double getCurrentTime();
void printHex(const char *s, int len);
struct bufferEntry {
double time;
int value[8];
};
const int maxBufferEntries=1000;
extern bufferEntry ADCbuffer[];
extern int bufferPos;
#include <string>
#include <sstream>
namespace utils
{
template < typename T > std::string to_string( const T& n )
{
std::ostringstream stm ;
stm << n ;
return stm.str() ;
}
std::string format(const char* fmt, ...);
#ifdef NO_STD_STOD
double stod(const std::string &in);
#endif
bool stobool(const std::string &in);
bool startsWith(const std::string &str, const char *with);
}
#endif