blob: a3e5a2a8e90c083e0fac6da9f3049520c5d1192f (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "nix_value.h"
#include "value_factory.h"
namespace vespalib::slime {
class RootValue
{
private:
Value *_value;
Stash *_stash;
public:
RootValue(Stash * stash) noexcept : _value(NixValue::instance()), _stash(stash) {}
RootValue(RootValue && rhs) noexcept : _value(rhs._value), _stash(rhs._stash) {
rhs._value = NixValue::instance();
rhs._stash = nullptr;
}
RootValue(const RootValue &) = delete;
RootValue &operator=(const RootValue &) = delete;
RootValue &operator=(RootValue && rhs) noexcept {
_value = rhs._value;
_stash = rhs._stash;
rhs._value = NixValue::instance();
rhs._stash = nullptr;
return *this;
}
Cursor &get() const noexcept { return *_value; }
Cursor &set(const ValueFactory &input) {
Value *value = input.create(*_stash);
_value = value;
return *value;
}
Value *wrap(SymbolTable &table, SymbolInserter &symbol);
~RootValue() = default;
};
} // namespace vespalib::slime
|