QtProtobuf  0.6
Protobuf plugin to generate Qt classes
qgrpcstatus.h
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
5  *
6  * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy of this
9  * software and associated documentation files (the "Software"), to deal in the Software
10  * without restriction, including without limitation the rights to use, copy, modify,
11  * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
12  * to permit persons to whom the Software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in all copies
16  * or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21  * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  */
25 
26 #pragma once //QGrpcStatus
27 
28 #include <QString>
29 #include <QMetaType>
30 #include <qobjectdefs.h>
31 
32 #include "qtgrpcglobal.h"
33 #include <memory>
34 
35 namespace QtProtobuf {
36 
37 class QGrpcStatusPrivate;
38 
58 class Q_GRPC_EXPORT QGrpcStatus final {
59  Q_GADGET
60  Q_PROPERTY(StatusCode code READ code CONSTANT)
61  Q_PROPERTY(QString message READ message CONSTANT)
62 public:
69  enum StatusCode {
70  Ok = 0,
71  Cancelled = 1,
72  Unknown = 2,
73  InvalidArgument = 3,
74  DeadlineExceeded = 4,
75  NotFound = 5,
76  AlreadyExists = 6,
77  PermissionDenied = 7,
78  Unauthenticated = 16,
79  ResourceExhausted = 8,
80  FailedPrecondition = 9,
81  Aborted = 10,
82  OutOfRange = 11,
83  Unimplemented = 12,
84  Internal = 13,
85  Unavailable = 14,
86  DataLoss = 15,
87  };
88 
89  Q_ENUM(StatusCode)
90 
91  QGrpcStatus(StatusCode code = StatusCode::Ok, const QString &message = QString());
92  ~QGrpcStatus();
93 
97  StatusCode code() const;
98 
102  QString message() const;
103 
104  bool operator ==(StatusCode code) const;
105  bool operator !=(StatusCode code) const;
106  bool operator ==(const QGrpcStatus &other) const;
107 
108  QGrpcStatus(const QGrpcStatus &other);
109  QGrpcStatus &operator =(const QGrpcStatus &other);
110 
111  QGrpcStatus(QGrpcStatus &&other);
112  QGrpcStatus &operator =(QGrpcStatus &&other);
113 
114 private:
115  std::unique_ptr<QGrpcStatusPrivate> dPtr;
116 };
117 }
118 
119 bool operator ==(QtProtobuf::QGrpcStatus::StatusCode code, const QtProtobuf::QGrpcStatus &status);
120 bool operator !=(QtProtobuf::QGrpcStatus::StatusCode code, const QtProtobuf::QGrpcStatus &status);
121 
122 Q_DECLARE_METATYPE(QtProtobuf::QGrpcStatus)
The QGrpcStatus class contains information about last gRPC operation.
Definition: qgrpcstatus.h:58
StatusCode
Channel's status codes.
Definition: qgrpcstatus.h:69