12 #ifndef __PTPMGMT_BIN_H
13 #define __PTPMGMT_BIN_H
18 __PTPMGMT_NAMESPACE_BEGIN
30 uint8_t *m_buf =
nullptr;
33 bool iResize(
size_t newAllocSize);
69 size_t length()
const {
return m_size; }
74 size_t size()
const {
return m_size; }
79 bool empty()
const {
return m_size == 0; }
84 const uint8_t *
get()
const {
return m_buf; }
91 std::string
getBinString()
const {
return std::string((
char *)m_buf, m_size); }
128 const uint8_t
getBin(
const size_t position)
const;
149 void copy(uint8_t *target)
const;
198 bool fromIp(
const std::string &
string,
int domain);
205 std::string
toId(
const std::string &sep =
":")
const {
206 return bufToId(m_buf, m_size, sep);
226 const std::string &sep);
290 std::string
toBase64(
bool pad =
true,
char v62 =
'+',
char v63 =
'/');
317 __PTPMGMT_NAMESPACE_END
319 #error "this header is for C++ and scripts use only, NOT for C"
__PTPMGMT_NAMESPACE_BEGIN const size_t EUI48
Definition: bin.h:20
const size_t EUI64
Definition: bin.h:21
Hold octets.
Definition: bin.h:28
Binary & setBin(const size_t position, const uint8_t value)
std::string toHex() const
Definition: bin.h:260
Binary & operator+=(const uint8_t octet)
Definition: bin.h:156
Binary & operator=(const Binary &rhs)
std::string getBinString() const
Definition: bin.h:91
std::string toId(const std::string &sep=":") const
Definition: bin.h:205
Binary & resize(const size_t length)
Binary & append(const uint8_t octet)
Binary & setBin(const void *buf, const size_t length)
static std::string bufToHex(const uint8_t *bin, size_t length)
Binary & append(const Binary &rhs)
bool fromMac(const std::string &string)
Definition: bin.h:239
bool fromBase64(const std::string &bin64, bool pad=false)
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)
Binary(const std::string &string)
bool fromIp(const std::string &string, int domain)
size_t size() const
Definition: bin.h:74
Binary(const size_t length, uint8_t set=0)
bool isMacLen() const
Definition: bin.h:244
std::string toBase64(bool pad=true, char v62='+', char v63='/')
Binary & setBin(const std::string &string)
bool fromHex(const std::string &hex)
bool eq(const Binary &rhs) const
bool fromIp(const std::string &string)
uint8_t & operator[](const size_t position)
Binary & setBin(const Binary &rhs)
Binary(const void *buf, const size_t length)
size_t length() const
Definition: bin.h:69
const uint8_t getBin(const size_t position) const
bool fromId(const std::string &string)
Binary(const Binary &rhs)
void copy(uint8_t *target) const
bool empty() const
Definition: bin.h:79
bool operator<(const Binary &rhs) const
Definition: bin.h:308
bool operator==(const Binary &rhs) const
Definition: bin.h:296
bool less(const Binary &rhs) const
const uint8_t * get() const
Definition: bin.h:84