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