pre::bits Namespace Reference

Functions

std::string to_string (const boost::dynamic_bitset< boost::uint8_t > &bitset)
 Create string representation of the dynamic bitset given. More...
 
template<typename uintX_t >
std::string to_binstring (uintX_t value)
 Returns a string representation in bits of the int given. More...
 
template<typename uintX_t , size_t bitsetSize>
uintX_t to_uint (const std::bitset< bitsetSize > value)
 
boost::dynamic_bitset< boost::uint8_t > & shift_in_bitset (boost::dynamic_bitset< boost::uint8_t > &hostBitset, const boost::dynamic_bitset< boost::uint8_t > &clientBitset)
 This function pads the given client bitset in the host by making a copy of clientBitset, resizing the clientBitset or-ing it in the hostBitset and returning the hostBitset. More...
 
boost::container::vector< boost::uint8_t > to_bytearray (const boost::dynamic_bitset< boost::uint8_t > &bitset)
 This converts the given boost::dynamic_bitset to an array of 8-bit wide bytes. More...
 
boost::dynamic_bitset< boost::uint8_t > to_bitset (const boost::container::vector< boost::uint8_t > &byteArray, size_t resultingBitSetSize=0)
 Converts a byte array into a bitset. More...
 

Detailed Description

Utilities to deal with bits : shift them, read them out in a given uint_X_t type and so on.

Function Documentation

boost::dynamic_bitset<boost::uint8_t>& pre::bits::shift_in_bitset ( boost::dynamic_bitset< boost::uint8_t > &  hostBitset,
const boost::dynamic_bitset< boost::uint8_t > &  clientBitset 
)
inline

This function pads the given client bitset in the host by making a copy of clientBitset, resizing the clientBitset or-ing it in the hostBitset and returning the hostBitset.

Parameters
hostBitsetWhich will get the clientBitset or-ed in it (i.e. The hostBitset get shifted to the left of the size of the clientBitset) hostBitset should be bigger than clientBitset
clientBitsetThe bitset which will be integrated in the host bitset
Returns
The hostBitset
template<typename uintX_t >
std::string pre::bits::to_binstring ( uintX_t  value)
inline

Returns a string representation in bits of the int given.

Parameters
value
Returns
The string representing the int given
boost::dynamic_bitset<boost::uint8_t> pre::bits::to_bitset ( const boost::container::vector< boost::uint8_t > &  byteArray,
size_t  resultingBitSetSize = 0 
)
inline

Converts a byte array into a bitset.

Parameters
byteArray
Returns
The bitset corresponding to the given byte array
boost::container::vector<boost::uint8_t> pre::bits::to_bytearray ( const boost::dynamic_bitset< boost::uint8_t > &  bitset)
inline

This converts the given boost::dynamic_bitset to an array of 8-bit wide bytes.

Parameters
bitsetto convert
Returns
The vector of bytes resulting of the conversion in fixed byte width
std::string pre::bits::to_string ( const boost::dynamic_bitset< boost::uint8_t > &  bitset)
inline

Create string representation of the dynamic bitset given.

Parameters
bitset