2 #include <marnav/nmea/split.hpp>
11 /// Performs checks on the specified raw NMEA sentence and extracts
12 /// information for further processing.
14 /// This is separated into this function in order to prevent bloat
15 /// of the template function create_sentence.
17 /// @param[in] s The raw NMEA sentence.
18 /// @param[in] ignore_checksum Option to ignore the checksum.
19 /// @return A tuple containing:
20 /// - The `talker` extracted from the raw NMEA sentence.
21 /// - The `tag` extracted from the raw NMEA sentence.
22 /// - Extracted `fields` from the raw NMEA sentence.
24 std::tuple
<talker
, std::string
, std::vector
<std::string
>> extract_sentence_information(
25 const std::string
& s
, bool ignore_checksum
)
27 detail::check_raw_sentence(s
);
29 // extract all fields, skip start token
30 std::vector
<std::string
> fields
= detail::parse_fields(s
);
31 if (fields
.size() < 2) // at least address and checksum must be present
32 throw std::invalid_argument
{"malformed sentence in nmea/make_sentence"};
35 detail::ensure_checksum(s
, fields
.back());
37 // extract address and posibly talker_id and tag.
38 // check for vendor extension is necessary because the address field of this extensions
39 // to not follow the pattern talker_id/tag
40 talker talk
{talker_id::none
};
42 std::tie(talk
, tag
) = detail::parse_address(fields
.front());
44 return std::make_tuple(talk
, tag
, fields
);