2 * Copyright (C) 2012-2013 Team XBMC
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)
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/>.
24 #include "utils/StringUtils.h"
25 #include "utils/URIUtils.h"
45 std::string CDbUrl::ToString() const
53 bool CDbUrl::FromString(const std::string &dbUrl)
66 void CDbUrl::AppendPath(const std::string &subPath)
68 if (!m_valid || subPath.empty())
71 m_url.SetFileName(URIUtils::AddFileToFolder(m_url.GetFileName(), subPath));
74 void CDbUrl::AddOption(const std::string &key, const char *value)
76 if (!validateOption(key, value))
79 CUrlOptions::AddOption(key, value);
83 void CDbUrl::AddOption(const std::string &key, const std::string &value)
85 if (!validateOption(key, value))
88 CUrlOptions::AddOption(key, value);
92 void CDbUrl::AddOption(const std::string &key, int value)
94 if (!validateOption(key, value))
97 CUrlOptions::AddOption(key, value);
101 void CDbUrl::AddOption(const std::string &key, float value)
103 if (!validateOption(key, value))
106 CUrlOptions::AddOption(key, value);
110 void CDbUrl::AddOption(const std::string &key, double value)
112 if (!validateOption(key, value))
115 CUrlOptions::AddOption(key, value);
119 void CDbUrl::AddOption(const std::string &key, bool value)
121 if (!validateOption(key, value))
124 CUrlOptions::AddOption(key, value);
128 void CDbUrl::AddOptions(const std::string &options)
130 CUrlOptions::AddOptions(options);
134 void CDbUrl::RemoveOption(const std::string &key)
136 CUrlOptions::RemoveOption(key);
140 bool CDbUrl::validateOption(const std::string &key, const CVariant &value)
148 void CDbUrl::updateOptions()
150 // Update the options string in the CURL object
151 string options = GetOptionsString();
152 if (!options.empty())
153 options = "?" + options;
155 m_url.SetOptions(options);