libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
ipv4address.h
Go to the documentation of this file.
1
22
23#ifndef IPV4ADDRESS_H
24#define IPV4ADDRESS_H
25
26#include <optional>
27#include <string>
28
30{
35 {
36 public:
44 IPv4Address(unsigned char first, unsigned char second, unsigned char third, unsigned char fourth) noexcept;
49 IPv4Address(unsigned long address) noexcept;
55 static std::optional<IPv4Address> parse(const std::string& address) noexcept;
60 unsigned char getFirst() const noexcept;
65 unsigned char getSecond() const noexcept;
70 unsigned char getThird() const noexcept;
75 unsigned char getFourth() const noexcept;
80 unsigned long getNetworkByteOrder() const noexcept;
85 std::string str() const noexcept;
86
87 private:
88 unsigned char m_first;
89 unsigned char m_second;
90 unsigned char m_third;
91 unsigned char m_fourth;
92 };
93}
94
95#endif //IPV4ADDRESS_H
unsigned long getNetworkByteOrder() const noexcept
Gets the address in network byte order.
IPv4Address(unsigned char first, unsigned char second, unsigned char third, unsigned char fourth) noexcept
Constructs an IPv4Address.
unsigned char getThird() const noexcept
Gets the third byte of the address.
static std::optional< IPv4Address > parse(const std::string &address) noexcept
Parses an IPv4Address from a string.
unsigned char getSecond() const noexcept
Gets the second byte of the address.
unsigned char getFirst() const noexcept
Gets the first byte of the address.
std::string str() const noexcept
Gets the string representation of the address.
unsigned char getFourth() const noexcept
Gets the fourth byte of the address.
IPv4Address(unsigned long address) noexcept
Constructs an IPv4Address.
Definition ipv4address.h:30