blob: a323ea3585142a4e9f14ea5d94f58fea09b40f13 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "variablemap.h"
#include "fieldvalue.h"
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/stllike/asciistream.h>
namespace document::fieldvalue {
IndexValue::IndexValue() : index(-1), key() {}
IndexValue::IndexValue(int index_) : index(index_), key() {}
bool
IndexValue::operator==(const IndexValue& other) const {
if (key) {
if (other.key && *key == *other.key) {
return true;
}
return false;
}
return index == other.index;
}
IndexValue::IndexValue(const FieldValue& key_)
: index(-1),
key(key_.clone())
{ }
IndexValue::IndexValue(IndexValue && rhs) noexcept = default;
IndexValue & IndexValue::operator = (IndexValue && rhs) noexcept = default;
IndexValue::IndexValue(const IndexValue & rhs) :
index(rhs.index),
key(rhs.key ? rhs.key->clone() : nullptr)
{}
IndexValue & IndexValue::operator = (const IndexValue & rhs) {
if (this != & rhs) {
IndexValue tmp(rhs);
std::swap(index, tmp.index);
std::swap(key, tmp.key);
}
return *this;
}
IndexValue::~IndexValue() = default;
vespalib::string
IndexValue::toString() const {
if (key) {
return key->toString();
} else {
return vespalib::make_string("%d", index);
}
}
VariableMap::VariableMap(VariableMap && rhs) noexcept = default;
VariableMap & VariableMap::operator = (VariableMap && rhs) noexcept = default;
VariableMap::VariableMap() = default;
VariableMap::~VariableMap() = default;
vespalib::string
VariableMap::toString() const {
vespalib::asciistream out;
out << "[ ";
for (const auto & entry : *this) {
out << entry.first << "=" << entry.second.toString() << " ";
}
out << "]";
return out.str();
}
}
|