EtcPal  HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
View other versions:
MacAddr Class Reference

Overview

A wrapper for the EtcPal MAC address type.

Provides C++ syntactic sugar for working with MAC addresses.

Public Member Functions

 MacAddr ()=default
 Constructs a null MAC address by default.
 
constexpr MacAddr (const EtcPalMacAddr &c_mac) noexcept
 Construct a MAC address copied from an instance of the C EtcPalMacAddr type.
 
MacAddroperator= (const EtcPalMacAddr &c_mac) noexcept
 Assign an instance of the C EtcPalMacAddr type to an instance of this class.
 
 MacAddr (const uint8_t *mac_data) noexcept
 Construct a MAC address from its raw 6-byte array representation. More...
 
constexpr const EtcPalMacAddrget () const noexcept
 Get a const reference to the underlying C type.
 
ETCPAL_CONSTEXPR_14 EtcPalMacAddrget () noexcept
 Get a mutable reference to the underlying C type.
 
std::string ToString () const
 Convert the MAC address to a string representation. More...
 
constexpr const uint8_t * data () const noexcept
 Get the raw 6-byte array representation of a MAC address. More...
 
std::array< uint8_t, ETCPAL_MAC_BYTESToArray () const noexcept
 Get a 6-byte std::array representation of a MAC address. More...
 
bool IsNull () const noexcept
 Whether this MacAddr represents a null (all 0's) MAC address.
 

Static Public Member Functions

static MacAddr FromString (const char *mac_str) noexcept
 Construct a MacAddr from a string representation. More...
 
static MacAddr FromString (const std::string &mac_str) noexcept
 Construct a MacAddr from a string representation. More...
 

Constructor & Destructor Documentation

◆ MacAddr()

MacAddr ( const uint8_t *  mac_data)
inlineexplicitnoexcept

Construct a MAC address from its raw 6-byte array representation.

Parameters
[in]mac_dataPointer to the MAC data, an array of length ETCPAL_MAC_BYTES.

Member Function Documentation

◆ data()

constexpr const uint8_t * data ( ) const
constexprnoexcept

Get the raw 6-byte array representation of a MAC address.

Returns
Pointer to an array of length ETCPAL_MAC_BYTES containing the address data.

◆ FromString() [1/2]

MacAddr FromString ( const char *  mac_str)
inlinestaticnoexcept

Construct a MacAddr from a string representation.

See etcpal_string_to_mac() for more information.

◆ FromString() [2/2]

MacAddr FromString ( const std::string &  mac_str)
inlinestaticnoexcept

Construct a MacAddr from a string representation.

See etcpal_string_to_mac() for more information.

◆ ToArray()

std::array< uint8_t, ETCPAL_MAC_BYTES > ToArray ( ) const
inlinenoexcept

Get a 6-byte std::array representation of a MAC address.

Copies the data into a new array.

◆ ToString()

std::string ToString ( ) const
inline

Convert the MAC address to a string representation.

See etcpal_mac_to_string() for more information.


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