seven bits

utility.h File Reference


Detailed Description

This header contains various utility functions inside the bit namespace.

#include <sys/types.h>
#include <stdint.h>
#include <string>

Go to the source code of this file.

Namespaces

namespace  bit

Classes

union  bit::le_single_IEEE754
union  bit::le_double_IEEE754
union  bit::le_quadruple_IEEE754
union  bit::be_single_IEEE754
union  bit::be_double_IEEE754
union  bit::be_quadruple_IEEE754

Defines

#define IEEE754_SINGLE_BIAS   (127)
#define IEEE754_DOUBLE_BIAS   (1023)
#define IEEE754_QUADRUPLE_BIAS   (16383)
#define LOG_2_BASE_10   (0.30102999566398119521)

Functions

uint64_t bit::be_to_host (uint64_t x)
 convert 64 bit value x from big-endian to host byte order
int64_t bit::be_to_host (int64_t x)
 convert 64 bit value x from big-endian to host byte order
uint32_t bit::be_to_host (uint32_t x)
 convert 32 bit value x from big-endian to host byte order
int32_t bit::be_to_host (int32_t x)
 convert 32 bit value x from big-endian to host byte order
uint16_t bit::be_to_host (uint16_t x)
 convert 16 bit value x from big-endian to host byte order
int16_t bit::be_to_host (int16_t x)
 convert 16 bit value x from big-endian to host byte order
uint8_t bit::be_to_host (uint8_t x)
 convert 8 bit value x from big-endian to host byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::be_to_host (int8_t x)
 convert 8 bit value x from big-endian to host byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::host_to_be (uint64_t x)
 convert 64 bit value x from host to big-endian byte order
int64_t bit::host_to_be (int64_t x)
 convert 64 bit value x from host to big-endian byte order
uint32_t bit::host_to_be (uint32_t x)
 convert 32 bit value x from host to big-endian byte order
int32_t bit::host_to_be (int32_t x)
 convert 32 bit value x from host to big-endian byte order
uint16_t bit::host_to_be (uint16_t x)
 convert 16 bit value x from host to big-endian byte order
int16_t bit::host_to_be (int16_t x)
 convert 16 bit value x from host to big-endian byte order
uint8_t bit::host_to_be (uint8_t x)
 convert 8 bit value x from host to big-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::host_to_be (int8_t x)
 convert 8 bit value x from host to big-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::le_to_host (uint64_t x)
 convert 64 bit value x from little-endian to host byte order
int64_t bit::le_to_host (int64_t x)
 convert 64 bit value x from little-endian to host byte order
uint32_t bit::le_to_host (uint32_t x)
 convert 32 bit value x from little-endian to host byte order
int32_t bit::le_to_host (int32_t x)
 convert 32 bit value x from little-endian to host byte order
uint16_t bit::le_to_host (uint16_t x)
 convert 16 bit value x from little-endian to host byte order
int16_t bit::le_to_host (int16_t x)
 convert 16 bit value x from little-endian to host byte order
uint8_t bit::le_to_host (uint8_t x)
 convert 8 bit value x from little-endian to host byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::le_to_host (int8_t x)
 convert 8 bit value x from little-endian to host byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::host_to_le (uint64_t x)
 convert 64 bit value x from host to little-endian byte order
int64_t bit::host_to_le (int64_t x)
 convert 64 bit value x from host to little-endian byte order
uint32_t bit::host_to_le (uint32_t x)
 convert 32 bit value x from host to little-endian byte order
int32_t bit::host_to_le (int32_t x)
 convert 32 bit value x from host to little-endian byte order
uint16_t bit::host_to_le (uint16_t x)
 convert 16 bit value x from host to little-endian byte order
int16_t bit::host_to_le (int16_t x)
 convert 16 bit value x from host to little-endian byte order
