tudocomp
– The TU Dortmund Compression Framework
LZSSLiterals.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <istream>
4
#include <
tudocomp/Literal.hpp
>
5
#include <
tudocomp/compressors/lzss/LZSSFactors.hpp
>
6
7
namespace
tdc
{
8
namespace
lzss {
9
10
template
<
typename
text_t>
11
class
TextLiterals
:
LiteralIterator
{
12
private
:
13
const
text_t* m_text;
14
const
FactorBuffer
* m_factors;
15
len_t
m_pos;
16
FactorBuffer::const_iterator
m_next_factor;
17
18
inline
void
skip_factors() {
19
while
(
20
m_next_factor != m_factors->
end
() &&
21
m_pos == m_next_factor->pos) {
22
23
m_pos +=
len_t
(m_next_factor->len);
24
++m_next_factor;
25
}
26
}
27
28
public
:
29
inline
TextLiterals
(
const
text_t& text,
const
FactorBuffer
& factors)
30
: m_text(&text),
31
m_factors(&factors),
32
m_pos(0),
33
m_next_factor(m_factors->begin()) {
34
35
skip_factors();
36
}
37
38
inline
bool
has_next
()
const
{
39
return
m_pos < m_text->size();
40
}
41
42
inline
Literal
next
() {
43
assert(
has_next
());
44
45
Literal
l = {
uliteral_t
((*m_text)[m_pos]),
len_t
(m_pos)};
46
47
++m_pos; skip_factors();
48
return
l;
49
}
50
};
51
52
}}
//ns
53
tdc::lzss::TextLiterals::next
Literal next()
Definition:
LZSSLiterals.hpp:42
tdc
Contains the text compression and encoding framework.
Definition:
namespaces.hpp:11
tdc::uliteral_t
uint8_t uliteral_t
Type to represent signed single literals.
Definition:
def.hpp:131
tdc::lzss::FactorBuffer
Definition:
LZSSFactors.hpp:23
Literal.hpp
LZSSFactors.hpp
tdc::LiteralIterator
Definition:
Literal.hpp:24
tdc::lzss::TextLiterals::has_next
bool has_next() const
Definition:
LZSSLiterals.hpp:38
tdc::Literal
Contains a literal and its location in the input.
Definition:
Literal.hpp:16
tdc::len_t
fast_t< len_compact_t > len_t
Type to represent an length value.
Definition:
def.hpp:114
tdc::lzss::FactorBuffer::end
const_iterator end() const
Definition:
LZSSFactors.hpp:53
tdc::lzss::TextLiterals
Definition:
LZSSLiterals.hpp:11
tdc::lzss::FactorBuffer::const_iterator
std::vector< Factor >::const_iterator const_iterator
Definition:
LZSSFactors.hpp:32
tdc::lzss::TextLiterals::TextLiterals
TextLiterals(const text_t &text, const FactorBuffer &factors)
Definition:
LZSSLiterals.hpp:29
include
tudocomp
compressors
lzss
LZSSLiterals.hpp
Generated by
1.8.13