A variable size container of bits (subclassed from std::deque<bool>) with an optional hierarchy. Similar to set::bitset but can be resized at runtime and has the ability to have parent Bitsets that can give bits to their children.
More...
|
| Bitset (Bitset *parent=nullptr) |
| Construct an empty Bitset. More...
|
|
| Bitset (size_type num_bits, unsigned long value=0, Bitset *parent=nullptr) |
| Construct a Bitset of a certain initial size and value. More...
|
|
void | get_more_bits (size_type num_bits) |
| Retrieve more bits from the parent Bitset. More...
|
|
Bitset & | operator&= (const Bitset &rhs) |
| Logical AND in place. More...
|
|
Bitset & | operator|= (const Bitset &rhs) |
| Logical OR in place. More...
|
|
Bitset & | operator^= (const Bitset &rhs) |
| Logical XOR in place. More...
|
|
Bitset & | operator<<= (size_type n) |
| Left shift in place. More...
|
|
Bitset & | operator>>= (size_type n) |
| Right shift in place. More...
|
|
Bitset | operator<< (size_type n) const |
| Left shift. More...
|
|
Bitset | operator>> (size_type n) const |
| Right shift. More...
|
|
Bitset & | set (size_type n, bool val=true) |
| Set a bit to a given value. More...
|
|
Bitset & | set () |
| Set all bits true. More...
|
|
Bitset & | reset (size_type n) |
| Reset a bit (i.e. set it to false) More...
|
|
Bitset & | reset () |
| Set all bits false. More...
|
|
Bitset & | flip (size_type n) |
| Flip (toggle) a bit. More...
|
|
Bitset & | flip () |
| Flip (toggle) all bits. More...
|
|
bool | test (size_type n) const |
| Test a bit (return its value) More...
|
|
template<typename IntType > |
void | from (IntType value, size_type num_bits=std::numeric_limits< IntType >::digits) |
| Sets value of the Bitset to the contents of an integer. More...
|
|
void | from_ulong (unsigned long value, size_type num_bits=std::numeric_limits< unsigned long >::digits) |
| Sets value of the Bitset to the contents of an unsigned long integer. Equivalent to from<unsigned long>()
|
|
template<typename IntType > |
IntType | to () const |
| Returns the value of the Bitset as a integer. More...
|
|
unsigned long | to_ulong () const |
| Returns the value of the Bitset as an unsigned long integer. Equivalent to to<unsigned long>().
|
|
std::string | to_string () const |
| Returns the value of the Bitset as a printable string, where each bit is represented by '1' or '0'. The msb is written into the zero index of the string, so it is printed msb to lsb (as is standard for writing numbers).
|
|
std::string | to_byte_string () |
| Returns the value of the Bitset to a byte string, where each character represents 8 bits of the Bitset. The string is used as a byte container, and is not intended to be printed. More...
|
|
size_t | to_byte_string (char *buf, size_t max_len) |
| Generate a byte string representation of the Bitset, where each character represents 8 bits of the Bitset. The string is used as a byte container, and is not intended to be printed. More...
|
|
void | from_byte_string (const std::string &s) |
| Sets the value of the Bitset to the contents of a byte string, where each character represents 8 bits of the Bitset. More...
|
|
template<typename CharIterator > |
void | from_byte_stream (CharIterator begin, CharIterator end) |
| Sets the value of the Bitset to the contents of a byte string, where each character represents 8 bits of the Bitset. A string container the values where the least signficant byte in string[0] and the most significant byte in string[size()-1]. More...
|
|
Bitset & | prepend (const Bitset &bits) |
| Adds the bitset to the little end.
|
|
Bitset & | append (const Bitset &bits) |
| Adds the bitset to the big end.
|
|
A variable size container of bits (subclassed from std::deque<bool>) with an optional hierarchy. Similar to set::bitset but can be resized at runtime and has the ability to have parent Bitsets that can give bits to their children.
This is the class used within DCCL hold the encoded message as it is created. The front() of the deque represents the least significant bit (lsb) and the back() is the most significant bit (msb). DCCL messages are encoded and decoded starting with the lsb and ending at the msb. The hierarchy is used to represent parent bit pools from which the child can pull more bits from to decode. The top level Bitset represents the entire encoded message, whereas the children are the message fields.
Definition at line 42 of file bitset.h.