1 /* 2 * Copyright (c) 2023 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_ROSEN_WINDOW_SCENE_CONFIG_H 17 #define OHOS_ROSEN_WINDOW_SCENE_CONFIG_H 18 19 #include <refbase.h> 20 21 #include "xml_config_base.h" 22 #include "libxml/parser.h" 23 #include "libxml/tree.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class WindowSceneConfig : public RefBase, public XmlConfigBase { 28 public: 29 WindowSceneConfig() = delete; 30 ~WindowSceneConfig() = default; 31 32 static bool LoadConfigXml(); GetConfig()33 static const ConfigItem& GetConfig() 34 { 35 return config_; 36 } 37 static void DumpConfig(const std::map<std::string, ConfigItem>& config); 38 39 private: 40 static ConfigItem config_; 41 static const std::map<std::string, ValueType> configItemTypeMap_; 42 43 static bool IsValidNode(const xmlNode& currNode); 44 static std::map<std::string, ConfigItem> ReadProperty(const xmlNodePtr& currNode); 45 static std::vector<int> ReadIntNumbersConfigInfo(const xmlNodePtr& currNode); 46 static std::vector<std::string> ReadStringsConfigInfo(const xmlNodePtr& currNode); 47 static std::vector<float> ReadFloatNumbersConfigInfo(const xmlNodePtr& currNode, bool allowNeg); 48 static std::string ReadStringConfigInfo(const xmlNodePtr& currNode); 49 static void ReadConfig(const xmlNodePtr& rootPtr, std::map<std::string, ConfigItem>& mapValue); 50 static std::string GetConfigPath(const std::string& configFileName); 51 static std::vector<std::string> SplitNodeContent(const xmlNodePtr& node, const std::string& pattern = " "); 52 }; 53 54 } // namespace Rosen 55 } // namespace OHOS 56 #endif // OHOS_ROSEN_WINDOW_SCENE_CONFIG_H 57