blob: f21c629d187e3ba1d0aa9547e827cf4b687418d1 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include "resource.h"
#include "resource.h"
#include "registry.h"
#include <util/generic/yexception.h>
#include <util/generic/xrange.h>
using namespace NResource;
bool NResource::FindExact(const TStringBuf key, TString* out) {
return CommonStore()->FindExact(key, out);
}
void NResource::FindMatch(const TStringBuf subkey, TResources* out) {
struct TMatch: public IMatch {
inline TMatch(TResources* r)
: R(r)
{
}
void OnMatch(const TResource& res) override {
R->push_back(res);
}
TResources* R;
};
TMatch m(out);
CommonStore()->FindMatch(subkey, m);
}
bool NResource::Has(const TStringBuf key) {
return CommonStore()->Has(key);
}
TString NResource::Find(const TStringBuf key) {
TString ret;
if (FindExact(key, &ret)) {
return ret;
}
ythrow yexception() << "can not find resource with path " << key;
}
size_t NResource::Count() noexcept {
return CommonStore()->Count();
}
TStringBuf NResource::KeyByIndex(size_t idx) {
return CommonStore()->KeyByIndex(idx);
}
TVector<TStringBuf> NResource::ListAllKeys() {
TVector<TStringBuf> res(Reserve(NResource::Count()));
for (auto i : xrange(NResource::Count())) {
res.push_back(NResource::KeyByIndex(i));
}
return res;
}
|