forked from pierr3/ModeS
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Helpers.h
85 lines (71 loc) · 1.74 KB
/
Helpers.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
#pragma once
#include <vector>
#include <string>
#include <sstream>
#include <WinInet.h>
#include <algorithm>
#include <cctype>
#include <locale>
#include <EuroScopePlugIn.h>
#include "CCAMS.h"
using namespace std;
string LoadUpdateString();
string LoadWebSquawk(EuroScopePlugIn::CFlightPlan FP, EuroScopePlugIn::CController ATCO, vector<const char*> usedCodes, bool vicinityADEP, int ConnectionType);
string ESversion();
inline std::vector<std::string> split(const std::string & s, char delim)
{
std::istringstream ss(s);
std::string item;
std::vector<std::string> elems;
while (std::getline(ss, item, delim))
elems.push_back(item);
return elems;
}
// trim from start (in place)
static 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)
static 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)
static inline void trim(std::string& s) {
ltrim(s);
rtrim(s);
}
class modesexception
: public std::exception
{
public:
explicit modesexception(std::string & what) : std::exception { what.c_str() } {}
virtual inline const long icon() const = 0;
inline void whatMessageBox()
{
MessageBox(NULL, what(), "CCAMS", MB_OK | icon());
}
};
class error
: public modesexception
{
public:
explicit error(std::string && what) : modesexception { what } {}
inline const long icon() const
{
return MB_ICONERROR;
}
};
class warning
: public modesexception
{
public:
explicit warning(std::string && what) : modesexception { what } {}
inline const long icon() const
{
return MB_ICONWARNING;
}
};