aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/archive/yarchive.h
blob: 50aaa253f2574d9b521bdb6dba42b1e850708d68 (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
44
45
46
47
48
#pragma once

#include "models_archive_reader.h"

#include <util/generic/fwd.h> 
#include <util/generic/ptr.h>


class IInputStream; 
class IOutputStream; 
 
class TBlob; 
 
//noncompressed data will be stored with default alignment DEVTOOLS-4384
static constexpr size_t ArchiveWriterDefaultDataAlignment = 16;

class TArchiveWriter {
public:
    explicit TArchiveWriter(IOutputStream* out, bool compress = true);
    ~TArchiveWriter();

    void Flush();
    void Finish();
    void Add(const TString& key, IInputStream* src); 
    void AddSynonym(const TString& existingKey, const TString& newKey);

private:
    class TImpl;
    THolder<TImpl> Impl_;
};

class TArchiveReader : public IModelsArchiveReader {
public:
    explicit TArchiveReader(const TBlob& data);
    ~TArchiveReader() override;

    size_t Count() const noexcept override;
    TString KeyByIndex(size_t n) const override;
    bool Has(TStringBuf key) const override;
    TAutoPtr<IInputStream> ObjectByKey(TStringBuf key) const override;
    TBlob ObjectBlobByKey(TStringBuf key) const override;
    TBlob BlobByKey(TStringBuf key) const override;
    bool Compressed() const override;

private:
    class TImpl;
    THolder<TImpl> Impl_;
};