cds  2.3.2
cds::algo::byte_splitter< BitString, BitStringSize, UInt > Class Template Reference

Simplified split_bitstring algorithm when count is multiple of 8. More...

#include <cds/algo/split_bitstring.h>

Public Types

typedef BitString bitstring
 Bit-string type.
 
typedef UInt uint_type
 Result type of cut() function.
 

Public Member Functions

 byte_splitter (bitstring const &h)
 Initializises the splitter with reference to h and zero start bit offset.
 
 byte_splitter (bitstring const &h, size_t nBitOffset)
 Initializises the splitter with reference to h and start bit offset nBitOffset.
 
 operator bool () const
 Returns true if end-of-string is not reached yet.
 
bool eos () const
 Returns true if end-of-stream encountered.
 
uint_type cut (unsigned count)
 Cuts next count bits (must be multiplier of 8) from bit-string. More...
 
uint_type safe_cut (unsigned count)
 Cuts up to count from the bit-string. More...
 
void reset () noexcept
 Resets the splitter.
 
bitstring const * source () const
 Returns pointer to source bitstring.
 
size_t bit_offset () const
 Returns current bit offset from beginning of bit-string.
 
size_t rest_count () const
 Returns how many bits remain.
 

Static Public Member Functions

static constexpr bool is_correct (unsigned count)
 Checks if count is multiple of 8.
 

Static Public Attributes

static constexpr size_t const c_bitstring_size = BitStringSize ? BitStringSize : sizeof( BitString )
 size of BitString in bytes
 

Detailed Description

template<typename BitString, size_t BitStringSize = sizeof( BitString ), typename UInt = unsigned>
class cds::algo::byte_splitter< BitString, BitStringSize, UInt >

Simplified split_bitstring algorithm when count is multiple of 8.

Member Function Documentation

◆ cut()

template<typename BitString , size_t BitStringSize = sizeof( BitString ), typename UInt = unsigned>
uint_type cds::algo::byte_splitter< BitString, BitStringSize, UInt >::cut ( unsigned  count)
inline

Cuts next count bits (must be multiplier of 8) from bit-string.

For performance reason, the function does not manage out-of-bound condition. To control that use safe_cut().

◆ safe_cut()

template<typename BitString , size_t BitStringSize = sizeof( BitString ), typename UInt = unsigned>
uint_type cds::algo::byte_splitter< BitString, BitStringSize, UInt >::safe_cut ( unsigned  count)
inline

Cuts up to count from the bit-string.

Safe analog of cut(): if count is more than the rest of bit-string, only the rest is returned. When eos() condition is met the function returns 0.


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

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:13 by Doxygen 1.8.13