Menu

ByteCount.h File Reference

#include <stdint.h>
#include "boost/mpl/eval_if.hpp"
#include "boost/mpl/int.hpp"
#include "boost/mpl/plus.hpp"

Go to the source code of this file.

Data Structures

struct  BitCount< ValueType, Value >
 Calculates the least number of bits needed to represent the given value of the specified type. More...
struct  BitCount< bool, true >
struct  BitCount< bool, false >
struct  ByteCount< ValueType, Value >
 Calculates the number of whole bytes needed to store the given value of the given type. More...

Defines

#define BitCountSigned(stype)

Functions

 BitCountSigned (int8_t)
 BitCountSigned (int16_t)
 BitCountSigned (int32_t)
 BitCountSigned (int64_t)
const uint16_t getBitCount (uint64_t value)
 Performs the calculation of the bit count for the given 64 bit unsigned value at runtime.
const uint16_t bitCountToByteCount (const uint16_t value)
 Converts the given number of bits to whole bytes needed to store the specified number of bits at runtime.

Define Documentation

#define BitCountSigned ( stype   ) 
Value:
template <stype Value>                                                  \
    struct BitCount<stype, Value> {                                         \
                                                                            \
        typedef stype value_type;                                           \
                                                                            \
        typedef boost::mpl::integral_c_tag tag;                             \
                                                                            \
        typedef BitCount type;                                              \
                                                                            \
        static const uint16_t value = (Value < 0) ?                         \
                                      (sizeof(stype) * 8) :                 \
                                      BitCount<                             \
                                        uint64_t,                           \
                                        static_cast<uint64_t>(Value)        \
                                      >::value;                             \
    }

Macro to create template struct overloads for signed integral types.


Function Documentation

BitCountSigned ( int64_t   ) 
BitCountSigned ( int32_t   ) 
BitCountSigned ( int16_t   ) 
BitCountSigned ( int8_t   ) 
const uint16_t bitCountToByteCount ( const uint16_t  value  )  [inline]

Converts the given number of bits to whole bytes needed to store the specified number of bits at runtime.

Parameters:
value The bit count to convert
Returns:
The number of whole bytes needed

Referenced by famouso::mw::attributes::access::Attribute_RT::setValue().

const uint16_t getBitCount ( uint64_t  value  )  [inline]

Performs the calculation of the bit count for the given 64 bit unsigned value at runtime.

Parameters:
value The value to calculate the bit count for
Returns:
The number of bits needed to represent the given value

Referenced by famouso::mw::attributes::access::Attribute_RT::setValue().