Build: add GCC-13, Clang-14, Clang-15, Clang-16, Clang-17
[marnav.git] / src / marnav / ais / message_06.cpp
blob8606306503d4fc572fa186ddafa5ffe8dae39fb1
1 #include <marnav/ais/message_06.hpp>
3 namespace marnav::ais
5 constexpr message_id message_06::ID;
6 constexpr std::size_t message_06::SIZE_BITS_HEAD;
7 constexpr std::size_t message_06::SIZE_BITS_MAX;
9 message_06::message_06()
10 : message(ID)
14 message_06::message_06(const raw & bits)
15 : message(ID)
17 if ((bits.size() < SIZE_BITS_HEAD) || (bits.size() > SIZE_BITS_MAX))
18 throw std::invalid_argument{"invalid number of bits in ais/message_06"};
19 read_data(bits);
22 void message_06::read_data(const raw & bits)
24 get(bits, repeat_indicator_);
25 get(bits, mmsi_);
26 get(bits, sequence_no_);
27 get(bits, dest_mmsi_);
28 get(bits, retransmit_flag_);
29 get(bits, dac_);
30 get(bits, fid_);
32 payload_ = raw{bits.begin() + SIZE_BITS_HEAD, bits.end()};
35 raw message_06::get_data() const
37 raw bits(SIZE_BITS_HEAD);
39 bits.set(type(), 0, 6);
40 set(bits, repeat_indicator_);
41 set(bits, mmsi_);
42 set(bits, sequence_no_);
43 set(bits, dest_mmsi_);
44 set(bits, retransmit_flag_);
45 set(bits, dac_);
46 set(bits, fid_);
48 bits.append(payload_);
50 return bits;