HEBI C++ API  3.9.0
mac_address.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "hebi.h"
4 
5 #include <iostream>
6 
7 namespace hebi {
8 
13 class MacAddress final {
14 public:
15 #ifndef DOXYGEN_OMIT_INTERNAL
16 
21  HebiMacAddress internal_;
22 #endif // DOXYGEN_OMIT_INTERNAL
23 
24 private:
29  static uint8_t hexToInt(char c);
30 
34  static uint8_t byteFromHexPair(char c1, char c2);
35 
36 public:
40  MacAddress();
41 
45  static MacAddress fromBytes(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f);
46 
56  bool setToHexString(std::string mac_str);
57 
58  uint8_t& operator[](std::size_t idx);
59  const uint8_t& operator[](std::size_t idx) const;
60 
61 private:
62  /*
63  * Is 'c' a valid hex digit (0-F, upper or lower case)?
64  *
65  * \returns 'true' if yes, 'false' if no.
66  */
67  static bool isHexDigitValid(char c);
68 
69 public:
76  static bool isHexStringValid(std::string mac_str);
77 };
78 
79 } // namespace hebi
Definition: arm.cpp:8
A simple wrapper class for internal C-API HebiMacAddress objects to allow interfacing with API calls ...
Definition: mac_address.hpp:13
bool setToHexString(std::string mac_str)
Sets the value of the current MacAddress to the value given in 'mac_str'.
Definition: mac_address.cpp:37
static MacAddress fromBytes(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f)
Creates a MacAddress from individual bytes.
Definition: mac_address.cpp:26
static bool isHexStringValid(std::string mac_str)
Is mac_str a valid string of format dd:dd:dd:dd:dd:dd, where 'd' is a hex digit 0-F....
Definition: mac_address.cpp:57
uint8_t & operator[](std::size_t idx)
Definition: mac_address.cpp:49
MacAddress()
Creates MAC address 00:00:00:00:00:00.
Definition: mac_address.cpp:17