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 | |
15 | namespace doc { |
16 | class Document; |
17 | } |
18 | |
19 | namespace dio { |
20 | |
21 | class DecodeDelegate; |
22 | class FileInterface; |
23 | |
24 | class Decoder { |
25 | public: |
26 | Decoder(); |
27 | virtual ~Decoder(); |
28 | virtual void initialize(DecodeDelegate* delegate, FileInterface* f); |
29 | virtual bool decode() = 0; |
30 | |
31 | protected: |
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 | |
40 | private: |
41 | DecodeDelegate* m_delegate; |
42 | FileInterface* m_f; |
43 | }; |
44 | |
45 | } // namespace dio |
46 | |
47 | #endif |
48 | |