• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://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,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "dfx_option.h"
17 
18 namespace panda::os::dfx_option {
19 
20 /* static */
IsInOptionList(const std::string & s)21 bool DfxOptionHandler::IsInOptionList(const std::string &s)
22 {
23 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
24 #define D(e, v, str) \
25     if (s == str) {  \
26         return true; \
27     }
28     DFX_OPTION_LIST(D)
29 #undef D
30     return false;
31 }
32 
33 /* static */
DfxOptionFromString(const std::string & s)34 DfxOptionHandler::DfxOption DfxOptionHandler::DfxOptionFromString(const std::string &s)
35 {
36 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
37 #define D(e, v, str)                           \
38     if (s == str) {                            \
39         return DfxOptionHandler::DfxOption::e; \
40     }
41     DFX_OPTION_LIST(D)
42 #undef D
43     UNREACHABLE();
44 }
45 
46 /* static */
StringFromDfxOption(DfxOptionHandler::DfxOption dfx_option)47 std::string DfxOptionHandler::StringFromDfxOption(DfxOptionHandler::DfxOption dfx_option)
48 {
49 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
50 #define D(e, v, str)                                    \
51     if (dfx_option == DfxOptionHandler::DfxOption::e) { \
52         return str;                                     \
53     }
54     DFX_OPTION_LIST(D)
55 #undef D
56     UNREACHABLE();
57 }
58 
59 }  // namespace panda::os::dfx_option
60