NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
mac_address.hpp
浏览该文件的文档.
1#ifndef NEFORCE_NETWORK_MAC_ADDRESS_HPP__
2#define NEFORCE_NETWORK_MAC_ADDRESS_HPP__
3
11
14NEFORCE_BEGIN_NAMESPACE__
15
21
27
41class NEFORCE_API mac_address : public istringify<mac_address> {
42public:
43 static constexpr size_t MAC_LEN = 6;
45
46private:
47 bytes_type bytes_{};
48
49public:
55 mac_address() noexcept = default;
56
61 explicit mac_address(const byte_t* bytes) noexcept { copy(bytes, bytes + MAC_LEN, bytes_.begin()); }
62
67 explicit mac_address(const bytes_type& bytes) noexcept :
68 bytes_(bytes) {}
69
80
92 static optional<mac_address> parse(const ip_address& ip, const char* iface = nullptr);
93
98 string to_string() const;
99
105 bool operator==(const mac_address& other) const noexcept { return bytes_ == other.bytes_; }
106
112 bool operator!=(const mac_address& other) const noexcept { return !(*this == other); }
113
118 const bytes_type& bytes() const noexcept { return bytes_; }
119};
120 // NetworkUtil
122 // Network
124
125NEFORCE_END_NAMESPACE__
126#endif // NEFORCE_NETWORK_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地址封装类
可字符串化接口