webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
status.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef GOOGLE_PROTOBUF_STUBS_STATUS_H_
31 #define GOOGLE_PROTOBUF_STUBS_STATUS_H_
32 
33 #include <iosfwd>
34 #include <string>
35 
38 
39 namespace google {
40 namespace protobuf {
41 namespace util {
42 namespace error {
43 // These values must match error codes defined in google/rpc/code.proto.
44 enum Code {
45  OK = 0,
46  CANCELLED = 1,
47  UNKNOWN = 2,
50  NOT_FOUND = 5,
56  ABORTED = 10,
59  INTERNAL = 13,
61  DATA_LOSS = 15,
62 };
63 } // namespace error
64 
65 struct StatusPod {
67 };
68 
70  public:
71  // Creates a "successful" status.
72  Status();
73 
74  // Create a status in the canonical error space with the specified
75  // code, and error message. If "code == 0", error_message is
76  // ignored and a Status object identical to Status::OK is
77  // constructed.
78  Status(error::Code error_code, StringPiece error_message);
79  Status(const Status&);
80  Status(const StatusPod&);
81  Status& operator=(const Status& x);
82  ~Status() {}
83 
84  // Some pre-defined Status objects
85  static const StatusPod OK;
86  static const StatusPod CANCELLED;
87  static const StatusPod UNKNOWN;
88 
89  // Accessor
90  bool ok() const {
91  return error_code_ == error::OK;
92  }
93  int error_code() const {
94  return error_code_;
95  }
97  return error_message_;
98  }
99 
100  bool operator==(const Status& x) const;
101  bool operator!=(const Status& x) const {
102  return !operator==(x);
103  }
104 
105  // Return a combination of the error code name and message.
106  string ToString() const;
107 
108  private:
109  error::Code error_code_;
110  string error_message_;
111 };
112 
113 // Prints a human-readable representation of 'x' to 'os'.
114 LIBPROTOBUF_EXPORT ostream& operator<<(ostream& os, const Status& x);
115 
116 #define EXPECT_OK(value) EXPECT_TRUE((value).ok())
117 
118 } // namespace util
119 } // namespace protobuf
120 } // namespace google
121 #endif // GOOGLE_PROTOBUF_STUBS_STATUS_H_
Definition: util.py:1
Definition: status.h:45
StringPiece error_message() const
Definition: status.h:96
int error_code() const
Definition: status.h:93
bool operator==(const uint128 &lhs, const uint128 &rhs)
Definition: int128.h:136
bool operator!=(const Status &x) const
Definition: status.h:101
error::Code code
Definition: status.h:66
bool ok() const
Definition: status.h:90
ostream & operator<<(ostream &os, const Status &x)
Definition: status.cc:130
Definition: stringpiece.h:178
EGLSurface EGLint x
Definition: eglext.h:950
Definition: EncryptedMediaExtensions.idl:80
Code
Definition: status.h:44
Definition: __init__.py:1
std::string ToString(const T &value)
Definition: angleutils.h:163
static const StatusPod CANCELLED
Definition: status.h:86
static const StatusPod OK
Definition: status.h:85
static const StatusPod UNKNOWN
Definition: status.h:87
#define LIBPROTOBUF_EXPORT
Definition: port.h:97
Definition: gflags_completions.h:115
~Status()
Definition: status.h:82
Definition: status.h:65
Definition: status.h:69