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);
stream_pos(const stream_pos &cp);
intmax_t as_bits() const;
intmax_t get_byte() 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:
uint8_t *m_buffer;
std::size_t m_buffer_size;

View File

@ -37,9 +37,9 @@ namespace ki
>::type;
/**
* The integer type that can most efficiently store N bits
* without signedness.
*/
* The integer type that can most efficiently store N bits
* without signedness.
*/
using uint_type = typename std::conditional<
N <= 8,
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>
using bi = BitInteger<N, false>;
/**
* Represents an unsigned integer of N bits.
*/
* Represents an unsigned integer of N bits.
*/
template <uint8_t N>
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>
struct bitsizeof
{
/**
* The number of bits a type will occupy if written to a BitStream.
* This does not reflect the size of the type in memory.
*/
* The number of bits a type will occupy if written to a BitStream.
* This does not reflect the size of the type in memory.
*/
static constexpr std::size_t value = sizeof(T) * 8;
};
@ -206,4 +206,4 @@ namespace ki
template <uint8_t N, bool Unsigned>
struct is_integral<BitInteger<N, Unsigned>> : std::true_type {};
}
}