Skip to content

Commit 91036f4

Browse files
added get_char_cbk
1 parent 8fe6ae7 commit 91036f4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/decompress/lzss.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ int LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
181181
}
182182
}
183183

184+
LZSSDecoder::LZSSDecoder(std::function<int()> getc_cbk, std::function<void(const uint8_t)> putc_cbk)
185+
: put_char_cbk(putc_cbk), get_char_cbk(getc_cbk), state(FSM_0), available(0) {
186+
for (int i = 0; i < N - F; i++) buffer[i] = ' ';
187+
r = N - F;
188+
}
189+
190+
184191
LZSSDecoder::LZSSDecoder(std::function<void(const uint8_t)> putc_cbk)
185192
: put_char_cbk(putc_cbk), state(FSM_0), available_bits(0) {
186193
for (int i = 0; i < N - F; i++) buffer[i] = ' ';

src/decompress/lzss.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ void lzss_flush();
2222
**************************************************************************************/
2323

2424

25-
// TODO improve documentation
2625
class LZSSDecoder {
2726
public:
28-
LZSSDecoder(std::function<void(const uint8_t)>);
27+
28+
LZSSDecoder(std::function<void(const uint8_t)> putc_cbk);
29+
30+
LZSSDecoder(std::function<int()> getc_cbk, std::function<void(const uint8_t)> putc_cbk);
31+
2932
/**
3033
* this enum describes the result of the computation of a single FSM computation
3134
* DONE: the decompression is completed
@@ -85,6 +88,7 @@ class LZSSDecoder {
8588
int i, r;
8689

8790
std::function<void(const uint8_t)> put_char_cbk=nullptr;
91+
std::function<void(const uint8_t)> get_char_cbk=nullptr;
8892

8993
inline void putc(const uint8_t c) { if(put_char_cbk) { put_char_cbk(c); } }
9094

0 commit comments

Comments
 (0)