summaryrefslogtreecommitdiff
path: root/Transceiver/TCIProtocol.hpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:28 +0200
commit69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch)
treeebc98370a697a9bbd6b973a14fa5113c475c6db7 /Transceiver/TCIProtocol.hpp
parent3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff)
parent059831534c7e884f0a607ed86b582fd00d821731 (diff)
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg' with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'Transceiver/TCIProtocol.hpp')
-rw-r--r--Transceiver/TCIProtocol.hpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/Transceiver/TCIProtocol.hpp b/Transceiver/TCIProtocol.hpp
new file mode 100644
index 00000000..9dd2b3dd
--- /dev/null
+++ b/Transceiver/TCIProtocol.hpp
@@ -0,0 +1,41 @@
+#ifndef TCI_PROTOCOL_HPP__
+#define TCI_PROTOCOL_HPP__
+
+#include <QString>
+#include <QtGlobal>
+
+namespace TciProtocol
+{
+ inline bool parse_frequency (QString const& text, quint64 * frequency)
+ {
+ if (!frequency || text.isEmpty ())
+ {
+ return false;
+ }
+
+ for (auto const character : text)
+ {
+ if (character < QLatin1Char {'0'} || character > QLatin1Char {'9'})
+ {
+ return false;
+ }
+ }
+
+ bool ok {false};
+ auto const parsed = text.toULongLong (&ok, 10);
+ if (!ok)
+ {
+ return false;
+ }
+
+ *frequency = parsed;
+ return true;
+ }
+
+ inline bool frequency_difference_exceeds (quint64 lhs, quint64 rhs, quint64 threshold)
+ {
+ return lhs > rhs ? lhs - rhs > threshold : rhs - lhs > threshold;
+ }
+}
+
+#endif