Wyatt Hepler | 421a810 | 2020-01-13 11:30:58 -0800 | [diff] [blame] | 1 | // Copyright 2020 The Pigweed Authors |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 4 | // use this file except in compliance with the License. You may obtain a copy of |
| 5 | // the License at |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 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 |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 12 | // License for the specific language governing permissions and limitations under |
| 13 | // the License. |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 14 | |
| 15 | #include "pw_status/status.h" |
| 16 | |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 17 | #define PW_CASE_RETURN_ENUM_STRING(value) \ |
Wyatt Hepler | 421a810 | 2020-01-13 11:30:58 -0800 | [diff] [blame] | 18 | case PW_STATUS_##value: \ |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 19 | return #value |
| 20 | |
Wyatt Hepler | 421a810 | 2020-01-13 11:30:58 -0800 | [diff] [blame] | 21 | extern "C" const char* pw_StatusString(pw_Status status) { |
Wyatt Hepler | 421a810 | 2020-01-13 11:30:58 -0800 | [diff] [blame] | 22 | switch (status) { |
Alexei Frolov | 1a82c14 | 2019-10-31 17:37:12 -0700 | [diff] [blame] | 23 | PW_CASE_RETURN_ENUM_STRING(OK); |
| 24 | PW_CASE_RETURN_ENUM_STRING(CANCELLED); |
| 25 | PW_CASE_RETURN_ENUM_STRING(UNKNOWN); |
| 26 | PW_CASE_RETURN_ENUM_STRING(INVALID_ARGUMENT); |
| 27 | PW_CASE_RETURN_ENUM_STRING(DEADLINE_EXCEEDED); |
| 28 | PW_CASE_RETURN_ENUM_STRING(NOT_FOUND); |
| 29 | PW_CASE_RETURN_ENUM_STRING(ALREADY_EXISTS); |
| 30 | PW_CASE_RETURN_ENUM_STRING(PERMISSION_DENIED); |
| 31 | PW_CASE_RETURN_ENUM_STRING(RESOURCE_EXHAUSTED); |
| 32 | PW_CASE_RETURN_ENUM_STRING(FAILED_PRECONDITION); |
| 33 | PW_CASE_RETURN_ENUM_STRING(ABORTED); |
| 34 | PW_CASE_RETURN_ENUM_STRING(OUT_OF_RANGE); |
| 35 | PW_CASE_RETURN_ENUM_STRING(UNIMPLEMENTED); |
| 36 | PW_CASE_RETURN_ENUM_STRING(INTERNAL); |
| 37 | PW_CASE_RETURN_ENUM_STRING(UNAVAILABLE); |
| 38 | PW_CASE_RETURN_ENUM_STRING(DATA_LOSS); |
| 39 | PW_CASE_RETURN_ENUM_STRING(UNAUTHENTICATED); |
| 40 | default: |
| 41 | return "INVALID STATUS"; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | #undef PW_CASE_RETURN_ENUM_STRING |