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>
6 
7 namespace tdc {
8 namespace lzss {
9 
10 template<typename text_t>
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 
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
uint8_t uliteral_t
Type to represent signed single literals.
Definition: def.hpp:131
Contains a literal and its location in the input.
Definition: Literal.hpp:16
fast_t< len_compact_t > len_t
Type to represent an length value.
Definition: def.hpp:114
const_iterator end() const
Definition: LZSSFactors.hpp:53
std::vector< Factor >::const_iterator const_iterator
Definition: LZSSFactors.hpp:32
TextLiterals(const text_t &text, const FactorBuffer &factors)