• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 CONFIGURATION_HELPER_H
17 #define CONFIGURATION_HELPER_H
18 
19 #include <cinttypes>
20 #include <string>
21 
22 #include <libxml/parser.h>
23 
24 namespace OHOS {
25 namespace Media {
26 namespace VideoProcessingEngine {
27 class ConfigurationHelper {
28 protected:
29     ConfigurationHelper() = default;
30     virtual ~ConfigurationHelper() = default;
31     ConfigurationHelper(const ConfigurationHelper&) = delete;
32     ConfigurationHelper& operator=(const ConfigurationHelper&) = delete;
33     ConfigurationHelper(ConfigurationHelper&&) = delete;
34     ConfigurationHelper& operator=(ConfigurationHelper&&) = delete;
35 
36     bool LoadConfigurationFromXml(const std::string& xmlFilePath);
37 
38     virtual bool ParseXml(const xmlNode& root);
39 
40     const xmlNode* GetElement(const xmlNode& parent, const std::string& tag) const;
41     const xmlNode* GetElementByName(const xmlNode& parent, const std::string& tag, const std::string& name) const;
42 
43     const std::string GetElementName(const xmlNode& parent, const std::string& tag) const;
44     const std::string GetElementName(const xmlNode& myself) const;
45     const std::string GetElementText(const xmlNode& parent, const std::string& tag) const;
46     const std::string GetElementText(const xmlNode& myself) const;
47     bool GetElementValue(const xmlNode& parent, const std::string& tag, uint32_t& value) const;
48     bool GetElementValue(const xmlNode& parent, const std::string& tag, int& value) const;
49     bool GetElementValue(const xmlNode& parent, const std::string& tag, uint64_t& value) const;
50     bool GetElementValue(const xmlNode& parent, const std::string& tag, bool& value) const;
51     bool GetElementValue(const xmlNode& parent, const std::string& tag, float& value) const;
52     bool GetElementValue(const xmlNode& parent, const std::string& tag, std::string& value) const;
53     bool GetElementValue(const xmlNode& myself, std::string& value) const;
54 };
55 } // namespace VideoProcessingEngine
56 } // namespace Media
57 } // namespace OHOS
58 
59 #endif /* CONFIGURATION_HELPER_H */
60