From 059831534c7e884f0a607ed86b582fd00d821731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 26 Sep 2026 23:24:03 +0200 Subject: New upstream version 3.2.0~rc1+dfsg --- Transceiver/TCIProtocol.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Transceiver/TCIProtocol.hpp (limited to 'Transceiver/TCIProtocol.hpp') 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 +#include + +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 -- cgit v1.2.3