1 /* 2 * Copyright (C) 2021 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 /** 17 * @addtogroup Bluetooth 18 * @{ 19 * 20 * @brief Defines map client xml object. 21 * 22 */ 23 24 /** 25 * @file map_mce_xml.h 26 * 27 * @brief map client xml header file . 28 * 29 */ 30 31 #ifndef MAP_MCE_XML_H 32 #define MAP_MCE_XML_H 33 34 #include <string> 35 #include "libxml/parser.h" 36 37 namespace OHOS { 38 namespace bluetooth { 39 class MceXmlAttribute { 40 public: 41 MceXmlAttribute(); 42 void SetAttribute(const std::string &value); 43 std::string AsString() const; 44 int AsInt(); 45 46 private: 47 std::string value_ {}; 48 }; 49 class MceXmlNode { 50 public: 51 MceXmlNode(); 52 void SetNode(xmlNode node); 53 MceXmlAttribute Attribute(std::string name) const; 54 bool Empty() const; 55 std::string Name() const; 56 MceXmlNode FirstChild() const; 57 MceXmlNode NextSibling() const; 58 59 private: 60 bool empty_ = true; 61 xmlNode node_ {}; 62 }; 63 class MceXmlDoc { 64 public: 65 ~MceXmlDoc(); 66 void LoadString(std::string content); 67 MceXmlNode Child(std::string name) const; 68 69 private: 70 xmlDocPtr pDoc_ = nullptr; 71 }; 72 } // namespace bluetooth 73 } // namespace OHOS 74 #endif // MAP_MCE_XML_H 75