|
Time Shield Library
C++ library for working with time
|
Classes | |
| struct | DueTimer |
| Helper structure that represents a timer ready to run. More... | |
| class | FakeNtpRunner |
| Fake runner for tests without network access. More... | |
| class | IUdpTransport |
| Abstract UDP transport interface for NTP queries. More... | |
| class | NtpClientCore |
| Core NTP query logic that parses packets and computes offsets. More... | |
| struct | NtpPacket |
| NTP packet layout (48 bytes). More... | |
| struct | RunningTimerScope |
| struct | ScheduledComparator |
| Comparator that orders timers by earliest fire time. More... | |
| struct | ScheduledTimer |
| Data stored in the priority queue of scheduled timers. More... | |
| struct | TimerState |
| Internal state shared between Timer and TimerScheduler. More... | |
| struct | UdpRequest |
| UDP request parameters for NTP transactions. More... | |
| class | UdpTransportPosix |
| POSIX UDP transport for NTP queries. More... | |
| class | UdpTransportWin |
| Windows UDP transport for NTP queries. More... | |
Typedefs | |
| using | PlatformUdpTransport = UdpTransportWin |
| using | RunnerAlias = detail::FakeNtpRunner |
| using | TimerClock = std::chrono::steady_clock |
| using | TimerCallback = std::function<void()> |
Enumerations | |
| enum | NtpProtoError { NTP_EPROTO_BASE = -10000 , NTP_E_BAD_MODE = NTP_EPROTO_BASE - 1 , NTP_E_BAD_VERSION = NTP_EPROTO_BASE - 2 , NTP_E_BAD_LI = NTP_EPROTO_BASE - 3 , NTP_E_BAD_STRATUM = NTP_EPROTO_BASE - 4 , NTP_E_KOD = NTP_EPROTO_BASE - 5 , NTP_E_BAD_TS = NTP_EPROTO_BASE - 6 } |
| Protocol-level error codes for NTP parsing. More... | |
Functions | |
| static uint8_t | ntp_li (uint8_t li_vn_mode) noexcept |
| Extract leap indicator from LI/VN/Mode field. | |
| static uint8_t | ntp_vn (uint8_t li_vn_mode) noexcept |
| Extract version number from LI/VN/Mode field. | |
| static uint8_t | ntp_mode (uint8_t li_vn_mode) noexcept |
| Extract mode from LI/VN/Mode field. | |
| static uint64_t | ntp_frac_to_us (uint32_t frac_net) noexcept |
| Convert NTP fractional seconds to microseconds. | |
| static bool | ntp_ts_to_unix_us (uint32_t sec_net, uint32_t frac_net, uint64_t &out_us) noexcept |
| Convert NTP timestamp parts to Unix microseconds. | |
| static void | fill_client_packet (NtpPacket &pkt, uint64_t now_us) |
| Fill an NTP client request packet using local time. | |
| static bool | parse_server_packet (const NtpPacket &pkt, uint64_t arrival_us, int64_t &offset_us, int64_t &delay_us, int &stratum, int &out_error_code) noexcept |
| Parse server response and compute offset and delay. | |
| std::string | trim_copy_ascii (const std::string &s) |
| Trim ASCII whitespace from both ends. | |
| std::string_view | trim_view_ascii (std::string_view v) |
| Trim ASCII whitespace from both ends (string_view). | |
| void | normalise_month_token_lower (const std::string &month, std::string &output) |
| Normalize month token to lower-case ASCII using current locale facet. | |
| void | normalise_month_token_lower (std::string_view month, std::string &output) |
| Normalize month token to lower-case ASCII using current locale facet (string_view). | |
| bool | try_parse_month_index (const std::string &month, int &value) |
| Try parse month name token into month index (1..12). | |
| bool | try_parse_month_index (std::string_view month, int &value) |
| Try parse month name token into month index (1..12), string_view overload. | |
| int | parse_month_index (const std::string &month) |
| Parse month name token into month index (1..12). | |
| int | parse_month_index (std::string_view month) |
| Parse month name token into month index (1..12), string_view overload. | |
| TIME_SHIELD_CONSTEXPR bool | is_ascii_space (char c) noexcept |
| Check whether character is ASCII whitespace. | |
| TIME_SHIELD_CONSTEXPR bool | is_ascii_digit (char c) noexcept |
| Check whether character is ASCII digit. | |
| TIME_SHIELD_CONSTEXPR void | skip_spaces (const char *&p, const char *end) noexcept |
| Skip ASCII whitespace. | |
| TIME_SHIELD_CONSTEXPR bool | parse_2digits (const char *&p, const char *end, int &out) noexcept |
| Parse exactly 2 digits into int. | |
| TIME_SHIELD_CONSTEXPR bool | parse_4digits_year (const char *&p, const char *end, year_t &out) noexcept |
| Parse exactly 4 digits into year_t (via int). | |
| TIME_SHIELD_CONSTEXPR bool | parse_fraction_to_ms (const char *&p, const char *end, int &ms_out) noexcept |
| Parse fractional seconds (1..9 digits) and convert to milliseconds. | |
| TimerState *& | current_timer_state () |
Variables | |
| NtpTimeServiceT< RunnerAlias > | g_ntp_time_service |
Definition at line 34 of file ntp_client.hpp.
Definition at line 184 of file ntp_time_service.hpp.
| using time_shield::detail::TimerCallback = std::function<void()> |
Definition at line 41 of file TimerScheduler.hpp.
| using time_shield::detail::TimerClock = std::chrono::steady_clock |
Definition at line 40 of file TimerScheduler.hpp.
|
inline |
Definition at line 57 of file TimerScheduler.hpp.
|
inlinestatic |
Fill an NTP client request packet using local time.
Definition at line 83 of file ntp_packet.hpp.
|
inlinenoexcept |
Check whether character is ASCII digit.
Definition at line 219 of file time_parser.hpp.
|
inlinenoexcept |
Check whether character is ASCII whitespace.
Definition at line 214 of file time_parser.hpp.
|
inline |
Normalize month token to lower-case ASCII using current locale facet.
| month | Input token. |
| output | Output lower-case token (overwritten). |
Definition at line 97 of file time_parser.hpp.
|
inline |
Normalize month token to lower-case ASCII using current locale facet (string_view).
| month | Input token view. |
| output | Output lower-case token (overwritten). |
Definition at line 110 of file time_parser.hpp.
|
inlinestaticnoexcept |
Convert NTP fractional seconds to microseconds.
Definition at line 68 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Extract leap indicator from LI/VN/Mode field.
Definition at line 53 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Extract mode from LI/VN/Mode field.
Definition at line 63 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Convert NTP timestamp parts to Unix microseconds.
Definition at line 74 of file ntp_packet.hpp.
|
inlinestaticnoexcept |
Extract version number from LI/VN/Mode field.
Definition at line 58 of file ntp_packet.hpp.
|
inlinenoexcept |
Parse exactly 2 digits into int.
Definition at line 232 of file time_parser.hpp.
|
inlinenoexcept |
Parse exactly 4 digits into year_t (via int).
Definition at line 248 of file time_parser.hpp.
|
inlinenoexcept |
Parse fractional seconds (1..9 digits) and convert to milliseconds.
Uses first 3 digits, scales if fewer.
Definition at line 265 of file time_parser.hpp.
|
inline |
Parse month name token into month index (1..12).
| month | Month token. |
| std::invalid_argument | if token is invalid. |
Definition at line 187 of file time_parser.hpp.
|
inline |
Parse month name token into month index (1..12), string_view overload.
| month | Month token view. |
| std::invalid_argument | if token is invalid. |
Definition at line 200 of file time_parser.hpp.
|
inlinestaticnoexcept |
Parse server response and compute offset and delay.
Definition at line 95 of file ntp_packet.hpp.
|
inlinenoexcept |
Skip ASCII whitespace.
Definition at line 224 of file time_parser.hpp.
|
inline |
Trim ASCII whitespace from both ends.
Definition at line 75 of file time_parser.hpp.
|
inline |
Trim ASCII whitespace from both ends (string_view).
Definition at line 85 of file time_parser.hpp.
|
inline |
Try parse month name token into month index (1..12).
| month | Month token (e.g. "Jan", "January", case-insensitive). |
| value | Output month index in range [1..12]. |
Definition at line 125 of file time_parser.hpp.
|
inline |
Try parse month name token into month index (1..12), string_view overload.
| month | Month token view (e.g. "Jan", "January", case-insensitive). |
| value | Output month index in range [1..12]. |
Definition at line 156 of file time_parser.hpp.
| NtpTimeServiceT< RunnerAlias > time_shield::detail::g_ntp_time_service |
Definition at line 540 of file ntp_time_service.hpp.