nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
message.cpp
Go to the documentation of this file.
1#include "nmealib/message.h"
2
3namespace nmealib {
4
5std::string Message::typeToString(Type t) {
6 switch (t) {
7 case Type::Unknown: return "Unknown";
8 case Type::NMEA0183: return "NMEA0183";
9 case Type::NMEA2000: return "NMEA2000";
10 default: return "InvalidType";
11 }
12}
13
14Message::Message() = default;
15
16Message::Message(std::string raw, Type type, TimePoint ts) noexcept
17 : rawData_(std::move(raw)), type_(type), timestamp_(ts) {}
18
19Message::~Message() = default;
20
22 return type_;
23}
24
25const std::string& Message::getRawData() const noexcept {
26 return rawData_;
27}
28
30 return timestamp_;
31}
32
33bool Message::operator==(const Message& other) const noexcept {
34 return type_ == other.type_ &&
35 rawData_ == other.rawData_;
36}
37
38void Message::setType(Type t) noexcept {
39 type_ = t;
40}
41
42void Message::setRaw(std::string r) noexcept {
43 rawData_ = std::move(r);
44}
45
47 timestamp_ = ts;
48}
49
50} // namespace nmealib
Defines a base class for NMEA messages, encapsulating common properties and behaviors.
Definition message.h:14
void setType(Type t) noexcept
Sets the message type.
Definition message.cpp:38
void setRaw(std::string r) noexcept
Sets the raw data string.
Definition message.cpp:42
std::string rawData_
Definition message.h:97
std::chrono::system_clock::time_point TimePoint
Definition message.h:30
const std::string & getRawData() const noexcept
Returns the raw, unmodified data string as received.
Definition message.cpp:25
virtual ~Message()
Type getType() const noexcept
Returns the message type.
Definition message.cpp:21
Type
Defines the type of NMEA message, allowing for differentiation between various standards.
Definition message.h:20
void setTimestamp(TimePoint ts) noexcept
Sets the message timestamp.
Definition message.cpp:46
TimePoint getTimestamp() const noexcept
Returns the timestamp associated with this message.
Definition message.cpp:29
static std::string typeToString(Type t)
Converts a Message::Type enum value to its string representation.
Definition message.cpp:5
TimePoint timestamp_
Definition message.h:99
bool operator==(const Message &other) const noexcept
Compares two Message objects for equality based on their content.
Definition message.cpp:33