NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / pgrmm.cpp
blob54fe50354a5a8320a11457860302d61ce4633cb6
1 #include "pgrmm.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(pgrmm)
10 constexpr const char * pgrmm::TAG;
12 pgrmm::pgrmm()
13 : sentence(ID, TAG, talker_id::none)
17 pgrmm::pgrmm(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 1)
21 throw std::invalid_argument{"invalid number of fields in pgrmm"};
23 read(*(first + 0), map_datum);
26 std::vector<std::string> pgrmm::get_data() const
28 return {to_string(map_datum)};
31 void pgrmm::set_map_datum(const std::string & t) noexcept
33 // in a regular NMEA sentence, there is only 72 characters for the map datum
34 if (t.size() <= 72) {
35 map_datum = t;
36 } else {
37 map_datum = t.substr(0, 72);