BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
MACAddress.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 namespace BeeeOn {
7 
8 class MACAddress {
9 public:
10  MACAddress(const unsigned char bytes[6]);
11  MACAddress(const std::vector<unsigned char> &bytes);
12 
13  MACAddress(const uint64_t numMac);
14 
15  MACAddress();
16 
17  uint64_t toNumber() const;
18 
19  std::string toString() const;
20 
21  std::string toString(const char separator) const;
22 
23  std::vector<unsigned char> bytes() const
24  {
25  return m_bytes;
26  }
27 
31  void into(unsigned char bytes[6]) const;
32 
33  operator uint64_t() const
34  {
35  return toNumber();
36  }
37 
38  bool operator ==(const MACAddress &mac) const
39  {
40  return (mac.bytes() == m_bytes);
41  }
42 
43  bool operator !=(const MACAddress &mac) const
44  {
45  return (mac.bytes() != m_bytes);
46  }
47 
48  bool operator <(const MACAddress &mac) const
49  {
50  return (toNumber() < mac.toNumber());
51  }
52 
53  bool operator >(const MACAddress &mac) const
54  {
55  return (toNumber() > mac.toNumber());
56  }
57 
58  static MACAddress parse(const std::string &str, const char separator = ':');
59 
60  static const MACAddress ZERO;
61 
62 private:
63  std::vector<unsigned char> m_bytes;
64 };
65 
66 }
Definition: MACAddress.h:8
void into(unsigned char bytes[6]) const
Definition: MACAddress.cpp:57