Build: add test presets
[marnav.git] / src / marnav / ais / message_13.cpp
blobc366c24ac0786d2a5796bc02679a5a54e9b740bf
1 #include <marnav/ais/message_13.hpp>
3 namespace marnav
5 namespace ais
7 constexpr message_id message_13::ID;
8 constexpr std::size_t message_13::SIZE_BITS_MIN;
9 constexpr std::size_t message_13::SIZE_BITS_MAX;
11 message_13::message_13()
12 : message(ID)
16 message_13::message_13(const raw & bits)
17 : message(ID)
19 if ((bits.size() < SIZE_BITS_MIN) || (bits.size() > SIZE_BITS_MAX))
20 throw std::invalid_argument{"invalid number of bits in ais/message_13"};
21 read_data(bits);
24 void message_13::read_data(const raw & bits)
26 get(bits, repeat_indicator);
27 get(bits, mmsi);
28 get(bits, mmsi_1);
29 get(bits, mmsi_seq_1);
31 if (bits.size() > SIZE_BITS_MIN + 1 * 32) {
32 get(bits, mmsi_2);
33 get(bits, mmsi_seq_2);
35 if (bits.size() > SIZE_BITS_MIN + 2 * 32) {
36 get(bits, mmsi_3);
37 get(bits, mmsi_seq_3);
39 if (bits.size() > SIZE_BITS_MIN + 3 * 32) {
40 get(bits, mmsi_4);
41 get(bits, mmsi_seq_4);
45 raw message_13::get_data() const
47 raw bits(SIZE_BITS_MIN);
48 bits.set(type(), 0, 6);
49 set(bits, repeat_indicator);
50 set(bits, mmsi);
51 set(bits, mmsi_1);
52 set(bits, mmsi_seq_1);
53 if (mmsi_2 != 0) {
54 set(bits, mmsi_2);
55 set(bits, mmsi_seq_2);
57 if (mmsi_3 != 0) {
58 set(bits, mmsi_3);
59 set(bits, mmsi_seq_3);
61 if (mmsi_4 != 0) {
62 set(bits, mmsi_4);
63 set(bits, mmsi_seq_4);
65 return bits;