2 * Copyright (C) 2012 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 this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "utils/StringUtils.h"
24 #include "utils/URIUtils.h"
44 std::string CDbUrl::ToString() const
52 bool CDbUrl::FromString(const std::string &dbUrl)
65 void CDbUrl::AppendPath(const std::string &subPath)
67 if (!m_valid || subPath.empty())
70 m_url.SetFileName(URIUtils::AddFileToFolder(m_url.GetFileName(), subPath));
73 void CDbUrl::AddOption(const std::string &key, const char *value)
75 if (!validateOption(key, value))
78 CUrlOptions::AddOption(key, value);
82 void CDbUrl::AddOption(const std::string &key, const std::string &value)
84 if (!validateOption(key, value))
87 CUrlOptions::AddOption(key, value);
91 void CDbUrl::AddOption(const std::string &key, int value)
93 if (!validateOption(key, value))
96 CUrlOptions::AddOption(key, value);
100 void CDbUrl::AddOption(const std::string &key, float value)
102 if (!validateOption(key, value))
105 CUrlOptions::AddOption(key, value);
109 void CDbUrl::AddOption(const std::string &key, double value)
111 if (!validateOption(key, value))
114 CUrlOptions::AddOption(key, value);
118 void CDbUrl::AddOption(const std::string &key, bool value)
120 if (!validateOption(key, value))
123 CUrlOptions::AddOption(key, value);
127 void CDbUrl::AddOptions(const std::string &options)
129 CUrlOptions::AddOptions(options);
133 void CDbUrl::RemoveOption(const std::string &key)
135 CUrlOptions::RemoveOption(key);
139 bool CDbUrl::validateOption(const std::string &key, const CVariant &value)
147 void CDbUrl::updateOptions()
149 // Update the options string in the CURL object
150 string options = GetOptionsString();
151 if (!options.empty())
152 options = "?" + options;
154 m_url.SetOptions(options);