-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathCommonTools.h
89 lines (63 loc) · 2.08 KB
/
CommonTools.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <fstream>
#include <uuid/uuid.h>
#include <algorithm>
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
#include "zlib.h"
#include <stdint.h>
#include <memory.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "curl/curl.h"
using namespace std;
typedef struct
{
string strHost;
string strPort;
string strUser;
string strPassword;
string strDBName;
}DBInfo;
typedef struct {
char *memory;
size_t size;
}memoryStruct;
class CommonTools
{
public:
CommonTools();
~CommonTools();
public:
static string getCurrentPath();
static string getUUID();
static string unix2Standard(time_t nUnix);
static time_t standard2Unix(const char* szTimestamp);
static bool parseConf(string strConfPath,DBInfo& mySQLInfo,DBInfo& pgInfo,DBInfo& redisInfo,
string& strTrafficPublicURL,vector<string>& vecProvince,string& strNodeType);
static void split(const std::string &strSrc, const std::string &strPattern,std::vector<std::string>& resVec);
static bool decoderGz(uint8_t* src_data, uint32_t src_length, uint8_t* dest_data, uint32_t & dest_length);
static time_t getCurrentTime();
static string getCurrentTime_s();
static bool isLaunchProcess(time_t nCurrentTime,int nLaunchMinute);
static bool isLaunchProcessEx(time_t nCurrentTime,int nLaunchMinute);
static int getHour(time_t nCurrentTime);
static int getMinute(time_t nCurrentTime);
static int getSecond(time_t nCurrentTime);
static string toString(int nValue);
static string toString(double dfValue);
static string toString(long long llValue);
static string getIP();
static size_t writeMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp);
static void httpGet(const char* pszURL,memoryStruct* pMemData);
};