Hold octets.
More...
#include <bin.h>
|
static std::string | bufToId (const uint8_t *id, size_t length) |
|
static std::string | bufToId (const uint8_t *id, size_t length, const std::string &sep) |
|
static std::string | bufToHex (const uint8_t *bin, size_t length) |
|
Hold octets.
- Note
- functions returning std::string for readable strings
◆ Binary() [1/4]
Binary::Binary |
( |
const Binary & |
rhs | ) |
|
Copy constructor
- Parameters
-
◆ Binary() [2/4]
Binary::Binary |
( |
const void * |
buf, |
|
|
const size_t |
length |
|
) |
| |
Constructor from buffer
- Parameters
-
[in] | buf | pointer to Binary octets |
[in] | length | |
◆ Binary() [3/4]
Binary::Binary |
( |
const size_t |
length, |
|
|
uint8_t |
set = 0 |
|
) |
| |
Constructor buffer with fixed length
- Parameters
-
[in] | length | of buffer |
[in] | set | value to set all octests |
◆ Binary() [4/4]
Binary::Binary |
( |
const std::string & |
string | ) |
|
Constructor from binary based string
- Parameters
-
[in] | string | string with octets content |
◆ append() [1/2]
append octets
- Parameters
-
- Returns
- reference to itself
◆ append() [2/2]
Binary& Binary::append |
( |
const uint8_t |
octet | ) |
|
Append single octet
- Parameters
-
- Returns
- reference to itself
◆ bufToHex()
static std::string Binary::bufToHex |
( |
const uint8_t * |
bin, |
|
|
size_t |
length |
|
) |
| |
|
static |
Convert Binary to hex string
- Parameters
-
[in] | bin | pointer to memory buffer |
[in] | length | of memory buffer |
- Returns
- hex string
◆ bufToId() [1/2]
static std::string Binary::bufToId |
( |
const uint8_t * |
id, |
|
|
size_t |
length |
|
) |
| |
|
static |
Convert Binary ID to string
- Parameters
-
[in] | id | pointer to memory buffer |
[in] | length | of memory buffer |
- Returns
- address
- Note
- Support MAC addresses
◆ bufToId() [2/2]
static std::string Binary::bufToId |
( |
const uint8_t * |
id, |
|
|
size_t |
length, |
|
|
const std::string & |
sep |
|
) |
| |
|
static |
Convert Binary ID to string with a selected seperator
- Parameters
-
[in] | id | pointer to memory buffer |
[in] | length | of memory buffer |
[in] | sep | seperator to use |
- Returns
- address
- Note
- Support MAC addresses
◆ clear()
◆ copy()
void Binary::copy |
( |
uint8_t * |
target | ) |
const |
Copy Binary to target memory block
- Parameters
-
[in,out] | target | memory block |
◆ empty()
bool Binary::empty |
( |
| ) |
const |
|
inline |
Return if Binary is empty
- Returns
- true if empty
◆ eq()
bool Binary::eq |
( |
const Binary & |
rhs | ) |
const |
Compare binaries
- Parameters
-
- Returns
- true if binaries are identical
◆ eui48ToEui64()
bool Binary::eui48ToEui64 |
( |
| ) |
|
Convert ID from EUI48 to EUI64 using 0xfffe padding
- Returns
- true if ID is EUI64 after conversion
◆ fromBase64()
bool Binary::fromBase64 |
( |
const std::string & |
bin64, |
|
|
bool |
pad = false |
|
) |
| |
Convert from Base64 string
- Parameters
-
[in] | bin64 | Base64 string |
[in] | pad | is mandatory |
- Returns
- true if conversion pass
- Note
- support RFC 4648, with or without padding. Both standard and "URL and filename safe". And IMAP mailbox names from RFC 3501 The function probe the characters for value 62, 63 to match to one of the standards.
◆ fromHex()
bool Binary::fromHex |
( |
const std::string & |
hex | ) |
|
Convert Hex to Binary with optional separators
- Parameters
-
- Returns
- true if hex is proper
◆ fromId()
bool Binary::fromId |
( |
const std::string & |
string | ) |
|
Convert ID address string to Binary
- Parameters
-
- Returns
- true if valid ID address
- Note
- Support MAC addresses
◆ fromIp() [1/2]
bool Binary::fromIp |
( |
const std::string & |
string | ) |
|
Convert IP address string to Binary
- Parameters
-
- Returns
- true if valid IP address version 4 or 6
- Note
- this function will toss old value
◆ fromIp() [2/2]
bool Binary::fromIp |
( |
const std::string & |
string, |
|
|
int |
domain |
|
) |
| |
Convert IP address string to Binary
- Parameters
-
[in] | string | address |
[in] | domain | of IP to use |
- Returns
- true if valid IP address version 4 or 6
- Note
- this function will toss old value
◆ fromMac()
bool Binary::fromMac |
( |
const std::string & |
string | ) |
|
|
inline |
Convert MAC address string to Binary
- Parameters
-
- Returns
- true if MAC address
◆ get()
const uint8_t* Binary::get |
( |
| ) |
const |
|
inline |
Get pointer to Binary
- Returns
- pointer to octets
◆ getBin()
const uint8_t Binary::getBin |
( |
const size_t |
position | ) |
const |
Get octet in position
- Parameters
-
- Returns
- octet value or zero if out of range
◆ getBinString()
std::string Binary::getBinString |
( |
| ) |
const |
|
inline |
Get binary content in a string
- Returns
- string with binary content
- Note
- for scripts, to use unpacking assignment and split octets into array or list
◆ isMacLen()
bool Binary::isMacLen |
( |
| ) |
const |
|
inline |
Check if ID length is a valid MAC address
- Returns
- true if ID length is valid MAC length
◆ length()
size_t Binary::length |
( |
| ) |
const |
|
inline |
◆ less()
bool Binary::less |
( |
const Binary & |
rhs | ) |
const |
Compare binaries
- Parameters
-
- Returns
- true if binary is smaller
◆ operator+=() [1/2]
append octets using operator +=
- Parameters
-
- Returns
- reference to itself
- Note
- script can use the append() function.
◆ operator+=() [2/2]
Binary& Binary::operator+= |
( |
const uint8_t |
octet | ) |
|
|
inline |
Append single octet using operator +=
- Parameters
-
- Returns
- reference to itself
- Note
- script can use the append() function.
◆ operator<()
bool Binary::operator< |
( |
const Binary & |
rhs | ) |
const |
|
inline |
Compare binaries
- Parameters
-
- Returns
- true if binary is smaller
◆ operator=()
Copy value from another object
- Parameters
-
- Returns
- reference to itself
◆ operator==()
bool Binary::operator== |
( |
const Binary & |
rhs | ) |
const |
|
inline |
Compare binaries
- Parameters
-
- Returns
- true if binaries are identical
◆ operator[]()
uint8_t& Binary::operator[] |
( |
const size_t |
position | ) |
|
Get octet in position Caller can change value using
- Parameters
-
- Returns
- octet value or zero if out of range
◆ resize()
Binary& Binary::resize |
( |
const size_t |
length | ) |
|
◆ setBin() [1/4]
Set new value from binary based string
- Parameters
-
- Returns
- reference to itself
- Note
- for scripts, to use packing assignment and create a string from array or list of octets
◆ setBin() [2/4]
Binary& Binary::setBin |
( |
const size_t |
position, |
|
|
const uint8_t |
value |
|
) |
| |
Set value in position
- Parameters
-
[in] | position | in Binary octets |
[in] | value | to set in positions |
- Returns
- reference to itself
- Note
- resize the Binary as needed
◆ setBin() [3/4]
Binary& Binary::setBin |
( |
const std::string & |
string | ) |
|
Set new value from binary based string
- Parameters
-
[in] | string | string with octets content |
- Returns
- reference to itself
- Note
- for scripts, to use packing assignment and create a string from array or list of octets
◆ setBin() [4/4]
Binary& Binary::setBin |
( |
const void * |
buf, |
|
|
const size_t |
length |
|
) |
| |
Set new value
- Parameters
-
[in] | buf | pointer to Binary octets |
[in] | length | |
- Returns
- reference to itself
◆ size()
size_t Binary::size |
( |
| ) |
const |
|
inline |
◆ toBase64()
std::string Binary::toBase64 |
( |
bool |
pad = true , |
|
|
char |
v62 = '+' , |
|
|
char |
v63 = '/' |
|
) |
| |
Convert to Base64 string
- Parameters
-
[in] | pad | with or without |
[in] | v62 | character to use for value 62 |
[in] | v63 | character to use for value 63 |
- Returns
- base64 string
- Note
- default values for 62 and 63 follow the standard from RFC 4648.
- Attention
- The function do not verify proper characters for values 62, 63. The caller should use proper characters.
◆ toHex()
std::string Binary::toHex |
( |
| ) |
const |
|
inline |
Convert Binary to hex string
- Returns
- hex string
◆ toId()
std::string Binary::toId |
( |
const std::string & |
sep = ":" | ) |
const |
|
inline |
Convert ID address to string
- Parameters
-
- Returns
- address
- Note
- Support MAC addresses
◆ toIp()
std::string Binary::toIp |
( |
| ) |
const |
Convert IP address to string
- Returns
- Ip address
- Note
- Support both IP version 4 and 6
-
the user should use with Binary IP address the class does not verify
The documentation for this class was generated from the following file: