aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/vespa/document/fieldvalue/shortfieldvalue.h
blob: 232db1eff59d80c7b283ec8495d760a0a74e6d63 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
 * \class document::ShortFieldValue
 * \ingroup fieldvalue
 *
 * \brief Wrapper for field values of datatype SHORT.
 */
#pragma once

#include "numericfieldvalue.h"
#include <vespa/document/datatype/datatype.h>

namespace document {

class ShortFieldValue final : public NumericFieldValue<int16_t> {
public:
    using UP = std::unique_ptr<ShortFieldValue>;
    using Number = int16_t;

    ShortFieldValue(Number value = 0)
        : NumericFieldValue<Number>(Type::SHORT, value) {}

    void accept(FieldValueVisitor &visitor) override { visitor.visit(*this); }
    void accept(ConstFieldValueVisitor &visitor) const override { visitor.visit(*this); }

    const DataType *getDataType() const override { return DataType::SHORT; }
    ShortFieldValue* clone() const override { return new ShortFieldValue(*this); }

    using NumericFieldValue<Number>::operator=;
    static std::unique_ptr<ShortFieldValue> make(int16_t value = 0) { return std::make_unique<ShortFieldValue>(value); }
};

} // document