aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/archive/models_archive_reader.h
blob: a5731b01cb4bd0753cd0b4367f2efdf53475912d (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
#pragma once

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

class IInputStream;

class TBlob;

class IModelsArchiveReader {
public:
    virtual ~IModelsArchiveReader() = default;
    virtual size_t Count() const = 0;
    virtual TString KeyByIndex(size_t n) const = 0;
    virtual bool Has(const TStringBuf key) const = 0;
    virtual TAutoPtr<IInputStream> ObjectByKey(const TStringBuf key) const = 0;
    virtual TBlob ObjectBlobByKey(const TStringBuf key) const = 0;
    virtual TBlob BlobByKey(const TStringBuf key) const = 0;
    virtual bool Compressed() const = 0;
    virtual THashSet<TStringBuf> FilterByPrefix(TStringBuf prefix, TStringBuf suffix) const {
        THashSet<TStringBuf> result;
        for (size_t ind = 0; ind < Count(); ++ind) { 
                TStringBuf path = KeyByIndex(ind);
                if (path.StartsWith(prefix) && path.EndsWith(suffix)) {
                    result.insert(path);
                }
        }
        return result;
    }
};