1 /* 2 * Copyright (c) 2022 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 OHOS_MEMORY_MEMMGR_COMMON_INCLUDE_XML_HELPER_H 17 #define OHOS_MEMORY_MEMMGR_COMMON_INCLUDE_XML_HELPER_H 18 19 #include <map> 20 #include <string> 21 #include <set> 22 #include "libxml/parser.h" 23 #include "libxml/xpath.h" 24 #include "kernel_interface.h" 25 #include "single_instance.h" 26 #include "memmgr_log.h" 27 #include "memmgr_ptr_util.h" 28 29 namespace OHOS { 30 namespace Memory { 31 class XmlHelper { 32 public: 33 static bool CheckNode(const xmlNodePtr &nodePtr); 34 static bool CheckPathExist(const char *path); 35 static bool HasChild(const xmlNodePtr &rootNodePtr); 36 static void SetIntParam(std::map<std::string, std::string> ¶m, 37 std::string key, int &dst, int defaultValue); 38 static void SetUnsignedIntParam(std::map<std::string, std::string> ¶m, 39 std::string key, unsigned int &dst, unsigned int defaultValue); 40 static void SetStringParam(std::map<std::string, std::string> ¶m, 41 std::string key, std::string &dst, std::string defaultValue); 42 static bool GetModuleParam(const xmlNodePtr &rootNodePtr, std::map<std::string, std::string> ¶m); 43 static bool ParseUnsignedLongLongContent(const xmlNodePtr &rootNodePtr, unsigned long long &value); 44 }; 45 } // namespace Memory 46 } // namespace OHOS 47 #endif // OHOS_MEMORY_MEMMGR_COMMON_INCLUDE_XML_HELPER_H 48