summaryrefslogtreecommitdiffstats
path: root/src/grpc/qtgrpcnamespace.h
blob: f68a47d14e2bc3f818bc36f3f9b11b7548263ffb (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
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
73
74
75
76
77
78
79
80
81
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QTGRPCNAMESPACE_H
#define QTGRPCNAMESPACE_H

#if 0
#pragma qt_class(QtGrpcNamespace)
#endif

#include <QtGrpc/qtgrpcexports.h>

#include <QtCore/qcompare.h>
#include <QtCore/qlatin1stringview.h>
#include <QtCore/qtmetamacros.h>

QT_BEGIN_NAMESPACE

struct QMetaObject;

namespace QtGrpc {
Q_NAMESPACE_EXPORT(Q_GRPC_EXPORT)

enum class SerializationFormat : quint8 {
    Default,
    Protobuf,
    Json,
};
Q_ENUM_NS(SerializationFormat)

enum class StatusCode : quint8 {
    Ok = 0,
    Cancelled = 1,
    Unknown = 2,
    InvalidArgument = 3,
    DeadlineExceeded = 4,
    NotFound = 5,
    AlreadyExists = 6,
    PermissionDenied = 7,
    ResourceExhausted = 8,
    FailedPrecondition = 9,
    Aborted = 10,
    OutOfRange = 11,
    Unimplemented = 12,
    Internal = 13,
    Unavailable = 14,
    DataLoss = 15,
    Unauthenticated = 16,
};
Q_ENUM_NS(StatusCode)

enum class RpcType : quint8 {
    UnaryCall,
    ServerStreaming,
    ClientStreaming,
    BidiStreaming,
};

struct RpcDescriptor
{
    const QLatin1StringView service;
    const QLatin1StringView method;
    const RpcType type;

private:
    friend bool comparesEqual(const RpcDescriptor &lhs, const RpcDescriptor &rhs) noexcept
    {
        return lhs.service == rhs.service && lhs.method == rhs.method && lhs.type == rhs.type;
    }
    Q_DECLARE_EQUALITY_COMPARABLE(RpcDescriptor)
};

// ### Qt7: remove QHash metadata interfaces.
inline QT_DEFINE_TAG(MultiValue);

Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
} // namespace QtGrpc

QT_END_NAMESPACE

#endif // QTGRPCNAMESPACE_H