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