status_util.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H
20 #define GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H
21 
23 
24 #include <grpc/status.h>
25 
28 bool grpc_status_code_from_string(const char* status_str,
30 
33 
34 // Converts an int to grpc_status_code. If the int is not a valid status code,
35 // sets the code to GRPC_STATUS_UNKNOWN and returns false. Otherwise, returns
36 // true.
38 
39 namespace grpc_core {
40 namespace internal {
41 
44  public:
45  bool Empty() const { return status_code_mask_ == 0; }
46 
48 
50  return status_code_mask_ & (1 << status);
51  }
52 
53  bool operator==(const StatusCodeSet& other) const {
54  return status_code_mask_ == other.status_code_mask_;
55  }
56 
57  private:
58  int status_code_mask_ = 0; // A bitfield of status codes in the set.
59 };
60 
61 } // namespace internal
62 } // namespace grpc_core
63 
64 #endif /* GRPC_CORE_LIB_CHANNEL_STATUS_UTIL_H */
grpc_core::internal::StatusCodeSet::Add
void Add(grpc_status_code status)
Definition: status_util.h:47
grpc_status_code_from_int
bool grpc_status_code_from_int(int status_int, grpc_status_code *status)
Definition: status_util.cc:103
grpc_core
Definition: call_metric_recorder.h:31
grpc_status_code
grpc_status_code
Definition: include/grpc/impl/codegen/status.h:28
status
absl::Status status
Definition: rls.cc:251
status.h
grpc_core::internal::StatusCodeSet::Contains
bool Contains(grpc_status_code status) const
Definition: status_util.h:49
grpc_core::internal::StatusCodeSet
A set of grpc_status_code values.
Definition: status_util.h:43
grpc_core::internal::StatusCodeSet::Empty
bool Empty() const
Definition: status_util.h:45
grpc_core::internal::StatusCodeSet::operator==
bool operator==(const StatusCodeSet &other) const
Definition: status_util.h:53
grpc_status_code_to_string
const char * grpc_status_code_to_string(grpc_status_code status)
Returns the string form of status, or "UNKNOWN" if invalid.
Definition: status_util.cc:62
grpc_status_code_from_string
bool grpc_status_code_from_string(const char *status_str, grpc_status_code *status)
Definition: status_util.cc:51
internal
Definition: benchmark/test/output_test_helper.cc:20
grpc_core::internal::StatusCodeSet::status_code_mask_
int status_code_mask_
Definition: status_util.h:58
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:22