aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/resource/registry.h
blob: fe67702cbc2894966b49eefdc696e48bc9d89ad3 (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
#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 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);
        }
    };
}