1 /** 2 * Copyright (c) 2021-2024 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 #ifndef PANDA_VERIF_CONFIG_H_ 17 #define PANDA_VERIF_CONFIG_H_ 18 19 #include "libpandabase/utils/logger.h" 20 21 #include "runtime/include/mem/panda_string.h" 22 23 #include <vector> 24 #include <string> 25 #include <cstring> 26 #include <stdexcept> 27 28 namespace ark::verifier::config { 29 struct Section { 30 // NOLINTBEGIN(misc-non-private-member-variables-in-classes) 31 PandaString name; 32 std::vector<struct Section> sections; 33 std::vector<PandaString> items; 34 // NOLINTEND(misc-non-private-member-variables-in-classes) Imageark::verifier::config::Section35 PandaString Image(size_t align = 0) const 36 { 37 PandaString spaces(align, ' '); 38 PandaString result = spaces + name + " {\n"; 39 for (const auto &s : sections) { 40 result += s.Image(align + 2UL); 41 } 42 for (const auto &i : items) { 43 result += spaces; 44 result += " "; 45 result += i; 46 result += "\n"; 47 } 48 result += spaces + "}\n"; 49 return result; 50 } operator []ark::verifier::config::Section51 const Section &operator[](const PandaString &title) const 52 { 53 for (const auto &s : sections) { 54 if (s.name == title) { 55 return s; 56 } 57 } 58 LOG(FATAL, VERIFIER) << "config section '" << title << "' not found"; 59 UNREACHABLE(); 60 } 61 }; 62 } // namespace ark::verifier::config 63 64 #endif // PANDA_VERIF_CONFIG_H_ 65