-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.h
More file actions
64 lines (47 loc) · 1.11 KB
/
Utils.h
File metadata and controls
64 lines (47 loc) · 1.11 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include <utility>
#include <optional>
#include <type_traits>
#define CONCAT(X, Y) CONCAT_INNER(X, Y)
#define CONCAT_INNER(X,Y) X##Y
#define ON_SCOPE_EXIT( Action ) SA::Internal::ActionOnScopeExit CONCAT( _scopeExit, __COUNTER__ ) ( [&]() { Action } )
class String;
class NetworkClientSecure;
class WiFiMulti;
namespace SA::Internal
{
template< class T >
class ActionOnScopeExit
{
public:
ActionOnScopeExit( T func )
: m_func( std::move( func ) )
{}
~ActionOnScopeExit()
{
m_func();
}
private:
T m_func;
};
}
namespace SA::Utils
{
void InitializeSerial();
WiFiMulti InitializeWiFi();
void InitializeClock();
bool StrCmpIgnoreCase(const char* l, const char* r);
template<class T>
std::optional<T> ParseValue(const char* str)
{
static_assert(false, "Unsupported type");
}
template<>
std::optional<const char*> ParseValue<const char*>(const char* str);
template<>
std::optional<int> ParseValue<int>(const char* str);
template<>
std::optional<bool> ParseValue<bool>(const char* str);
template<>
std::optional<float> ParseValue<float>(const char* str);
}