NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / hfb.cpp
blobea5853c52827a4501ea308e23ce775a79fe9dec6
1 #include "hfb.hpp"
2 #include <marnav/nmea/io.hpp>
3 #include <marnav/utils/unique.hpp>
5 namespace marnav
7 namespace nmea
9 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(hfb)
11 constexpr const char * hfb::TAG;
13 hfb::hfb()
14 : sentence(ID, TAG, talker_id::global_positioning_system)
18 hfb::hfb(talker talk, fields::const_iterator first, fields::const_iterator last)
19 : sentence(ID, TAG, talk)
21 if (std::distance(first, last) != 4)
22 throw std::invalid_argument{"invalid number of fields in hfb"};
24 read(*(first + 0), distance_head_foot);
25 read(*(first + 1), distance_head_foot_unit);
26 read(*(first + 2), distance_head_bottom);
27 read(*(first + 3), distance_head_bottom_unit);
30 std::vector<std::string> hfb::get_data() const
32 return {to_string(distance_head_foot), to_string(distance_head_foot_unit),
33 to_string(distance_head_bottom), to_string(distance_head_bottom_unit)};