-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
49 lines (41 loc) · 1.32 KB
/
common.h
File metadata and controls
49 lines (41 loc) · 1.32 KB
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
#pragma once
//#define NDEBUG
#if defined NDEBUG
#define TRACE( format, ... )
#else
#define TRACE( format, ... ) printf( "+++ %s::%s(%d) +++ " format, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__ )
#endif
//TDN Signature layuout
#define TDNSING_LEN 160
#define DATETIME_LEN 20
#define RANDOMNO_LEN 98
#define BANKNAME_LEN 10 // right padded with ~
#define SERVERIP_LEN 22 // right padded with ~
#define AMOUNT_LEN 10 // cents left padded with 0
#define MAX_AMOUNT 9999999.99
#define INITIAL_ISSUE 1 // TDN Initial Issuance
#define REDEMPTION 2 // TDN Redemption
#define REISSUANCE 3 // TDN Reissuance
#define CONSOLIDATE 4 // TDN Consolidation
#define SPLIT 5 // TDN Split
#include <algorithm>
#include <cctype>
#include <locale>
std::string FormatAmount(std::string& amount);
// trim from start (in place)
inline void ltrim(std::string& s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
}));
}
// trim from end (in place)
inline void rtrim(std::string& s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
return !std::isspace(ch);
}).base(), s.end());
}
// trim from both ends (in place)
inline void trim(std::string& s) {
ltrim(s);
rtrim(s);
}