bit_reader_c/bit_writer_c: add constructors taking memory_c

This commit is contained in:
Moritz Bunkus 2018-11-21 16:31:44 +01:00
parent 65870e15af
commit 175f043ed1
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 11 additions and 0 deletions

View File

@ -38,6 +38,10 @@ public:
init(data, len);
}
reader_c(memory_c &data) {
init(data.get_buffer(), data.get_size());
}
void init(const unsigned char *data, std::size_t len) {
m_end_of_data = data + len;
m_byte_position = data;

View File

@ -41,6 +41,13 @@ public:
{
}
writer_c(memory_c &data)
: m_data{data.get_buffer()}
, m_size{data.get_size()}
, m_data_size{data.get_size()}
{
}
inline memory_cptr get_buffer() {
return memory_c::clone(m_data, m_size);
}