aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/resource/registry.h
blob: a2d0ef768df7d3e31848569dc34b0e83b8212f35 (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
#pragma once

#include <util/generic/string.h>
#include <util/generic/strbuf.h>

#include "resource.h"

namespace NResource {
    TString Compress(const TStringBuf data);
    TString Decompress(const TStringBuf data);

    class IMatch {
    public:
        virtual void OnMatch(const TResource& res) = 0;
    };

    class IStore {
    public:
        virtual void Store(const TStringBuf key, const TStringBuf data) = 0;
        virtual bool Has(const TStringBuf key) const = 0;
        virtual bool FindExact(const TStringBuf key, TString* out) const = 0;
        virtual void FindMatch(const TStringBuf subkey, IMatch& cb) const = 0;
        virtual size_t Count() const noexcept = 0;
        virtual TStringBuf KeyByIndex(size_t idx) const = 0;
        virtual ~IStore() {
        }
    };

    IStore* CommonStore();

    struct TRegHelper {
        inline TRegHelper(const TStringBuf key, const TStringBuf data) {
            CommonStore()->Store(key, data);
        }
    };
}