aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/data/slime/symbol.h
blob: 7a4b94293ee6f71be30f638ca395aa5716416ffb (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <cstdint>

namespace vespalib::slime {

/**
 * A Symbol may be used to look up a field within an OBJECT.
 **/
class Symbol
{
private:
    static constexpr uint32_t UNDEFINED = (uint32_t)-1;

    uint32_t _value;

public:
    Symbol() noexcept : _value(UNDEFINED) {}
    Symbol(uint32_t v) noexcept : _value(v) {}
    bool undefined() const noexcept { return (_value == UNDEFINED); }
    uint32_t getValue() const noexcept { return _value; }
    bool operator<(const Symbol &rhs) const noexcept { return (_value < rhs._value); }
    bool operator==(const Symbol &rhs) const noexcept { return (_value == rhs._value); }
};

} // namespace vespalib::slime