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 #ifndef AUDIO_XML_NODE_H 16 #define AUDIO_XML_NODE_H 17 18 #include <memory> 19 #include <mutex> 20 21 namespace OHOS { 22 namespace AudioStandard { 23 24 struct XmlFuncHandle; 25 26 class DlopenUtils { 27 public: 28 static bool Init(); 29 static void DeInit(); 30 static std::shared_ptr<XmlFuncHandle> GetHandle(); 31 private: 32 static std::atomic<int32_t> refCount_; 33 static std::shared_ptr<XmlFuncHandle> xmlFuncHandle_; 34 static std::mutex dlMutex_; 35 }; 36 37 class AudioXmlNode { 38 public: 39 static std::shared_ptr<AudioXmlNode> Create(); 40 41 AudioXmlNode() = default; 42 virtual ~AudioXmlNode() = default; 43 44 virtual std::shared_ptr<AudioXmlNode> GetChildrenNode() = 0; 45 virtual std::shared_ptr<AudioXmlNode> GetCopyNode() = 0; 46 virtual int32_t Config(const char *fileName, const char *encoding, int32_t options) = 0; 47 virtual void MoveToNext() = 0; 48 virtual void MoveToChildren() = 0; 49 50 virtual bool IsNodeValid() = 0; 51 virtual bool HasProp(const char *propName) = 0; 52 virtual int32_t GetProp(const char *propName, std::string &result) = 0; 53 virtual int32_t GetContent(std::string &result) = 0; 54 virtual std::string GetName() = 0; 55 virtual bool CompareName(const char *propName) = 0; 56 virtual bool IsElementNode() = 0; 57 58 virtual void FreeDoc() = 0; 59 virtual void FreeProp(char *propName) = 0; 60 }; 61 } // namespace AudioStandard 62 } // namespace OHOS 63 #endif // AUDIO_XML_NODE_H