1049e185fSopenharmony_ci/*
2049e185fSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3049e185fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4049e185fSopenharmony_ci * you may not use this file except in compliance with the License.
5049e185fSopenharmony_ci * You may obtain a copy of the License at
6049e185fSopenharmony_ci *
7049e185fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8049e185fSopenharmony_ci *
9049e185fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10049e185fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11049e185fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12049e185fSopenharmony_ci * See the License for the specific language governing permissions and
13049e185fSopenharmony_ci * limitations under the License.
14049e185fSopenharmony_ci */
15049e185fSopenharmony_ci
16049e185fSopenharmony_ci#ifndef XML_PARSE_H
17049e185fSopenharmony_ci#define XML_PARSE_H
18049e185fSopenharmony_ci
19049e185fSopenharmony_ci#include <libxml/parser.h>
20049e185fSopenharmony_ci#include <libxml/tree.h>
21049e185fSopenharmony_ci#include <vector>
22049e185fSopenharmony_ci#include <string>
23049e185fSopenharmony_ci#include <unordered_map>
24049e185fSopenharmony_ci#include "avcodec_info.h"
25049e185fSopenharmony_ci
26049e185fSopenharmony_cinamespace OHOS {
27049e185fSopenharmony_cinamespace Media {
28049e185fSopenharmony_ciusing namespace MediaAVCodec;
29049e185fSopenharmony_ciclass __attribute__((visibility("default"))) XmlParser {
30049e185fSopenharmony_cipublic:
31049e185fSopenharmony_ci    virtual ~XmlParser();
32049e185fSopenharmony_ci    virtual bool LoadConfiguration(const char *xmlPath) final;
33049e185fSopenharmony_ci    virtual bool Parse() final;
34049e185fSopenharmony_ci    virtual void Destroy() final;
35049e185fSopenharmony_ci
36049e185fSopenharmony_ciprotected:
37049e185fSopenharmony_ci    xmlDoc *mDoc_ = nullptr;
38049e185fSopenharmony_ci    virtual bool ParseInternal(xmlNode *node) = 0;
39049e185fSopenharmony_ci    virtual bool SetCapabilityIntData(std::unordered_map<std::string, int32_t&> dataMap,
40049e185fSopenharmony_ci        const std::string &capabilityKey, const std::string &capabilityValue) const = 0;
41049e185fSopenharmony_ci    virtual bool SetCapabilityVectorData(std::unordered_map<std::string, std::vector<int32_t>&> dataMap,
42049e185fSopenharmony_ci        const std::string &capabilityKey, const std::string &capabilityValue) const = 0;
43049e185fSopenharmony_ci    virtual bool IsNumberArray(const std::vector<std::string> &strArray) const final;
44049e185fSopenharmony_ci    virtual bool TransStrAsRange(const std::string &str, Range &range) const final;
45049e185fSopenharmony_ci    virtual std::vector<int32_t> TransStrAsIntegerArray(const std::vector<std::string> &spilt) const final;
46049e185fSopenharmony_ci    virtual bool SpiltKeyList(
47049e185fSopenharmony_ci        const std::string &str, const std::string &delim, std::vector<std::string> &spilt) const final;
48049e185fSopenharmony_ci    virtual bool SetCapabilityStringData(std::unordered_map<std::string, std::string&> dataMap,
49049e185fSopenharmony_ci        const std::string &capabilityKey, const std::string &capabilityValue) const final;
50049e185fSopenharmony_ci    virtual bool SetCapabilityRangeData(std::unordered_map<std::string, Range&> dataMap,
51049e185fSopenharmony_ci        const std::string &capabilityKey, const std::string &capabilityValue) const final;
52049e185fSopenharmony_ci};
53049e185fSopenharmony_ci}  //  namespace Media
54049e185fSopenharmony_ci}  //  namespace OHOS
55049e185fSopenharmony_ci
56049e185fSopenharmony_ci#endif  //  XML_PARSE_H