MAC address.
More...
#include <JMACAddress.hh>
|
static const char * | get_separator () |
| Get list of allowed separators.
|
|
static bool | is_separator (const int c) |
| Check if given character is an allowed separator.
|
|
|
std::istream & | operator>> (std::istream &in, JMACAddress &object) |
| Read MAC address from input stream.
|
|
std::ostream & | operator<< (std::ostream &out, const JMACAddress &object) |
| Write MAC address to output stream.
|
|
MAC address.
Definition at line 30 of file JMACAddress.hh.
◆ anonymous enum
Enumerator |
---|
NUMBER_OF_BYTES | number of bytes
|
Definition at line 34 of file JMACAddress.hh.
34 {
36 };
@ NUMBER_OF_BYTES
number of bytes
◆ JMACAddress()
JDATABASE::JMACAddress::JMACAddress |
( |
| ) |
|
|
inline |
◆ get_separator()
static const char * JDATABASE::JMACAddress::get_separator |
( |
| ) |
|
|
inlinestatic |
Get list of allowed separators.
- Returns
- allowed separators
Definition at line 44 of file JMACAddress.hh.
45 {
46 return ":.-";
47 }
◆ is_separator()
static bool JDATABASE::JMACAddress::is_separator |
( |
const int | c | ) |
|
|
inlinestatic |
Check if given character is an allowed separator.
- Parameters
-
- Returns
- true if separator; else false
Definition at line 56 of file JMACAddress.hh.
57 {
59
60 for (std::string::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
61 if ((int) *i == c) {
62 return true;
63 }
64 }
65
66 return false;
67 }
static const char * get_separator()
Get list of allowed separators.
◆ equal()
bool JDATABASE::JMACAddress::equal |
( |
const JMACAddress & | address | ) |
const |
|
inline |
Equal method.
- Parameters
-
- Returns
- true if this MAC address and given MAC address are equal; else false
Definition at line 84 of file JMACAddress.hh.
85 {
87 if ((*this)[i] != address[i]) {
88 return false;
89 }
90 }
91
92 return true;
93 }
◆ ClassDefNV()
◆ operator>>
std::istream & operator>> |
( |
std::istream & | in, |
|
|
JMACAddress & | object ) |
|
friend |
Read MAC address from input stream.
- Parameters
-
in | input stream |
object | MAC address |
- Returns
- input stream
Definition at line 103 of file JMACAddress.hh.
104 {
106
108
109 int c;
110
111 if (in >> hex >> c) {
112
113 object[0] = (unsigned char) c;
114
117 object[i] = (unsigned char) c;
118 else
119 in.setstate(ios::failbit);
120 }
121 }
122
123 return in >> dec;
124 }
static bool is_separator(const int c)
Check if given character is an allowed separator.
JMACAddress()
Default constructor.
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & | out, |
|
|
const JMACAddress & | object ) |
|
friend |
Write MAC address to output stream.
- Parameters
-
out | output stream |
object | MAC address |
- Returns
- output stream
Definition at line 135 of file JMACAddress.hh.
136 {
138
139 out << setw(2) << setfill('0') << hex << (int) object[0];
140
143 << setw(2) << setfill('0') << hex << (int) object[i];
144 }
145
146 return out << setfill(' ') << dec;
147 }
The documentation for this struct was generated from the following file: