aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/sqlite/sqlitetimestamp.h
blob: fbd4d2dcc17522a2592ffd70ccbde710621efda5 (plain)
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
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

namespace Sqlite {

class TimeStamp
{
public:
    TimeStamp() = default;
    TimeStamp(long long value)
        : value(value)
    {}

    friend bool operator==(TimeStamp first, TimeStamp second)
    {
        return first.value == second.value;
    }

    friend bool operator!=(TimeStamp first, TimeStamp second) { return !(first == second); }
    friend bool operator<(TimeStamp first, TimeStamp second) { return first.value < second.value; }

    friend TimeStamp operator+(TimeStamp first, TimeStamp second)
    {
        return first.value + second.value;
    }

    friend TimeStamp operator-(TimeStamp first, TimeStamp second)
    {
        return first.value - second.value;
    }

    bool isValid() const { return value >= 0; }

    long long operator*() { return value; }

public:
    long long value = -1;
};

} // namespace Sqlite