libUTL++
RLencoder.h
1 #pragma once
2 
4 
5 #include <libutl/Encoder.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
33 
35 class RLencoder : public Encoder
36 {
38 
39 public:
50  Stream* stream,
51  bool owner = true,
52  uint_t minRunLength = 3,
53  uint_t runLengthBits = 8,
54  bool eob = true)
55  {
56  init();
57  start(mode, stream, owner, minRunLength, runLengthBits, eob);
58  }
59 
60  virtual size_t decode(byte_t* block, size_t num);
61 
62  virtual size_t encode(const byte_t* block, size_t num);
63 
73  void start(uint_t mode,
74  Stream* stream,
75  bool owner = true,
76  uint_t minRunLength = 3,
77  uint_t runLengthBits = 8,
78  bool eob = true);
79 
80 protected:
81  virtual void clear();
82  virtual void finishEncoding();
83 
84 private:
85  void init();
86  void
87  deInit()
88  {
89  close();
90  }
91  void clearSelf();
92  bool
93  getEOB() const
94  {
95  return getFlag(flg_eob);
96  }
97  void
98  setEOB(bool eob)
99  {
100  setFlag(flg_eob, eob);
101  }
102 
103 private:
104  uint_t _minRunLen;
105  uint_t _maxRunLen;
106  uint_t _runLenBits;
107  int _saveC2;
108  enum flg_t
109  {
110  flg_eob = 9
111  };
112 };
113 
115 
116 UTL_NS_END;
void deInit()
De-initialize UTL++.
Encoder/decoder abstraction.
Definition: Encoder.h:39
Run-length coder.
Definition: RLencoder.h:35
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
unsigned char byte_t
Unsigned character.
Definition: types.h:31
RLencoder(uint_t mode, Stream *stream, bool owner=true, uint_t minRunLength=3, uint_t runLengthBits=8, bool eob=true)
Constructor.
Definition: RLencoder.h:49
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
Stream I/O abstraction.
Definition: Stream.h:68
void init()
Initialize UTL++.