1 #include <marnav/nmea/r00.hpp>
2 #include <marnav/nmea/io.hpp>
7 constexpr sentence_id
r00::ID
;
8 constexpr const char * r00::TAG
;
9 constexpr int r00::max_waypoint_ids
;
12 : sentence(ID
, TAG
, talker::global_positioning_system
)
16 r00::r00(talker talk
, fields::const_iterator first
, fields::const_iterator last
)
17 : sentence(ID
, TAG
, talk
)
19 if (std::distance(first
, last
) != r00::max_waypoint_ids
)
20 throw std::invalid_argument
{"invalid number of fields in r00"};
22 for (auto i
= 0; i
< max_waypoint_ids
; ++i
) {
24 read(*(first
+ i
), id
);
25 set_waypoint_id(i
, id
);
29 void r00::append_data_to(std::string
& s
, const version
&) const
31 for (auto i
= 0; i
< max_waypoint_ids
; ++i
) {
32 if (waypoint_id_
[i
]) {
33 append(s
, waypoint_id_
[i
].value());
40 void r00::check_index(int index
) const
42 if ((index
< 0) || (index
>= max_waypoint_ids
))
43 throw std::out_of_range
{"waypoint ID out of range"};
46 std::optional
<waypoint
> r00::get_waypoint_id(int index
) const
49 return waypoint_id_
[index
];
52 void r00::set_waypoint_id(int index
, const waypoint
& id
)
55 waypoint_id_
[index
] = id
;