Variable binary width code reader.
More...
|
std::istream & | is |
| Input Stream.
|
|
std::size_t | bits |
| Binary width of codes.
|
|
bool | feofmc |
| Found End-Of-File MetaCode.
|
|
ByteCache | lo |
| LeftOvers.
|
|
Variable binary width code reader.
Definition at line 322 of file lzw_v6.cpp.
CodeReader::CodeReader |
( |
std::istream & |
is | ) |
|
|
inlineexplicit |
Default constructor.
- Parameters
-
[in] | is | Input Stream to read codes from |
Definition at line 329 of file lzw_v6.cpp.
bool CodeReader::corrupted |
( |
| ) |
const |
|
inline |
Returns if EF is considered corrupted.
- Return values
-
true | didn't find end-of-file metacode |
false | found end-of-file metacode |
Definition at line 416 of file lzw_v6.cpp.
References feofmc.
void CodeReader::increase_bits |
( |
| ) |
|
|
inline |
Increases internal binary width by one.
- Exceptions
-
std::overflow_error | if internal binary width cannot be increased |
Definition at line 355 of file lzw_v6.cpp.
References bits.
358 if (
bits == SIZE_MAX)
359 throw std::overflow_error(
"CodeReader::increase_bits()");
Reads the code k
with a binary width of CodeReader::bits
.
- Parameters
-
- Returns
- Whether or not the stream can be used for input.
- Return values
-
true | the input stream can still be used |
false | the input stream can no longer be used |
Definition at line 371 of file lzw_v6.cpp.
References bits, ByteCache::data, feofmc, is, lo, and ByteCache::used.
374 static const std::array<unsigned long int, 9> masks {
375 {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF}
378 std::size_t remaining_bits {
bits};
379 std::size_t offset {
lo.
used};
383 remaining_bits -=
lo.
used;
387 while (remaining_bits != 0 &&
is.get(reinterpret_cast<char &> (temp)))
388 if (remaining_bits >= CHAR_BIT)
390 k |=
static_cast<CodeType> (temp) << offset;
392 remaining_bits -= CHAR_BIT;
396 k |=
static_cast<CodeType> (temp & masks[remaining_bits]) << offset;
397 lo.
used = CHAR_BIT - remaining_bits;
398 lo.
data = temp >> remaining_bits;
402 if (k == static_cast<CodeType> (MetaCode::Eof))
void CodeReader::reset_bits |
( |
| ) |
|
|
inline |
Resets internal binary width.
- Note
- Default value is
CHAR_BIT + 1
.
Definition at line 345 of file lzw_v6.cpp.
References bits.
The documentation for this class was generated from the following file: