1 #ifndef SCRAPER_PARSER_H
2 #define SCRAPER_PARSER_H
5 * Copyright (C) 2012-2013 Team XBMC
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, see
20 * <http://www.gnu.org/licenses/>.
25 #include "StdString.h"
26 #include "addons/IAddon.h"
28 #define MAX_SCRAPER_BUFFERS 20
38 class CScraperSettings;
44 CScraperParser(const CScraperParser& parser);
46 CScraperParser& operator= (const CScraperParser& parser);
47 bool Load(const CStdString& strXMLFile);
48 bool IsNoop() { return m_isNoop; };
51 const CStdString GetFilename() { return m_strFile; }
52 CStdString GetSearchStringEncoding() const
53 { return m_SearchStringEncoding; }
54 const CStdString Parse(const CStdString& strTag,
55 ADDON::CScraper* scraper);
57 void AddDocument(const CXBMCTinyXML* doc);
59 CStdString m_param[MAX_SCRAPER_BUFFERS];
63 void ReplaceBuffers(CStdString& strDest);
64 void ParseExpression(const CStdString& input, CStdString& dest, TiXmlElement* element, bool bAppend);
66 /*! \brief Parse an 'XSLT' declaration from the scraper
67 This allow us to transform an inbound XML document using XSLT
68 to a different type of XML document, ready to be output direct
69 to the album loaders or similar
70 \param input the input document
71 \param dest the output destation for the conversion
72 \param element the current XML element
73 \param bAppend append or clear the buffer
75 void ParseXSLT(const CStdString& input, CStdString& dest, TiXmlElement* element, bool bAppend);
76 void ParseNext(TiXmlElement* element);
77 void Clean(CStdString& strDirty);
78 void ConvertJSON(CStdString &string);
80 void GetBufferParams(bool* result, const char* attribute, bool defvalue);
81 void InsertToken(CStdString& strOutput, int buf, const char* token);
83 CXBMCTinyXML* m_document;
84 TiXmlElement* m_pRootElement;
86 const char* m_SearchStringEncoding;
90 ADDON::CScraper* m_scraper;