1 /* 2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> 3 * (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com> 4 * 5 * This file is part of lsp-plugins 6 * Created on: 14 янв. 2018 г. 7 * 8 * lsp-plugins is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * any later version. 12 * 13 * lsp-plugins is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef CORE_FILES_LSPC_LSPCCHUNKREADER_H_ 23 #define CORE_FILES_LSPC_LSPCCHUNKREADER_H_ 24 25 #include <core/files/lspc/LSPCChunkAccessor.h> 26 27 namespace lsp 28 { 29 30 class LSPCChunkReader: public LSPCChunkAccessor 31 { 32 private: 33 LSPCChunkReader & operator = (const LSPCChunkReader &); 34 35 protected: 36 friend class LSPCFile; 37 38 protected: 39 uint32_t nUnread; // Number of bytes still not read from chunk 40 size_t nBufTail; // Buffer tail 41 wsize_t nFileOff; // File read offset 42 bool bLast; 43 44 protected: 45 explicit LSPCChunkReader(LSPCResource *fd, uint32_t magic, uint32_t uid); 46 47 public: 48 virtual ~LSPCChunkReader(); 49 50 public: 51 /** 52 * Read chunk data header from LSPC chunk. Header should contain lspc_header_t at 53 * the beginning. 54 * @param hdr the header data to store 55 * @param size the size of header, should be at least sizeof(lspc_header_t) 56 * @return status of operation or error code (negative) 57 */ 58 virtual ssize_t read_header(void *hdr, size_t size); 59 60 /** 61 * Read regular data from LSPC chunk. 62 * @param buf the pointer to store data 63 * @param count number of bytes to read 64 * @return status of operation or error code (negative) 65 */ 66 virtual ssize_t read(void *buf, size_t count); 67 68 /** 69 * Skip some amount of data 70 * @param count amount of bytes to skip 71 * @return number of skipped bytes or error code (negative) 72 */ 73 virtual ssize_t skip(size_t count); 74 }; 75 76 } /* namespace lsp */ 77 78 #endif /* CORE_FILES_LSPC_LSPCCHUNKREADER_H_ */ 79