nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
zda.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5namespace nmealib {
6namespace nmea0183 {
7
15public:
22 explicit NotZDAException(const std::string& context, const std::string& details = "") :
23 NmeaException(context, "The sentence is not a ZDA sentence", details) {}
24};
25
36class ZDA : public Message0183 {
37public:
49 ZDA(std::string talkerId,
50 double utcTime,
51 unsigned int day,
52 unsigned int month,
53 unsigned int year,
54 int localZoneHours,
55 int localZoneMinutes
56 );
57
58 ZDA(const ZDA&) = default;
59 ZDA& operator=(const ZDA&) = default;
60 ZDA(ZDA&&) noexcept = default;
61 ZDA& operator=(ZDA&&) noexcept = default;
62
63 ~ZDA() override = default;
64
70 std::unique_ptr<nmealib::Message> clone() const override;
71
73 double getUtcTime() const noexcept;
75 unsigned int getDay() const noexcept;
77 unsigned int getMonth() const noexcept;
79 unsigned int getYear() const noexcept;
81 int getLocalZoneHours() const noexcept;
83 int getLocalZoneMinutes() const noexcept;
84
91 std::string getStringContent(bool verbose) const noexcept override;
92
101 bool operator==(const ZDA& other) const noexcept;
102
103private:
104 double utcTime_{};
105 unsigned int day_{};
106 unsigned int month_{};
107 unsigned int year_{};
108 int localZoneHours_{};
109 int localZoneMinutes_{};
110
111 ZDA() = delete;
112
113 ZDA(Message0183 baseMessage,
114 double utcTime,
115 unsigned int day,
116 unsigned int month,
117 unsigned int year,
118 int localZoneHours,
119 int localZoneMinutes
120 ) noexcept;
121
122 static std::unique_ptr<ZDA> create(std::unique_ptr<Message0183> baseMessage);
123 static std::string composeRaw(const std::string& talkerId,
124 double utcTime,
125 unsigned int day,
126 unsigned int month,
127 unsigned int year,
128 int localZoneHours,
129 int localZoneMinutes);
130
131 friend class Nmea0183Factory;
132 friend class MessageRegistry;
133};
134
135} // namespace nmea0183
136} // namespace nmealib
Defines a base class for NMEA messages, encapsulating common properties and behaviors.
Definition message.h:14
Base exception class for all NMEA library errors.
Represents an NMEA 0183 sentence.
Definition nmea0183.h:98
Registry for message type creators.
Factory for creating typed NMEA 0183 message objects from raw sentence strings.
Exception thrown when a sentence is not a valid ZDA sentence.
Definition zda.h:14
NotZDAException(const std::string &context, const std::string &details="")
Construct a NotZDAException with context and optional details.
Definition zda.h:22
Represents a parsed NMEA 0183 ZDA (Time and Date) sentence.
Definition zda.h:36
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this ZDA message.
Definition zda.cpp:101
unsigned int getYear() const noexcept
Get four-digit year.
Definition zda.cpp:159
ZDA(const ZDA &)=default
int getLocalZoneMinutes() const noexcept
Get local zone offset minutes.
Definition zda.cpp:167
ZDA(ZDA &&) noexcept=default
double getUtcTime() const noexcept
Get UTC time in hhmmss.ss numeric form.
Definition zda.cpp:147
ZDA(std::string talkerId, double utcTime, unsigned int day, unsigned int month, unsigned int year, int localZoneHours, int localZoneMinutes)
Construct a ZDA message from individual field values.
Definition zda.cpp:80
int getLocalZoneHours() const noexcept
Get local zone offset hours.
Definition zda.cpp:163
ZDA & operator=(const ZDA &)=default
unsigned int getMonth() const noexcept
Get month number.
Definition zda.cpp:155
unsigned int getDay() const noexcept
Get day of month.
Definition zda.cpp:151
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition zda.cpp:105