-
Notifications
You must be signed in to change notification settings - Fork 12
/
Util.h
executable file
·61 lines (47 loc) · 975 Bytes
/
Util.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
57
58
59
60
61
#ifndef UTIL_H
#define UTIL_H
#include <sstream>
using std::stringstream;
template<typename T>
T FromString(string key)
{
stringstream sstr(key);
T ret;
sstr >> ret;
return ret;
}
template<> bool FromString<bool>(string key);
template<> int FromString<int>(string key);
template<typename T>
string ToString(T key)
{
stringstream sstr;
sstr << key;
return sstr.str();
}
string ToString(bool key, string truestring="yes", string falsestring="no");
template<typename T>
void SetValue(uchar* pos, T value)
{
*(T*)pos = value;
}
template<typename T>
T GetValue(uchar* binary, uint pos)
{
return *(T*)&(binary[pos]);
}
uint EndianSwap(uint n);
#include <ctime>
clock_t ticker();
void Wait_ms(uint n);
string humantime();
struct Work
{
vector<uchar> data;
vector<uchar> target_share;
bool old;
clock_t time;
ullint ntime_at_getwork;
};
vector<string> Explode(string str, char delim);
#endif