Skip to content

Commit 7b6ad8b

Browse files
committed
Remove ObisId::from_string. Remove DlmsParser::patterns(). Remove extra DlmsParser::register_pattern overloads
1 parent 83529e6 commit 7b6ad8b

4 files changed

Lines changed: 0 additions & 80 deletions

File tree

src/dlms_parser/dlms_parser.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ void DlmsParser::load_default_patterns() {
5050
axdr_parser_.register_pattern("swappedTagObis-value-scalerUnit", "TOW, TV, TSU", 100);
5151
}
5252

53-
void DlmsParser::register_pattern(const char* dsl) {
54-
axdr_parser_.register_pattern("CUSTOM", dsl, 0, ObisId{});
55-
}
56-
57-
void DlmsParser::register_pattern(const char* name, const char* dsl, const int priority) {
58-
axdr_parser_.register_pattern(name, dsl, priority, ObisId{});
59-
}
60-
6153
void DlmsParser::register_pattern(const char* name, const char* dsl, const int priority, const ObisId default_obis) {
6254
axdr_parser_.register_pattern(name, dsl, priority, default_obis);
6355
}

src/dlms_parser/dlms_parser.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ class DlmsParser final : NonCopyableAndNonMovable {
2121
// Load built-in patterns.
2222
void load_default_patterns();
2323

24-
void register_pattern(const char* dsl);
25-
void register_pattern(const char* name, const char* dsl, int priority = 0);
2624
void register_pattern(const char* name, const char* dsl, int priority, ObisId default_obis);
2725

28-
[[nodiscard]] std::span<const AxdrDescriptorPattern> patterns() const { return axdr_parser_.patterns(); }
29-
3026
// Parse a full frame (in-place). buf is modified during parsing.
3127
ParseResult parse(std::span<uint8_t> buf);
3228

src/dlms_parser/obis_id.h

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <compare>
55
#include <cstdio>
66
#include <cstdint>
7-
#include <optional>
87
#include <span>
98
#include <string_view>
109
#include <algorithm>
@@ -22,40 +21,6 @@ struct ObisId final {
2221

2322
[[nodiscard]] bool empty() const { return v == std::array<uint8_t, 6>{}; }
2423

25-
[[nodiscard]] static std::optional<ObisId> from_string(const std::string_view str) noexcept {
26-
std::array<uint8_t, 6> values{};
27-
size_t count = 0;
28-
size_t pos = 0;
29-
30-
while (pos < str.size()) {
31-
if (count == values.size()) return std::nullopt;
32-
if (str[pos] < '0' || str[pos] > '9') return std::nullopt;
33-
34-
unsigned value = 0;
35-
while (pos < str.size() && str[pos] >= '0' && str[pos] <= '9') {
36-
value = value * 10U + static_cast<unsigned>(str[pos] - '0');
37-
if (value > 255U) return std::nullopt;
38-
++pos;
39-
}
40-
41-
values[count++] = static_cast<uint8_t>(value);
42-
43-
if (pos == str.size()) break;
44-
if (str[pos] != '.' && str[pos] != '-') return std::nullopt;
45-
46-
++pos;
47-
if (pos == str.size()) return std::nullopt;
48-
}
49-
50-
if (count == 5) {
51-
values[5] = 255;
52-
} else if (count != values.size()) {
53-
return std::nullopt;
54-
}
55-
56-
return ObisId(values[0], values[1], values[2], values[3], values[4], values[5]);
57-
}
58-
5924
[[nodiscard]] std::string_view to_string(std::span<char> buffer) const {
6025
if (buffer.empty()) return {};
6126
const int len = snprintf(buffer.data(), buffer.size(), "%u.%u.%u.%u.%u.%u", v[0], v[1], v[2], v[3], v[4], v[5]);

tests/test_obis_id.cpp

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)