1 /* 2 * Copyright (C) 2012-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include <string> 12 #include <vector> 13 14 #define MAX_SCRAPER_BUFFERS 20 15 16 namespace ADDON 17 { 18 class CScraper; 19 } 20 21 class TiXmlElement; 22 class CXBMCTinyXML; 23 24 class CScraperSettings; 25 26 class CScraperParser 27 { 28 public: 29 CScraperParser(); 30 CScraperParser(const CScraperParser& parser); 31 ~CScraperParser(); 32 CScraperParser& operator= (const CScraperParser& parser); 33 bool Load(const std::string& strXMLFile); IsNoop()34 bool IsNoop() const { return m_isNoop; }; 35 36 void Clear(); GetFilename()37 const std::string& GetFilename() const { return m_strFile; } GetSearchStringEncoding()38 std::string GetSearchStringEncoding() const 39 { return m_SearchStringEncoding; } 40 const std::string Parse(const std::string& strTag, 41 ADDON::CScraper* scraper); 42 43 void AddDocument(const CXBMCTinyXML* doc); 44 45 std::string m_param[MAX_SCRAPER_BUFFERS]; 46 47 private: 48 bool LoadFromXML(); 49 void ReplaceBuffers(std::string& strDest); 50 void ParseExpression(const std::string& input, std::string& dest, TiXmlElement* element, bool bAppend); 51 52 /*! \brief Parse an 'XSLT' declaration from the scraper 53 This allow us to transform an inbound XML document using XSLT 54 to a different type of XML document, ready to be output direct 55 to the album loaders or similar 56 \param input the input document 57 \param dest the output destination for the conversion 58 \param element the current XML element 59 \param bAppend append or clear the buffer 60 */ 61 void ParseXSLT(const std::string& input, std::string& dest, TiXmlElement* element, bool bAppend); 62 void ParseNext(TiXmlElement* element); 63 void Clean(std::string& strDirty); 64 void ConvertJSON(std::string &string); 65 void ClearBuffers(); 66 void GetBufferParams(bool* result, const char* attribute, bool defvalue); 67 void InsertToken(std::string& strOutput, int buf, const char* token); 68 69 CXBMCTinyXML* m_document; 70 TiXmlElement* m_pRootElement; 71 72 const char* m_SearchStringEncoding; 73 bool m_isNoop; 74 75 std::string m_strFile; 76 ADDON::CScraper* m_scraper; 77 }; 78 79