Binary data utilities.
These functions and macros are to be used for manipulating binary data.
Classes | |
class | CRCParam |
Encapsulate parameters for CRC computation. More... | |
Functions | |
void | buhtoid (void *p, double v, unsigned pos=0) |
void | buhtoif (void *p, float v, unsigned pos=0) |
void | buhtoil (void *p, uint32_t v, unsigned pos=0) |
void | buhtoill (void *p, uint64_t v, unsigned pos=0) |
void | buhtois (void *p, uint16_t v, unsigned pos=0) |
void | buhtoisl (void *p, int32_t v, unsigned pos=0) |
void | buhtoisll (void *p, int64_t v, unsigned pos=0) |
void | buhtoiss (void *p, int16_t v, unsigned pos=0) |
void | buhtond (void *p, double v, unsigned pos=0) |
void | buhtonf (void *p, float v, unsigned pos=0) |
void | buhtonl (void *p, uint32_t v, unsigned pos=0) |
void | buhtonll (void *p, uint64_t v, unsigned pos=0) |
void | buhtons (void *p, uint16_t v, unsigned pos=0) |
void | buhtonsl (void *p, int32_t v, unsigned pos=0) |
void | buhtonsll (void *p, int64_t v, unsigned pos=0) |
void | buhtonss (void *p, int16_t v, unsigned pos=0) |
void | buitohd (const void *p, double &v, unsigned pos=0) |
void | buitohf (const void *p, float &v, unsigned pos=0) |
void | buitohl (const void *p, uint32_t &v, unsigned pos=0) |
void | buitohll (const void *p, uint64_t &v, unsigned pos=0) |
void | buitohs (const void *p, uint16_t &v, unsigned pos=0) |
void | buitohsl (const void *p, int32_t &v, unsigned pos=0) |
void | buitohsll (const void *p, int64_t &v, unsigned pos=0) |
void | buitohss (const void *p, int16_t &v, unsigned pos=0) |
void | buntohd (const void *p, double &v, unsigned pos=0) |
void | buntohf (const void *p, float &v, unsigned pos=0) |
void | buntohl (const void *p, uint32_t &v, unsigned pos=0) |
void | buntohll (const void *p, uint64_t &v, unsigned pos=0) |
void | buntohs (const void *p, uint16_t &v, unsigned pos=0) |
void | buntohsl (const void *p, int32_t &v, unsigned pos=0) |
void | buntohsll (const void *p, int64_t &v, unsigned pos=0) |
void | buntohss (const void *p, int16_t &v, unsigned pos=0) |
uint32_t | computeCRC (const unsigned char *data, unsigned long len, const CRCParam ¶ms) |
unsigned short | countBits (uint32_t v) |
template<class T > | |
T | decodeVar (const std::string &str, std::string::size_type pos) |
template<class T > | |
T | decodeVar (std::string &str) |
template<class T > | |
T | decodeVarLE (const std::string &str, std::string::size_type pos) |
template<class T > | |
T | decodeVarLE (std::string &str) |
template<class T > | |
std::string | encodeVar (const T &v) |
template<class T > | |
void | encodeVar (const T &v, std::string &str, size_t pos=0) |
template<class T > | |
std::string | encodeVarLE (const T &v) |
template<class T > | |
void | encodeVarLE (const T &v, std::string &str, size_t pos=0) |
NEW_EXCEPTION_CLASS (CRCException, Exception) | |
unsigned long | reflect (unsigned long crc, int bitnum) |
Reflects the lower bitnum bits of crc. More... | |
std::string | xorChecksum (const std::string &str, unsigned wordSize) |
Variables | |
const CRCParam | CRC16 (16, 0x8005, 0, 0, true, true, true) |
CRC-16 parameters. More... | |
const CRCParam | CRC24Q (24, 0x823ba9, 0, 0xffffff, true, false, false) |
CRC-24Q parameters. More... | |
const CRCParam | CRC32 (32, 0x4c11db7, 0xffffffff, 0xffffffff, true, true, true) |
CRC-32 parameters. More... | |
const CRCParam | CRCCCITT (16, 0x1021, 0xffff, 0, true, false, false) |
CCITT CRC parameters. More... | |
const CRCParam | CRCGLOL3 (24, 0xc3267d, 0, 0xffffff, true, false, false) |
GLONASS CDMA L3 CRC parameters. More... | |
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 950 of file BinUtils.hpp.
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 935 of file BinUtils.hpp.
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 851 of file BinUtils.hpp.
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 866 of file BinUtils.hpp.
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 838 of file BinUtils.hpp.
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 899 of file BinUtils.hpp.
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 915 of file BinUtils.hpp.
|
inline |
Converts host byte order to Intel little-endian.
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 885 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 1082 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 1067 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 983 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 998 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 970 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 1031 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 1047 of file BinUtils.hpp.
|
inline |
Converts host byte order to Network byte order (big-endian).
[in,out] | p | a pointer to the buffer where the converted value will be stored. |
[in] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to store the encoded value. |
Definition at line 1017 of file BinUtils.hpp.
|
inline |
Converts Intel little-endian to host byte order.
[in] | p | a pointer to the buffer containing the little-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 686 of file BinUtils.hpp.
|
inline |
Converts Intel little-endian to host byte order.
[in] | p | a pointer to the buffer containing the little-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 671 of file BinUtils.hpp.
|
inline |
Converts Intel little-endian to host byte order.
[in] | p | a pointer to the buffer containing the little-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 587 of file BinUtils.hpp.
|
inline |
Converts Intel little-endian to host byte order.
[in] | p | a pointer to the buffer containing the little-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 602 of file BinUtils.hpp.
|
inline |
Converts Intel little-endian to host byte order.
[in] | p | a pointer to the buffer containing the little-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 635 of file BinUtils.hpp.
|
inline |
Converts Intel little-endian to host byte order.
[in] | p | a pointer to the buffer containing the little-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 651 of file BinUtils.hpp.
|
inline |
Converts Intel little-endian to host byte order.
[in] | p | a pointer to the buffer containing the little-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 621 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 818 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 803 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 719 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 734 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 706 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 767 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 783 of file BinUtils.hpp.
|
inline |
Converts Network (big-endian) to host byte order.
[in] | p | a pointer to the buffer containing the big-endian value. |
[out] | v | the value in host byte order. |
[in] | pos | an optional offset (bytes) into p to decode from. |
Definition at line 753 of file BinUtils.hpp.
|
inline |
Compute CRC (suitable for polynomial orders from 1 to 32). Does bit-by-bit computation (brute-force, no look-up tables).
[in] | data | data to process CRC on. |
[in] | len | length of data to process (in bytes). |
[in] | params | see documentation of CRCParam:w |
Definition at line 477 of file BinUtils.hpp.
|
inline |
Count the set bits in an 32-bit unsigned integer. Originated due to need in EngNav::checkParity
Definition at line 342 of file BinUtils.hpp.
|
inline |
Decode the item specified from the string and convert it from network byte order to host byte order.
[in] | str | the string from which to obtain data. |
[in] | pos | offset into the string from which to pull the data. |
Definition at line 366 of file BinUtils.hpp.
|
inline |
Decode and remove the item specified from the head of the string and convert it from network byte order to host byte order.
[in,out] | str | the string from which to obtain data. |
Definition at line 398 of file BinUtils.hpp.
|
inline |
Decode the item specified from the string and convert it from little-endian byte order to host byte order.
[in] | str | the string from which to obtain data. |
[in] | pos | offset into the string from which to pull the data. |
Definition at line 383 of file BinUtils.hpp.
|
inline |
Decode and remove the item specified from the head of the string and convert it from little-endian byte order to host byte order.
[in,out] | str | the string from which to obtain data. |
Definition at line 406 of file BinUtils.hpp.
|
inline |
Add the network ordered binary representation of a var to the the given string.
[in] | v | the object of type T to convert to a string. |
Definition at line 414 of file BinUtils.hpp.
|
inline |
Add the network ordered binary representation of a var to the the given string.
[in] | v | the object of type T to convert to a string. |
[in,out] | str | the string where the encoded data will be stored. |
[in] | pos | the position in str where the encoded variable will be stored. |
Definition at line 425 of file BinUtils.hpp.
|
inline |
Add the little-endian binary representation of a var to the the given string.
[in] | v | the object of type T to convert to a string. |
Definition at line 436 of file BinUtils.hpp.
|
inline |
Add the little-endian binary representation of a var to the the given string.
[in] | v | the object of type T to convert to a string. |
[in,out] | str | the string where the encoded data will be stored. |
[in] | pos | the position in str where the encoded variable will be stored. |
Definition at line 447 of file BinUtils.hpp.
|
inline |
Reflects the lower bitnum bits of crc.
Definition at line 457 of file BinUtils.hpp.
|
inline |
Calculate an Exclusive-OR Checksum on the string str.
[in] | str | The encoded data for which the checksum is to be computed. The size of this string must be evenly divisible by wordSize. |
[in] | wordSize | The size of the checksum in bytes. |
gnsstk::InvalidParameter | if there is a partial word at the end of str. |
Definition at line 551 of file BinUtils.hpp.
CRC-16 parameters.
Definition at line 307 of file BinUtils.hpp.
CRC-24Q parameters.
Definition at line 311 of file BinUtils.hpp.
CRC-32 parameters.
Definition at line 309 of file BinUtils.hpp.
CCITT CRC parameters.
Definition at line 305 of file BinUtils.hpp.
GLONASS CDMA L3 CRC parameters.
Definition at line 313 of file BinUtils.hpp.