libmusicbrainz4
4.0.0
|
00001 /* -------------------------------------------------------------------------- 00002 00003 libmusicbrainz4 - Client library to access MusicBrainz 00004 00005 Copyright (C) 2011 Andrew Hawkins 00006 00007 This file is part of libmusicbrainz4. 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of v2 of the GNU Lesser General Public 00011 License as published by the Free Software Foundation. 00012 00013 libmusicbrainz4 is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this library. If not, see <http://www.gnu.org/licenses/>. 00020 00021 $Id: Query.h 13266 2011-08-25 12:56:47Z adhawkins $ 00022 00023 ----------------------------------------------------------------------------*/ 00024 00025 #ifndef _MUSICBRAINZ4_QUERY_H 00026 #define _MUSICBRAINZ4_QUERY_H 00027 00028 #include "musicbrainz4/ReleaseList.h" 00029 #include "musicbrainz4/Metadata.h" 00030 00031 #include "musicbrainz4/xmlParser.h" 00032 00033 #include <string> 00034 #include <map> 00035 #include <vector> 00036 00136 namespace MusicBrainz4 00137 { 00138 class CQueryPrivate; 00139 00163 class CQuery 00164 { 00165 public: 00166 typedef std::map<std::string,std::string> tParamMap; 00167 00173 enum tQueryResult 00174 { 00175 eQuery_Success=0, 00176 eQuery_ConnectionError, 00177 eQuery_Timeout, 00178 eQuery_AuthenticationError, 00179 eQuery_FetchError, 00180 eQuery_RequestError, 00181 eQuery_ResourceNotFound 00182 }; 00183 00197 CQuery(const std::string& UserAgent, const std::string& Server="musicbrainz.org", int Port=80); 00198 00199 ~CQuery(); 00200 00209 void SetUserName(const std::string& UserName); 00210 00219 void SetPassword(const std::string& Password); 00220 00231 void SetProxyHost(const std::string& ProxyHost); 00232 00243 void SetProxyPort(int ProxyPort); 00244 00255 void SetProxyUserName(const std::string& ProxyUserName); 00256 00267 void SetProxyPassword(const std::string& ProxyPassword); 00268 00279 CReleaseList LookupDiscID(const std::string& DiscID); 00280 00298 CRelease LookupRelease(const std::string& ReleaseID); 00299 00336 CMetadata Query(const std::string& Entity,const std::string& ID="",const std::string& Resource="",const tParamMap& Params=tParamMap()); 00337 00356 bool AddCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries); 00357 00376 bool DeleteCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries); 00377 00386 CQuery::tQueryResult LastResult() const; 00387 00395 int LastHTTPCode() const; 00396 00404 std::string LastErrorMessage() const; 00405 00413 std::string Version() const; 00414 00415 private: 00416 CQueryPrivate * const m_d; 00417 00418 CMetadata PerformQuery(const std::string& Query); 00419 void WaitRequest() const; 00420 std::string UserAgent() const; 00421 bool EditCollection(const std::string& CollectionID, const std::vector<std::string>& Entries, const std::string& Action); 00422 std::string URIEscape(const std::string& URI); 00423 std::string URLEncode(const std::map<std::string,std::string>& Params); 00424 }; 00425 } 00426 00427 #endif