uint8_t bit::host_to_le (uint8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::host_to_le (int8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::net_to_host (uint64_t x)
 convert 64 bit value x from network to host byte order
int64_t bit::net_to_host (int64_t x)
 convert 64 bit value x from network to host byte order
uint32_t bit::net_to_host (uint32_t x)
 convert 32 bit value x from network to host byte order
int32_t bit::net_to_host (int32_t x)
 convert 32 bit value x from network to host byte order
uint16_t bit::net_to_host (uint16_t x)
 convert 16 bit value x from network to host byte order
int16_t bit::net_to_host (int16_t x)
 convert 16 bit value x from network to host byte order
uint8_t bit::net_to_host (uint8_t x)
 convert 8 bit value x from network to host byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::net_to_host (int8_t x)
 convert 8 bit value x from network to host byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::host_to_net (uint64_t x)
 convert 64 bit value x from host to network byte order
int64_t bit::host_to_net (int64_t x)
 convert 64 bit value x from host to network byte order
uint32_t bit::host_to_net (uint32_t x)
 convert 32 bit value x from host to network byte order
int32_t bit::host_to_net (int32_t x)
 convert 32 bit value x from host to network byte order
uint16_t bit::host_to_net (uint16_t x)
 convert 16 bit value x from host to network byte order
int16_t bit::host_to_net (int16_t x)
 convert 16 bit value x from host to network byte order
uint8_t bit::host_to_net (uint8_t x)
 convert 8 bit value x from host to network byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::host_to_net (int8_t x)
 convert 8 bit value x from host to network byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::le_to_be (uint64_t x)
 convert 64 bit value x from host to little-endian byte order
int64_t bit::le_to_be (int64_t x)
 convert 64 bit value x from host to little-endian byte order
uint32_t bit::le_to_be (uint32_t x)
 convert 32 bit value x from host to little-endian byte order
int32_t bit::le_to_be (int32_t x)
 convert 32 bit value x from host to little-endian byte order
uint16_t bit::le_to_be (uint16_t x)
 convert 16 bit value x from host to little-endian byte order
int16_t bit::le_to_be (int16_t x)
 convert 16 bit value x from host to little-endian byte order
uint8_t bit::le_to_be (uint8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::le_to_be (int8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::le_to_net (uint64_t x)
 convert 64 bit value x from host to little-endian byte order
int64_t bit::le_to_net (int64_t x)
 convert 64 bit value x from host to little-endian byte order
uint32_t bit::le_to_net (uint32_t x)
 convert 32 bit value x from host to little-endian byte order
int32_t bit::le_to_net (int32_t x)
 convert 32 bit value x from host to little-endian byte order
uint16_t bit::le_to_net (uint16_t x)
 convert 16 bit value x from host to little-endian byte order
int16_t bit::le_to_net (int16_t x)
 convert 16 bit value x from host to little-endian byte order
uint8_t bit::le_to_net (uint8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::le_to_net (int8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::be_to_le (uint64_t x)
 convert 64 bit value x from host to little-endian byte order
int64_t bit::be_to_le (int64_t x)
 convert 64 bit value x from host to little-endian byte order
uint32_t bit::be_to_le (uint32_t x)
 convert 32 bit value x from host to little-endian byte order
int32_t bit::be_to_le (int32_t x)
 convert 32 bit value x from host to little-endian byte order
uint16_t bit::be_to_le (uint16_t x)
 convert 16 bit value x from host to little-endian byte order
int16_t bit::be_to_le (int16_t x)
 convert 16 bit value x from host to little-endian byte order
uint8_t bit::be_to_le (uint8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::be_to_le (int8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
uint64_t bit::net_to_le (uint64_t x)
 convert 64 bit value x from host to little-endian byte order
int64_t bit::net_to_le (int64_t x)
 convert 64 bit value x from host to little-endian byte order
uint32_t bit::net_to_le (uint32_t x)
 convert 32 bit value x from host to little-endian byte order
int32_t bit::net_to_le (int32_t x)
 convert 32 bit value x from host to little-endian byte order
uint16_t bit::net_to_le (uint16_t x)
 convert 16 bit value x from host to little-endian byte order
int16_t bit::net_to_le (int16_t x)
 convert 16 bit value x from host to little-endian byte order
uint8_t bit::net_to_le (uint8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
int8_t bit::net_to_le (int8_t x)
 convert 8 bit value x from host to little-endian byte order There aren't any endian changes for 8-bit values, but, this method is included to allow overloading to occur properly for all integer values.
double bit::be_to_host (double x)
 convert double value x from network to host byte order
double bit::le_to_host (double x)
 convert double value x from network to host byte order
double bit::net_to_host (double x)
 convert double value x from network to host byte order
float bit::be_to_host (float x)
 convert float value x from network to host byte order
float bit::le_to_host (float x)
 convert float value x from network to host byte order
float bit::net_to_host (float x)
 convert float value x from network to host byte order
long double bit::be_to_host (long double x)
 convert long double value x from network to host byte order
long double bit::le_to_host (long double x)
 convert long double value x from network to host byte order
long double bit::net_to_host (long double x)
 convert long double value x from network to host byte order
double bit::host_to_be (double x)
 convert double value x from host to network byte order
double bit::host_to_le (double x)
 convert double value x from host to network byte order
double bit::host_to_net (double x)
 convert double value x from host to network byte order
float bit::host_to_be (float x)
 convert float value x from host to network byte order
float bit::host_to_le (float x)
 convert float value x from host to network byte order
float bit::host_to_net (float x)
 convert float value x from host to network byte order
long double bit::host_to_be (long double x)
 convert long double value x from host to network byte order
long double bit::host_to_le (long double x)
 convert long double value x from host to network byte order
long double bit::host_to_net (long double x)
 convert long double value x from host to network byte order
double bit::le_to_be (double x)
 convert double value x from host to network byte order
float bit::le_to_be (float x)
 convert float value x from host to network byte order
long double bit::le_to_be (long double x)
 convert long double value x from host to network byte order
double bit::le_to_net (double x)
 convert double value x from host to network byte order
float bit::le_to_net (float x)
 convert float value x from host to network byte order
long double bit::le_to_net (long double x)
 convert long double value x from host to network byte order
double bit::be_to_le (double x)
 convert double value x from host to network byte order
float bit::be_to_le (float x)
 convert float value x from host to network byte order
long double bit::be_to_le (long double x)
 convert long double value x from host to network byte order
double bit::net_to_le (double x)
 convert double value x from host to network byte order
float bit::net_to_le (float x)
 convert float value x from host to network byte order
long double bit::net_to_le (long double x)
 convert long double value x from host to network byte order
size_t bit::octet_ceiling (size_t bits)
 Calculate the number of octets required to completely hold n bits.
size_t bit::octet_floor (size_t bits)
 Calculate the number of whole octets required to hold n bits.
void * bit::starting_octet (void *p, size_t bits)
 Given a pointer p to a memory segment and a bit offset, return a pointer to the octet that contains the start of the sequence.
void * bit::ending_octet (void *p, size_t bits)
 Given a pointer p to a memory segment and a bit offset, return a pointer to the octet that contains the end of the sequence.
size_t bit::last_octet_upper_bits (size_t bits)
 Given a bit sequence starting at zero, calculate the number of of upper (used) bits in the last octet.
size_t bit::last_octet_lower_bits (size_t bits)
 Given a bit sequence starting at zero, calculate the number of lower (unused) bits in the last octet.
void * bit::left_shift (void *buffer, size_t buffer_size, size_t lshift_bits)
 Left shift an entire memory segment by a given number of bits.
void * bit::right_shift (void *buffer, size_t buffer_size, size_t rshift_bits)
 Right shift an enitre memory segment by a given number of bits.
std::string bit::hex_string (void *buffer, size_t buffer_size, bool uppercase, std::string separator, std::string prefix, std::string postfix)
std::string bit::binary_string (void *buffer, size_t buffer_size, std::string separator, size_t separator_digits, std::string prefix, std::string postfix)


Define Documentation

#define IEEE754_DOUBLE_BIAS   (1023)

#define IEEE754_QUADRUPLE_BIAS   (16383)

#define IEEE754_SINGLE_BIAS   (127)

#define LOG_2_BASE_10   (0.30102999566398119521)


Generated on Mon Nov 3 10:50:01 2008 for bit by doxygen 1.5.6