NMEA: changed type of talker id from 'std::string' to its own type.
[marnav.git] / src / marnav / nmea / hdm.cpp
blob2d4c2f43b34c93e22561262b6be1e1b4b22673d2
1 #include "hdm.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(hdm)
10 constexpr const char * hdm::TAG;
12 hdm::hdm()
13 : sentence(ID, TAG, talker_id::magnetic_compass)
17 hdm::hdm(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 2)
21 throw std::invalid_argument{"invalid number of fields in hdm"};
23 read(*(first + 0), heading);
24 read(*(first + 1), heading_mag);
27 void hdm::set_heading(double t) noexcept
29 heading = t;
30 heading_mag = reference::MAGNETIC;
33 std::vector<std::string> hdm::get_data() const
35 return {to_string(heading), to_string(heading_mag)};