The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::utils::BitArray Class Reference

Class for fast bit manipulation. More...

#include <BitArray.hpp>

Public Member Functions

 BitArray (const void *data, size_t data_size, size_t array_size=0)
 
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
 BitArray (const T &value, size_t array_size=sizeof(T))
 
 BitArray (const BitArray &other)
 
BitArrayoperator= (const BitArray &other)=default
 
 BitArray (BitArray &&)=default
 
BitArrayoperator= (BitArray &&)=default
 
const void * getValue () const
 
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
getValue () const
 
size_t getSize () const
 
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
void fill (const T &value)
 
bool operator== (const BitArray &other) const
 
bool operator!= (const BitArray &other) const
 
BitArray operator<< (size_t amount) const
 
BitArrayoperator<<= (size_t amount)
 
BitArray operator>> (size_t amount) const
 
BitArrayoperator>>= (size_t amount)
 
BitArray operator& (const BitArray &other) const
 
BitArrayoperator&= (const BitArray &other)
 
BitArray operator| (const BitArray &other) const
 
BitArrayoperator|= (const BitArray &other)
 
BitArray operator~ () const
 

Detailed Description

Class for fast bit manipulation.

Type to represent a bit array whose size is not known at compile time. If the size is known at compile time use std::bitset.

Definition at line 44 of file BitArray.hpp.

Constructor & Destructor Documentation

◆ BitArray() [1/3]

sparta::utils::BitArray::BitArray ( const void *  data,
size_t  data_size,
size_t  array_size = 0 
)
inline

Construct a BitArray from a data buffer

Parameters
dataPointer to the data buffer
data_sizeSize of the data buffer in bytes
array_sizeThe size of the BitArray in bytes

If the array_size parameter is not specified or zero, the size of the array will be the same as the size of the data buffer.

Definition at line 60 of file BitArray.hpp.

◆ BitArray() [2/3]

template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
sparta::utils::BitArray::BitArray ( const T &  value,
size_t  array_size = sizeof(T) 
)
inlineexplicit

Construct a BitArray from an integer type

Parameters
valueThe integer
array_sizeThe size of the BitArray in bytes

If the array_size parameter is not specified, the size of the array will be the same as the size of the integer type.

Definition at line 81 of file BitArray.hpp.

◆ BitArray() [3/3]

sparta::utils::BitArray::BitArray ( const BitArray other)
inline

Definition at line 86 of file BitArray.hpp.

Member Function Documentation

◆ fill()

template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
void sparta::utils::BitArray::fill ( const T &  value)
inline

Fill the array by repeating value

Definition at line 122 of file BitArray.hpp.

◆ getSize()

size_t sparta::utils::BitArray::getSize ( ) const
inline

Definition at line 112 of file BitArray.hpp.

◆ getValue() [1/2]

const void * sparta::utils::BitArray::getValue ( ) const
inline

Definition at line 98 of file BitArray.hpp.

◆ getValue() [2/2]

template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
T sparta::utils::BitArray::getValue ( ) const
inline

Definition at line 105 of file BitArray.hpp.

◆ operator!=()

bool sparta::utils::BitArray::operator!= ( const BitArray other) const
inline

Definition at line 136 of file BitArray.hpp.

◆ operator&()

BitArray sparta::utils::BitArray::operator& ( const BitArray other) const
inline

The size of the resulting BitArray will equal that of the left hand size array. If the right hand side array is the larger of the two, its upper bits will be truncated and will not be included in the result. If the left hand side is the larger, the result will contain its upper bits unchanged.

Definition at line 174 of file BitArray.hpp.

◆ operator&=()

BitArray & sparta::utils::BitArray::operator&= ( const BitArray other)
inline

Definition at line 181 of file BitArray.hpp.

◆ operator<<()

BitArray sparta::utils::BitArray::operator<< ( size_t  amount) const
inline

Definition at line 141 of file BitArray.hpp.

◆ operator<<=()

BitArray & sparta::utils::BitArray::operator<<= ( size_t  amount)
inline

Definition at line 148 of file BitArray.hpp.

◆ operator==()

bool sparta::utils::BitArray::operator== ( const BitArray other) const
inline

Definition at line 130 of file BitArray.hpp.

◆ operator>>()

BitArray sparta::utils::BitArray::operator>> ( size_t  amount) const
inline

Definition at line 154 of file BitArray.hpp.

◆ operator>>=()

BitArray & sparta::utils::BitArray::operator>>= ( size_t  amount)
inline

Definition at line 161 of file BitArray.hpp.

◆ operator|()

BitArray sparta::utils::BitArray::operator| ( const BitArray other) const
inline

The size of the resulting BitArray will equal that of the left hand size array. If the right hand side array is the larger of the two, its upper bits will be truncated and will not be included in the result. If the left hand side is the larger, the result will contain its upper bits unchanged.

Definition at line 194 of file BitArray.hpp.

◆ operator|=()

BitArray & sparta::utils::BitArray::operator|= ( const BitArray other)
inline

Definition at line 201 of file BitArray.hpp.

◆ operator~()

BitArray sparta::utils::BitArray::operator~ ( ) const
inline

Definition at line 207 of file BitArray.hpp.


The documentation for this class was generated from the following file: