blob: 51aafcb051f370b1ecf028d7f43d9b595cbb3ac6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#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<void (char const *, size_t, char *, size_t)> 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<Reader const> m_pReader;
DecompressorType m_decompressor;
DDVector<uint32_t, PolymorphReader> m_blobInfo;
DDVector<uint32_t, PolymorphReader> m_chunkOffset;
};
|