Merge pull request #26166 from ksooo/improve-plugin-ctx-menus
[xbmc.git] / xbmc / utils / ScraperParser.h
blobec1cfd2b3412974e055a99fccbca778609506a47
1 /*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include <string>
12 #include <vector>
14 #define MAX_SCRAPER_BUFFERS 20
16 namespace ADDON
18 class CScraper;
21 class TiXmlElement;
22 class CXBMCTinyXML;
24 class CScraperSettings;
26 class CScraperParser
28 public:
29 CScraperParser();
30 CScraperParser(const CScraperParser& parser);
31 ~CScraperParser();
32 CScraperParser& operator= (const CScraperParser& parser);
33 bool Load(const std::string& strXMLFile);
34 bool IsNoop() const { return m_isNoop; }
36 void Clear();
37 const std::string& GetFilename() const { return m_strFile; }
38 std::string GetSearchStringEncoding() const
39 { return m_SearchStringEncoding; }
40 const std::string Parse(const std::string& strTag,
41 ADDON::CScraper* scraper);
43 void AddDocument(const CXBMCTinyXML* doc);
45 std::string m_param[MAX_SCRAPER_BUFFERS];
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);
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
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);
69 CXBMCTinyXML* m_document;
70 TiXmlElement* m_pRootElement;
72 const char* m_SearchStringEncoding;
73 bool m_isNoop;
75 std::string m_strFile;
76 ADDON::CScraper* m_scraper;