1// Aseprite Document IO Library
2// Copyright (c) 2018 Igara Studio S.A.
3// Copyright (c) 2017 David Capello
4//
5// This file is released under the terms of the MIT license.
6// Read LICENSE.txt for more information.
7
8#ifndef DIO_DECODER_H_INCLUDED
9#define DIO_DECODER_H_INCLUDED
10#pragma once
11
12#include <cstdint>
13#include <cstring>
14
15namespace doc {
16 class Document;
17}
18
19namespace dio {
20
21class DecodeDelegate;
22class FileInterface;
23
24class Decoder {
25public:
26 Decoder();
27 virtual ~Decoder();
28 virtual void initialize(DecodeDelegate* delegate, FileInterface* f);
29 virtual bool decode() = 0;
30
31protected:
32 DecodeDelegate* delegate() { return m_delegate; }
33 FileInterface* f() { return m_f; }
34
35 uint8_t read8();
36 uint16_t read16();
37 uint32_t read32();
38 size_t readBytes(uint8_t* buf, size_t n);
39
40private:
41 DecodeDelegate* m_delegate;
42 FileInterface* m_f;
43};
44
45} // namespace dio
46
47#endif
48