Utils: bitset update to e865429e8a6c17366105e985fd037e42261a1af9.
[marnav.git] / src / marnav / ais / message_06.cpp
blobdf62b036079654101c6a3e62f19cdf5f5aed3c75
1 #include "message_06.hpp"
3 namespace marnav
5 namespace ais
7 message_06::message_06()
8 : message(ID)
12 message_06::message_06(const raw & bits)
13 : message(ID)
15 if ((bits.size() < SIZE_BITS_HEAD) || (bits.size() > SIZE_BITS_MAX))
16 throw std::invalid_argument{"invalid number of bits in ais/message_06"};
17 read_data(bits);
20 void message_06::read_data(const raw & bits)
22 get(bits, repeat_indicator);
23 get(bits, mmsi);
24 get(bits, sequence_no);
25 get(bits, dest_mmsi);
26 get(bits, retransmit_flag);
27 get(bits, dac);
28 get(bits, fid);
30 payload = raw{bits.begin() + SIZE_BITS_HEAD, bits.end()};
33 raw message_06::get_data() const
35 raw bits(SIZE_BITS_HEAD);
37 bits.set(type(), 0, 6);
38 set(bits, repeat_indicator);
39 set(bits, mmsi);
40 set(bits, sequence_no);
41 set(bits, dest_mmsi);
42 set(bits, retransmit_flag);
43 set(bits, dac);
44 set(bits, fid);
46 bits.append(payload);
48 return bits;