NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
mac_address.hpp
浏览该文件的文档.
1#ifndef NEFORCE_NETWORK_UTIL_MAC_ADDRESS_HPP__
2#define NEFORCE_NETWORK_UTIL_MAC_ADDRESS_HPP__
3
11
14NEFORCE_BEGIN_NAMESPACE__
15
20
84class NEFORCE_API mac_address : public istringify<mac_address> {
85public:
86 static constexpr size_t MAC_LEN = 6;
88
89private:
90 bytes_type bytes_{};
91
92public:
98 mac_address() noexcept = default;
99
104 explicit mac_address(const byte_t* bytes) noexcept { copy(bytes, bytes + MAC_LEN, bytes_.begin()); }
105
110 explicit mac_address(const bytes_type& bytes) noexcept :
111 bytes_(bytes) {}
112
123
135 static optional<mac_address> parse(const ip_address& ip, const char* iface = nullptr);
136
141 NEFORCE_NODISCARD string to_string() const;
142
148 bool operator==(const mac_address& other) const noexcept { return bytes_ == other.bytes_; }
149
155 bool operator!=(const mac_address& other) const noexcept { return !(*this == other); }
156
161 NEFORCE_NODISCARD const bytes_type& bytes() const noexcept { return bytes_; }
162};
163 // NetworkUtil
165
166NEFORCE_END_NAMESPACE__
167#endif // NEFORCE_NETWORK_UTIL_MAC_ADDRESS_HPP__
固定大小数组容器
固定大小数组容器
IP地址封装类
array< byte_t, MAC_LEN > bytes_type
MAC地址字节数组类型
mac_address(const bytes_type &bytes) noexcept
从字节数组容器构造
static constexpr size_t MAC_LEN
MAC地址字节长度
static optional< mac_address > parse(string_view str)
从字符串解析MAC地址
bool operator==(const mac_address &other) const noexcept
相等比较运算符
static optional< mac_address > parse(const ip_address &ip, const char *iface=nullptr)
从IP地址获取MAC地址
const bytes_type & bytes() const noexcept
获取MAC地址字节数组
bool operator!=(const mac_address &other) const noexcept
不等比较运算符
mac_address() noexcept=default
默认构造函数
string to_string() const
转换为字符串表示
可选值类
unsigned char byte_t
字节类型,定义为无符号字符
constexpr Iterator2 copy(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__copy_aux(first, last, result)))
复制范围元素
basic_string_view< char > string_view
字符字符串视图
IP地址封装类
可字符串化接口