blob: 584ac182995d06df5c57f6a60844107a91758def (
plain) (
blame)
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
|
#pragma once
#include "base64stream.h"
#include <util/memory/blob.h>
#include <util/stream/zlib.h>
#include <util/generic/ptr.h>
class TCompressedStaticData {
public:
using TDataFunction = const char* (*)(size_t);
using TData = TBlob;
class TDataInputStream: public IInputStream {
public:
TDataInputStream(TDataFunction function)
: Compressed(function)
, Decompressed(&Compressed)
{
}
private:
size_t DoRead(void* buf, size_t len) override {
return Decompressed.Read(buf, len);
}
private:
TStringDataInputStream Compressed;
TZLibDecompress Decompressed;
};
TCompressedStaticData(TDataFunction function) {
TDataInputStream inp(function);
Data = TBlob::FromStream(inp);
}
const TData& GetData() const {
return Data;
}
private:
TData Data;
};
|