util: Forgot to push header file for previous commit

This commit is contained in:
Joshua Scott 2018-11-16 14:53:46 +00:00
parent b9455e243f
commit 25d371b49f
2 changed files with 28 additions and 13 deletions

View File

@ -21,6 +21,7 @@ namespace ki
explicit stream_pos(intmax_t byte = 0, int bit = 0); explicit stream_pos(intmax_t byte = 0, int bit = 0);
stream_pos(const stream_pos &cp); stream_pos(const stream_pos &cp);
intmax_t as_bits() const;
intmax_t get_byte() const; intmax_t get_byte() const;
uint8_t get_bit() const; uint8_t get_bit() const;
@ -148,6 +149,20 @@ namespace ki
} }
} }
/**
* Copy memory from an external buffer into the bitstream's buffer from the current position.
* @param src The buffer to copy data from.
* @param bitsize The number of bits to copy from the src buffer.
*/
void write_copy(uint8_t *src, std::size_t bitsize);
/**
* Copy memory from the bitstream's buffer into an external buffer.
* @param dst The destination buffer to copy data to.
* @param bitsize The number of bits to copy into the dst buffer.
*/
void read_copy(uint8_t *dst, std::size_t bitsize);
private: private:
uint8_t *m_buffer; uint8_t *m_buffer;
std::size_t m_buffer_size; std::size_t m_buffer_size;

View File

@ -37,9 +37,9 @@ namespace ki
>::type; >::type;
/** /**
* The integer type that can most efficiently store N bits * The integer type that can most efficiently store N bits
* without signedness. * without signedness.
*/ */
using uint_type = typename std::conditional< using uint_type = typename std::conditional<
N <= 8, N <= 8,
uint8_t, uint8_t,
@ -162,27 +162,27 @@ namespace ki
}; };
/** /**
* Represents a signed integer of N bits. * Represents a signed integer of N bits.
*/ */
template <uint8_t N> template <uint8_t N>
using bi = BitInteger<N, false>; using bi = BitInteger<N, false>;
/** /**
* Represents an unsigned integer of N bits. * Represents an unsigned integer of N bits.
*/ */
template <uint8_t N> template <uint8_t N>
using bui = BitInteger<N, true>; using bui = BitInteger<N, true>;
/** /**
* A utility to calculate the bitsize of a type. * A utility to calculate the bitsize of a type.
*/ */
template <typename T, typename Enable = void> template <typename T, typename Enable = void>
struct bitsizeof struct bitsizeof
{ {
/** /**
* The number of bits a type will occupy if written to a BitStream. * The number of bits a type will occupy if written to a BitStream.
* This does not reflect the size of the type in memory. * This does not reflect the size of the type in memory.
*/ */
static constexpr std::size_t value = sizeof(T) * 8; static constexpr std::size_t value = sizeof(T) * 8;
}; };