[XAudio2] avoid leak + fix voice creation for closest match
[xbmc.git] / xbmc / NfoFile.h
blob9b97f2a3ab4ce158edb46f181d8a4a3ce309e0a7
1 /*
2 * Copyright (C) 2005-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 // NfoFile.h: interface for the CNfoFile class.
13 //////////////////////////////////////////////////////////////////////
15 #include "InfoScanner.h"
16 #include "addons/Scraper.h"
17 #include "utils/XBMCTinyXML.h"
19 #include <string>
20 #include <utility>
21 #include <vector>
23 namespace ADDON
25 enum class AddonType;
28 class CNfoFile
30 public:
31 virtual ~CNfoFile() { Close(); }
33 CInfoScanner::INFO_TYPE Create(const std::string&,
34 const ADDON::ScraperPtr&, int episode=-1);
35 template<class T>
36 bool GetDetails(T& details, const char* document=NULL,
37 bool prioritise=false)
39 CXBMCTinyXML doc;
40 if (document)
41 doc.Parse(document, TIXML_ENCODING_UNKNOWN);
42 else if (m_headPos < m_doc.size())
43 doc.Parse(m_doc.substr(m_headPos), TIXML_ENCODING_UNKNOWN);
44 else
45 return false;
47 return details.Load(doc.RootElement(), true, prioritise);
50 void Close();
51 void SetScraperInfo(ADDON::ScraperPtr info) { m_info = std::move(info); }
52 ADDON::ScraperPtr GetScraperInfo() { return m_info; }
53 const CScraperUrl &ScraperUrl() const { return m_scurl; }
55 static int Scrape(ADDON::ScraperPtr& scraper, CScraperUrl& url,
56 const std::string& content);
58 static std::vector<ADDON::ScraperPtr> GetScrapers(ADDON::AddonType type,
59 const ADDON::ScraperPtr& selectedScraper);
61 private:
62 std::string m_doc;
63 size_t m_headPos = 0;
64 ADDON::ScraperPtr m_info;
65 ADDON::AddonType m_type{};
66 CScraperUrl m_scurl;
68 int Load(const std::string&);