Build: add GCC-13, Clang-14, Clang-15, Clang-16, Clang-17
[marnav.git] / src / marnav / nmea / ais_helper.cpp
blob4a481cfa703e326141f226f286a4cea2b8c337ef
1 #include <marnav/nmea/ais_helper.hpp>
3 namespace marnav::nmea
5 /// Creates and returns a container of VDM sentences, created from the specified
6 /// payload.
7 ///
8 /// @param[in] payload The payload to create VDM sentences from.
9 /// @param[in] seq_msg_id The optional sequence message ID to be configured for
10 /// the resulting sentences.
11 /// @param[in] radio_channel Specifies which AIS radio channel to configure for
12 /// the resulting sentences.
13 /// @return Container of NMEA sentences containing VDM sentences.
14 std::vector<std::unique_ptr<nmea::sentence>> make_vdms(
15 const std::vector<std::pair<std::string, uint32_t>> & payload,
16 std::optional<uint32_t> seq_msg_id, ais_channel radio_channel)
18 std::vector<std::unique_ptr<nmea::sentence>> sentences;
20 for (uint32_t fragment = 0; fragment < payload.size(); ++fragment) {
21 auto sentence = std::make_unique<vdm>();
23 sentence->set_n_fragments(payload.size());
24 sentence->set_fragment(fragment + 1);
25 sentence->set_radio_channel(radio_channel);
26 sentence->set_payload(payload[fragment]);
28 if (seq_msg_id)
29 sentence->set_seq_msg_id(*seq_msg_id);
31 sentences.push_back(std::move(sentence));
34 return sentences;