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 XML_PARSE_H 17 #define XML_PARSE_H 18 19 #include <libxml/parser.h> 20 #include <libxml/tree.h> 21 #include <vector> 22 #include <string> 23 #include <unordered_map> 24 #include "avcodec_info.h" 25 26 namespace OHOS { 27 namespace Media { 28 using namespace MediaAVCodec; 29 class __attribute__((visibility("default"))) XmlParser { 30 public: 31 virtual ~XmlParser(); 32 virtual bool LoadConfiguration(const char *xmlPath) final; 33 virtual bool Parse() final; 34 virtual void Destroy() final; 35 36 protected: 37 xmlDoc *mDoc_ = nullptr; 38 virtual bool ParseInternal(xmlNode *node) = 0; 39 virtual bool SetCapabilityIntData(std::unordered_map<std::string, int32_t&> dataMap, 40 const std::string &capabilityKey, const std::string &capabilityValue) const = 0; 41 virtual bool SetCapabilityVectorData(std::unordered_map<std::string, std::vector<int32_t>&> dataMap, 42 const std::string &capabilityKey, const std::string &capabilityValue) const = 0; 43 virtual bool IsNumberArray(const std::vector<std::string> &strArray) const final; 44 virtual bool TransStrAsRange(const std::string &str, Range &range) const final; 45 virtual std::vector<int32_t> TransStrAsIntegerArray(const std::vector<std::string> &spilt) const final; 46 virtual bool SpiltKeyList( 47 const std::string &str, const std::string &delim, std::vector<std::string> &spilt) const final; 48 virtual bool SetCapabilityStringData(std::unordered_map<std::string, std::string&> dataMap, 49 const std::string &capabilityKey, const std::string &capabilityValue) const final; 50 virtual bool SetCapabilityRangeData(std::unordered_map<std::string, Range&> dataMap, 51 const std::string &capabilityKey, const std::string &capabilityValue) const final; 52 }; 53 } // namespace Media 54 } // namespace OHOS 55 56 #endif // XML_PARSE_H