[win32] cmake: make use of ADDONS_TO_BUILD in make-addons.bat
[vuplus_xbmc] / xbmc / NfoFile.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20 // NfoFile.h: interface for the CNfoFile class.
21 //
22 //////////////////////////////////////////////////////////////////////
23
24 #if !defined(AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_)
25 #define AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_
26
27 #pragma once
28
29 #include "utils/XBMCTinyXML.h"
30 #include "addons/Scraper.h"
31 #include "utils/CharsetConverter.h"
32 #include "utils/XMLUtils.h"
33 #include "utils/StdString.h"
34
35 class CNfoFile
36 {
37 public:
38   CNfoFile() : m_headPos(0), m_type(ADDON::ADDON_UNKNOWN) {}
39   virtual ~CNfoFile() { Close(); }
40
41   enum NFOResult
42   {
43     NO_NFO       = 0,
44     FULL_NFO     = 1,
45     URL_NFO      = 2,
46     COMBINED_NFO = 3,
47     ERROR_NFO    = 4
48   };
49
50   NFOResult Create(const CStdString&, const ADDON::ScraperPtr&, int episode=-1);
51   template<class T>
52     bool GetDetails(T& details,const char* document=NULL, bool prioritise=false)
53   {
54     CXBMCTinyXML doc;
55     if (document)
56       doc.Parse(document, TIXML_ENCODING_UNKNOWN);
57     else
58       doc.Parse(m_doc.substr(m_headPos), TIXML_ENCODING_UNKNOWN);
59
60     return details.Load(doc.RootElement(), true, prioritise);
61   }
62
63   void Close();
64   void SetScraperInfo(const ADDON::ScraperPtr& info) { m_info = info; }
65   const ADDON::ScraperPtr& GetScraperInfo() const { return m_info; }
66   const CScraperUrl &ScraperUrl() const { return m_scurl; }
67
68 private:
69   std::string m_doc;
70   size_t m_headPos;
71   ADDON::ScraperPtr m_info;
72   ADDON::TYPE m_type;
73   CScraperUrl m_scurl;
74
75   int Load(const CStdString&);
76   int Scrape(ADDON::ScraperPtr& scraper);
77 };
78
79 #endif // !defined(AFX_NfoFile_H__641CCF68_6D2A_426E_9204_C0E4BEF12D00__INCLUDED_)