| BitString & append(BitString const &str) | Concatenates two bit strings. The resulting string is
returned, allowing multiple appends to be appended to each
other (e.g. "a.append(b).append(c).append(e)").
|
| const char * ascii() const | Return an ASCII string, treating each 8 bits as a character. The
return value will be valid until this bitstring remains in scope or
ascii() is called again.
|
| const char * ascii7() const | Return an ASCII string, treating each 7 bits as a character.
|
| bool at(unsigned index, bool * ok = 0) const | Returns the value of the bit at index index as a boolean.
If ok is provided, then it will be set to true if index is in range.
|
| const char * ccp() const | Return a character pointer to the data.
The returned character pointer will point to contiguous memory
where the data of the bitstring can be found. Any bits following
the first length() bits are undefined.
This is a logically const method.
If the internal representation of the bit string happens to be
contiguous and byte aligned, then the address is returned
(complexity of O(1)). Otherwise, the internal data will have to be
manipulated (i.e. moved -- complexity of O(n)).
The returned pointer will point to valid data as long as no other
non-const operations are performed on the data and the bit string
remains in scope.
|
| void clear() | Clear the bit string (making it empty).
|
| bool empty() const | Returns true if the bit string is empty.
|
| BitString & insert(BitString const &str, unsigned index) | Insert a bit string before index. The bit string will be
prepended if index is 0. It will be appended if index is
length().
|
| unsigned length() const | Returns length of string in bits. Returns 0 if this is an empty bit string.
|
| BitString & minimize() | Remove all leading 0 bits.
|
| BitString & padLeft(unsigned width = 8) | Expand the bit string's length to a multiple of width bits,
left padding with zeroes. Returns a reference to self.
|
| BitString & padRight(unsigned width = 8) | Expand the bit string's length to a multiple of width bits,
right padding with zeroes. Returns a reference to self.
|
| unsigned index() const | Returns the current index. This is used by peek(), read(), etc.
|
| BitString read(size_t length) | Returns length bits as another bit string. The next read() or
peek() will begin at length + 1 bits. An empty bit string is
returned if length is 0, length is greater than the length of
the bit string, or the bit string is null.
|
| BitString peek(size_t length) const | Same as read(), but the internal bit index is not updated, leaving
the bit string in the exact same state it was before this method is
called.
|
| bool seek(int offset, int whence = 0) | Moves the index ahead offset. If offset goes beyond the end
of the string, the seek is not done and false is returned. If
whence is positive, 0, or negative, the offset is relative to the
start of the bit string, the current position, or the end of the bit
string, respectively. The default is relative.
|
| unsigned remaining() const | This is a convenience method. It is the same as length() -
index().
|
| void replace(int index, BitString const & bs) | Replace the bitstring starting at index index with bs.
The bitstring does not grow in size.
|
| bool set(unsigned index) | Set a bit to 1 at index index. Returns false if index is out
of range.
|
| bool reset(unsigned index) | Reset a bit to 0 at index index. Returns false if index is
out of range.
|
| void resize(size_t length) | Either truncates the bit string or right pads with 0s in order to
make the length equal to length.
|
| BitString substr(size_t begin_index, size_t length) const | Returns a section of the bit string as another bit string. Returns
an empty string if the requested bit string is out of range, or this
is an empty string.
This method is logically const.
|
| const char * toBinString() const | Returns a string of '1' and '0' characters.
|
| char * toBinString(char * dest, size_t length) const | Returns a string of '1' and '0' characters.
|
| const char * toHexString() const | Returns a string of [0-9A-F] characters. The string will be zero
padded on the right to make it byte aligned.
|
| char * toHexString(char * dest, size_t length) const | Returns a string of [0-9A-F] characters. The string will be zero
padded on the right to make it byte aligned.
|