aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/fieldvalue/variablemap.h
blob: d867c47c9b75af00131713823b68ad52be919fc0 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <map>
#include <memory>

namespace document {
    class FieldValue;
}

namespace document::fieldvalue {

class IndexValue {
public:
    IndexValue();
    IndexValue(int index_);
    IndexValue(const FieldValue& key_);
    IndexValue(IndexValue && rhs) noexcept;
    IndexValue & operator = (IndexValue && rhs) noexcept;
    IndexValue(const IndexValue & rhs);
    IndexValue & operator = (const IndexValue & rhs);

    ~IndexValue();

    vespalib::string toString() const;
    bool operator==(const IndexValue& other) const;

    int index; // For array
    std::unique_ptr<FieldValue> key; // For map/wset
};

using VariableMapT = std::map<vespalib::string, IndexValue>;

class VariableMap : public VariableMapT {
public:
    VariableMap();
    VariableMap(VariableMap && rhs) noexcept;
    VariableMap & operator = (VariableMap && rhs) noexcept;
    VariableMap(const VariableMap & rhs) = delete;
    VariableMap & operator = (const VariableMap & rhs) = delete;
    ~VariableMap();
    vespalib::string toString() const;
};

}