libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::IPAddressRaw Struct Reference

原始 IPv4 地址 / Raw IPv4 address More...

#include <net.hpp>

Public Member Functions

void ToString (char out[IPADDR_STRLEN]) const
 
bool operator== (const IPAddressRaw &other) const
 
bool operator!= (const IPAddressRaw &other) const
 

Static Public Member Functions

static IPAddressRaw FromString (const char *str)
 

Data Fields

uint8_t bytes [4] {}
 

Detailed Description

原始 IPv4 地址 / Raw IPv4 address

Definition at line 18 of file net.hpp.

Member Function Documentation

◆ FromString()

static IPAddressRaw LibXR::IPAddressRaw::FromString ( const char * str)
inlinestatic

Definition at line 22 of file net.hpp.

23 {
24 IPAddressRaw ip{};
25 std::sscanf(str, "%hhu.%hhu.%hhu.%hhu", &ip.bytes[0], &ip.bytes[1], &ip.bytes[2],
26 &ip.bytes[3]);
27 return ip;
28 }

◆ operator!=()

bool LibXR::IPAddressRaw::operator!= ( const IPAddressRaw & other) const
inline

Definition at line 41 of file net.hpp.

41{ return !(*this == other); }

◆ operator==()

bool LibXR::IPAddressRaw::operator== ( const IPAddressRaw & other) const
inline

Definition at line 36 of file net.hpp.

37 {
38 return Memory::FastCmp(bytes, other.bytes, 4) == 0;
39 }
static int FastCmp(const void *a, const void *b, size_t size)
快速内存比较 / Fast memory comparison

◆ ToString()

void LibXR::IPAddressRaw::ToString ( char out[IPADDR_STRLEN]) const
inline

Definition at line 30 of file net.hpp.

31 {
32 std::snprintf(out, IPADDR_STRLEN, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2],
33 bytes[3]);
34 }

Field Documentation

◆ bytes

uint8_t LibXR::IPAddressRaw::bytes[4] {}

Definition at line 20 of file net.hpp.

20{};

The documentation for this struct was generated from the following file: