17 explicit Fields(std::string_view body)
18 : _count(
NMEA::splitFields(body, _fields))
19 , _overflowed(_count == 0)
22 size_t size()
const {
return _count; }
26 std::string_view
operator[](
size_t index)
const {
return _fields[index]; }
28 std::string_view
back()
const {
return _count ? _fields[_count - 1] : std::string_view{}; }
38 std::array<std::string_view, 12> _fields{};
44bool number(std::string_view text, T& result)
46 if (text.empty() || text.front() ==
'+') {
49 const auto parsed = NMEA::number<T>(text);
58[[nodiscard]]
inline std::string_view
checkedBody(std::string_view line)
61 return wire && wire->hasValidChecksum() ? wire->body : std::string_view{};
64[[nodiscard]]
inline bool rejected(
const Fields& reply, std::string_view command)
67 return reply.
size() == 3 && reply[0] == command && reply[1] ==
"ERROR" && number(reply[2],
error);
73 if (reply.
size() == 2 && reply[0] == command && reply[1] ==
"OK") {
85 if ((reply.
size() > 2 || reply.
overflowed()) && reply[0] == command && reply[1] ==
"OK") {
Borrowed fields for the largest supported PQTM reply, including empty trailing fields.
std::string_view back() const
std::string_view operator[](size_t index) const
Fields(std::string_view body)
std::optional< Frame > frame(std::string_view text)
PQTM reply fields and the acknowledgement and readback rules every command shares.
GPSCommandOutcome acknowledgement(const Fields &reply, std::string_view command)
"<command>,OK" acknowledges and "<command>,ERROR,<code>" rejects a setting.
std::string_view checkedBody(std::string_view line)
The body of a checksum-valid "$<body>*hh" line; empty otherwise.
bool rejected(const Fields &reply, std::string_view command)
GPSCommandOutcome readback(const Fields &reply, std::string_view command, bool matches)