#pragma once #include "dd_vector.hpp" #include "polymorph_reader.hpp" #include "../std/function.hpp" #include "../std/scoped_ptr.hpp" #include "../std/string.hpp" #include "../base/base.hpp" #include "../base/exception.hpp" class Reader; class BlobStorage { public: DECLARE_EXCEPTION(OpenException, RootException); typedef function DecompressorType; // Takes ownership of pReader and deletes it, even if exception is thrown. BlobStorage(Reader const * pReader, DecompressorType const & decompressor); ~BlobStorage(); // Get blob by its number, starting from 0. void GetBlob(uint32_t i, string & blob) const; // Returns the number of blobs. uint32_t Size() const; private: void Init(); uint32_t GetChunkFromBI(uint32_t blobInfo) const; uint32_t GetOffsetFromBI(uint32_t blobInfo) const; uint32_t m_bitsInChunkSize; static uint32_t const HEADER_SIZE = 4; scoped_ptr m_pReader; DecompressorType m_decompressor; DDVector m_blobInfo; DDVector m_chunkOffset; };