VTB: release CVBuffer after it actually has been rendered
[xbmc.git] / xbmc / DbUrl.cpp
blobf48a280aacd52fcbda45e5f4a2708e7219d9628a
1 /*
2 * Copyright (C) 2012-2013 Team XBMC
3 * http://xbmc.org
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.
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.
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/>.
21 #include "DbUrl.h"
22 #include "utils/URIUtils.h"
24 CDbUrl::CDbUrl()
26 Reset();
29 CDbUrl::~CDbUrl()
30 { }
32 void CDbUrl::Reset()
34 m_valid = false;
35 m_type.clear();
36 m_url.Reset();
37 m_options.clear();
40 std::string CDbUrl::ToString() const
42 if (!m_valid)
43 return "";
45 return m_url.Get();
48 bool CDbUrl::FromString(const std::string &dbUrl)
50 Reset();
52 m_url.Parse(dbUrl);
53 m_valid = parse();
55 if (!m_valid)
56 Reset();
58 return m_valid;
61 void CDbUrl::AppendPath(const std::string &subPath)
63 if (!m_valid || subPath.empty())
64 return;
66 m_url.SetFileName(URIUtils::AddFileToFolder(m_url.GetFileName(), subPath));
69 void CDbUrl::AddOption(const std::string &key, const char *value)
71 if (!validateOption(key, value))
72 return;
74 CUrlOptions::AddOption(key, value);
75 updateOptions();
78 void CDbUrl::AddOption(const std::string &key, const std::string &value)
80 if (!validateOption(key, value))
81 return;
83 CUrlOptions::AddOption(key, value);
84 updateOptions();
87 void CDbUrl::AddOption(const std::string &key, int value)
89 if (!validateOption(key, value))
90 return;
92 CUrlOptions::AddOption(key, value);
93 updateOptions();
96 void CDbUrl::AddOption(const std::string &key, float value)
98 if (!validateOption(key, value))
99 return;
101 CUrlOptions::AddOption(key, value);
102 updateOptions();
105 void CDbUrl::AddOption(const std::string &key, double value)
107 if (!validateOption(key, value))
108 return;
110 CUrlOptions::AddOption(key, value);
111 updateOptions();
114 void CDbUrl::AddOption(const std::string &key, bool value)
116 if (!validateOption(key, value))
117 return;
119 CUrlOptions::AddOption(key, value);
120 updateOptions();
123 void CDbUrl::AddOptions(const std::string &options)
125 CUrlOptions::AddOptions(options);
126 updateOptions();
129 void CDbUrl::RemoveOption(const std::string &key)
131 CUrlOptions::RemoveOption(key);
132 updateOptions();
135 bool CDbUrl::validateOption(const std::string &key, const CVariant &value)
137 if (key.empty())
138 return false;
140 return true;
143 void CDbUrl::updateOptions()
145 // Update the options string in the CURL object
146 std::string options = GetOptionsString();
147 if (!options.empty())
148 options = "?" + options;
150 m_url.SetOptions(options);