pre::bytes Namespace Reference

Functions

std::string to_hexstring (const boost::uint8_t *bytes, const size_t length)
 Convers the given byte array of the given length to a corresponding hexadecimal number in a string. More...
 
std::string to_hexstring (const std::string &bytes)
 Convers the given byte array of the given length to a corresponding hexadecimal number in a human readable string. More...
 
std::string to_binstring (const boost::container::vector< boost::uint8_t > &byteArray)
 Convers the given byte array of the given length to a corresponding binary number in a string. More...
 
boost::uint8_t from_hexchar (char highNibbleChar, char lowNibbleChar)
 Converts the given hexChars to the byte corresponding. More...
 
boost::container::vector< boost::uint8_t > from_hexstring (const std::string &hexString)
 This function can be used to parse a string of hexadecimal number back into bits representation. Note that it runs from left to right, putting eventually the last nibble empty if the size of the input string isn't a multiple of 2. More...
 
std::string buffer_from_hexstring (const std::string &hex)
 Converts a string of hexadecimal number into a binary buffer of this valeu. More...
 
template<typename intX_t >
intX_t from_byteArray (const boost::container::vector< boost::uint8_t > &byteArray)
 This function transforms any byteArray in the chosen (u)int*_t type. More...
 
boost::shared_ptr< boost::container::vector< boost::uint8_t > > load_bytearray (const std::string binaryFilePath)
 This methods opens up a file and parses it's bytes into a bytearray. More...
 

Variables

const size_t NIBBLE_BITS = 4
 Constant telling how much bits there is in a nibble.
 
const size_t BYTE_NIBBLES = 2
 Constant telling how much Nibbles are in a byte.
 

Detailed Description

Utilities to print bytes, transform them to string, reading them from files...

Function Documentation

std::string pre::bytes::buffer_from_hexstring ( const std::string &  hex)
inline

Converts a string of hexadecimal number into a binary buffer of this valeu.

Parameters
hexbyte string
template<typename intX_t >
intX_t pre::bytes::from_byteArray ( const boost::container::vector< boost::uint8_t > &  byteArray)
inline

This function transforms any byteArray in the chosen (u)int*_t type.

Parameters
byteArrayTo transform into native uint
Returns
The int requested with the value of the byteArray.
boost::uint8_t pre::bytes::from_hexchar ( char  highNibbleChar,
char  lowNibbleChar 
)
inline

Converts the given hexChars to the byte corresponding.

Parameters
highNibbleChar
lowNibbleChar
boost::container::vector<boost::uint8_t> pre::bytes::from_hexstring ( const std::string &  hexString)
inline

This function can be used to parse a string of hexadecimal number back into bits representation. Note that it runs from left to right, putting eventually the last nibble empty if the size of the input string isn't a multiple of 2.

Parameters
hexStringto convert
boost::shared_ptr<boost::container::vector<boost::uint8_t> > pre::bytes::load_bytearray ( const std::string  binaryFilePath)
inline

This methods opens up a file and parses it's bytes into a bytearray.

Parameters
binaryFilePathWhere to find the file to load
Returns
The bytearray corresponding to the file content
Exceptions
std::runtime_errorIn case the file isn't found.
std::string pre::bytes::to_binstring ( const boost::container::vector< boost::uint8_t > &  byteArray)
inline

Convers the given byte array of the given length to a corresponding binary number in a string.

Parameters
byteArrayArray of bytes
std::string pre::bytes::to_hexstring ( const boost::uint8_t *  bytes,
const size_t  length 
)
inline

Convers the given byte array of the given length to a corresponding hexadecimal number in a string.

Parameters
bytesArray of bytes
lengthLength of the byte array

Constant array which can be used to convert hex strings to real nibbles.

std::string pre::bytes::to_hexstring ( const std::string &  bytes)
inline

Convers the given byte array of the given length to a corresponding hexadecimal number in a human readable string.

Parameters
bytesbuffer of bytes

Constant array which can be used to convert hex strings to real nibbles.