blob: f2fa16d1cdb5aab1f817222a10e6866c03a5dc33 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#pragma once
#include <library/cpp/scheme/scheme.h>
// Scheme adapter that holds referenced value
template <typename TScheme>
class TSchemeHolder {
public:
TSchemeHolder()
: Value_(NSc::Null())
, Scheme_(&Value_)
{
}
explicit TSchemeHolder(NSc::TValue&& value)
: Value_(std::move(value))
, Scheme_(&Value_)
{
}
explicit TSchemeHolder(const NSc::TValue& value)
: Value_(value)
, Scheme_(&Value_)
{
}
TSchemeHolder(TSchemeHolder<TScheme>&& rhs)
: Value_(std::move(rhs.Value_))
, Scheme_(&Value_)
{
}
TSchemeHolder(const TSchemeHolder<TScheme>& rhs)
: Value_(rhs.Value_)
, Scheme_(&Value_)
{
}
TSchemeHolder<TScheme>& operator=(TSchemeHolder<TScheme>&& rhs) {
Value_ = std::move(rhs.Value_);
return *this;
}
TSchemeHolder<TScheme>& operator=(const TSchemeHolder<TScheme>& rhs) {
Value_ = rhs.Value_;
return *this;
}
TScheme& Scheme() {
return Scheme_;
}
const TScheme& Scheme() const {
return Scheme_;
}
TScheme& operator->() {
return Scheme_;
}
const TScheme& operator->() const {
return Scheme_;
}
NSc::TValue& Value() {
return Value_;
}
const NSc::TValue& Value() const {
return Value_;
}
bool IsNull() const {
return Value_.IsNull();
}
private:
NSc::TValue Value_;
TScheme Scheme_;
};
|