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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "UrcClip.hpp"
using namespace at::urc;
auto Clip::isValid() const noexcept -> bool
{
return tokens.size() >= minParametersCount;
}
std::string Clip::getNumber() const
{
if (!isValid()) {
return std::string();
}
return tokens[magic_enum::enum_integer(Tokens::Number)];
};
std::optional<Clip::AddressType> Clip::getType() const
{
if (!isValid()) {
return std::nullopt;
}
auto addressType = utils::getNumericValue<int>(tokens[magic_enum::enum_integer(Tokens::Type)]);
constexpr auto addressTypes = magic_enum::enum_values<Clip::AddressType>();
for (const auto &type : addressTypes) {
if (magic_enum::enum_integer(type) == addressType) {
return type;
}
}
return std::nullopt;
};
std::optional<std::string> Clip::getSubaddr() const
{
size_t minNumOfParams = magic_enum::enum_integer(Tokens::Subaddr) + 1;
if (tokens.size() < minNumOfParams) {
return std::nullopt;
}
if (tokens[magic_enum::enum_integer(Tokens::Subaddr)].empty()) {
return std::nullopt;
}
return tokens[magic_enum::enum_integer(Tokens::Subaddr)];
};
std::optional<std::string> Clip::getSatype() const
{
size_t minNumOfParams = magic_enum::enum_integer(Tokens::Satype) + 1;
if (tokens.size() < minNumOfParams) {
return std::nullopt;
}
if (tokens[magic_enum::enum_integer(Tokens::Satype)].empty()) {
return std::nullopt;
}
return tokens[magic_enum::enum_integer(Tokens::Satype)];
};
std::optional<std::string> Clip::getAlpha() const
{
size_t minNumOfParams = magic_enum::enum_integer(Tokens::Alpha) + 1;
if (tokens.size() < minNumOfParams) {
return std::nullopt;
}
if (tokens[magic_enum::enum_integer(Tokens::Alpha)].empty()) {
return std::nullopt;
}
return tokens[magic_enum::enum_integer(Tokens::Alpha)];
};
std::optional<std::string> Clip::getCLIValidity() const
{
size_t minNumOfParams = magic_enum::enum_integer(Tokens::CLIValidity) + 1;
if (tokens.size() < minNumOfParams) {
return std::nullopt;
}
if (tokens[magic_enum::enum_integer(Tokens::CLIValidity)].empty()) {
return std::nullopt;
}
return tokens[magic_enum::enum_integer(Tokens::CLIValidity)];
};