/proc/self/cwd/pw_status/status.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2020 The Pigweed Authors |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
4 | | // use this file except in compliance with the License. You may obtain a copy of |
5 | | // the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
11 | | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
12 | | // License for the specific language governing permissions and limitations under |
13 | | // the License. |
14 | | |
15 | | #include "pw_status/status.h" |
16 | | |
17 | | #define PW_CASE_RETURN_ENUM_STRING(value) \ |
18 | 0 | case PW_STATUS_##value: \ |
19 | 0 | return #value |
20 | | |
21 | 0 | extern "C" const char* pw_StatusString(pw_Status status) { |
22 | 0 | switch (status) { |
23 | 0 | PW_CASE_RETURN_ENUM_STRING(OK); |
24 | 0 | PW_CASE_RETURN_ENUM_STRING(CANCELLED); |
25 | 0 | PW_CASE_RETURN_ENUM_STRING(UNKNOWN); |
26 | 0 | PW_CASE_RETURN_ENUM_STRING(INVALID_ARGUMENT); |
27 | 0 | PW_CASE_RETURN_ENUM_STRING(DEADLINE_EXCEEDED); |
28 | 0 | PW_CASE_RETURN_ENUM_STRING(NOT_FOUND); |
29 | 0 | PW_CASE_RETURN_ENUM_STRING(ALREADY_EXISTS); |
30 | 0 | PW_CASE_RETURN_ENUM_STRING(PERMISSION_DENIED); |
31 | 0 | PW_CASE_RETURN_ENUM_STRING(RESOURCE_EXHAUSTED); |
32 | 0 | PW_CASE_RETURN_ENUM_STRING(FAILED_PRECONDITION); |
33 | 0 | PW_CASE_RETURN_ENUM_STRING(ABORTED); |
34 | 0 | PW_CASE_RETURN_ENUM_STRING(OUT_OF_RANGE); |
35 | 0 | PW_CASE_RETURN_ENUM_STRING(UNIMPLEMENTED); |
36 | 0 | PW_CASE_RETURN_ENUM_STRING(INTERNAL); |
37 | 0 | PW_CASE_RETURN_ENUM_STRING(UNAVAILABLE); |
38 | 0 | PW_CASE_RETURN_ENUM_STRING(DATA_LOSS); |
39 | 0 | PW_CASE_RETURN_ENUM_STRING(UNAUTHENTICATED); |
40 | 0 | case PW_STATUS_DO_NOT_USE_RESERVED_FOR_FUTURE_EXPANSION_USE_DEFAULT_IN_SWITCH_INSTEAD_: |
41 | 0 | default: |
42 | 0 | return "INVALID STATUS"; |
43 | 0 | } |
44 | 0 | } |
45 | | |
46 | | #undef PW_CASE_RETURN_ENUM_STRING |