tudocomp
– The TU Dortmund Compression Framework
Literal.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cassert>
4 #include <tudocomp/def.hpp>
5 #include <tudocomp/util/View.hpp>
6 
7 namespace tdc {
8 
16 struct Literal {
19 
22 };
23 
25 public:
29  inline bool has_next() const { return false; }
30 
33  inline Literal next() { assert(false); return Literal{0, 0}; }
34 };
35 
38 };
39 
42 private:
43  View m_view;
44  len_t m_index;
45 
46 public:
50  inline ViewLiterals(View view) : m_view(view), m_index(0) {
51  }
52 
56  inline bool has_next() const {
57  return m_index < m_view.size();
58  }
59 
62  inline Literal next() {
63  assert(has_next());
64 
65  auto i = m_index++;
66  return Literal { uliteral_t(m_view[i]), i };
67  }
68 };
69 
70 }
71 
bool has_next() const
Tests whether there are more literals in the stream.
Definition: Literal.hpp:56
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
A const view into a slice of memory.
uint8_t uliteral_t
Type to represent signed single literals.
Definition: def.hpp:131
Literal next()
Yields the next literal from the stream.
Definition: Literal.hpp:33
size_type size() const
Returns size of the View.
A literal iterator that yields every character from a View.
Definition: Literal.hpp:41
Literal next()
Yields the next literal from the stream.
Definition: Literal.hpp:62
ViewLiterals(View view)
Constructor.
Definition: Literal.hpp:50
uliteral_t c
The literal.
Definition: Literal.hpp:18
An empty literal iterator that yields no literals whatsoever.
Definition: Literal.hpp:37
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
bool has_next() const
Tests whether there are more literals in the stream.
Definition: Literal.hpp:29
len_t pos
The position of the literal in the input.
Definition: Literal.hpp:21