libmusicbrainz4
4.0.3
|
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$ 00022 00023 ----------------------------------------------------------------------------*/ 00024 00025 #ifndef _MUSICBRAINZ4_QUERY_H 00026 #define _MUSICBRAINZ4_QUERY_H 00027 00028 #include "defines.h" 00029 00030 #include "Entity.h" 00031 00032 #include "musicbrainz4/ReleaseList.h" 00033 #include "musicbrainz4/Metadata.h" 00034 00035 #include "musicbrainz4/xmlParser.h" 00036 00037 #include <string> 00038 #include <map> 00039 #include <vector> 00040 00157 namespace MusicBrainz4 00158 { 00159 class CQueryPrivate; 00160 00184 class CQuery 00185 { 00186 public: 00187 typedef std::map<std::string,std::string> tParamMap; 00188 00194 enum tQueryResult 00195 { 00196 eQuery_Success=0, 00197 eQuery_ConnectionError, 00198 eQuery_Timeout, 00199 eQuery_AuthenticationError, 00200 eQuery_FetchError, 00201 eQuery_RequestError, 00202 eQuery_ResourceNotFound 00203 }; 00204 00218 CQuery(const std::string& UserAgent, const std::string& Server="musicbrainz.org", int Port=80); 00219 00220 ~CQuery(); 00221 00230 void SetUserName(const std::string& UserName); 00231 00240 void SetPassword(const std::string& Password); 00241 00252 void SetProxyHost(const std::string& ProxyHost); 00253 00264 void SetProxyPort(int ProxyPort); 00265 00276 void SetProxyUserName(const std::string& ProxyUserName); 00277 00288 void SetProxyPassword(const std::string& ProxyPassword); 00289 00300 CReleaseList LookupDiscID(const std::string& DiscID); 00301 00319 CRelease LookupRelease(const std::string& ReleaseID); 00320 00357 CMetadata Query(const std::string& Entity,const std::string& ID="",const std::string& Resource="",const tParamMap& Params=tParamMap()); 00358 00377 bool AddCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries); 00378 00397 bool DeleteCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries); 00398 00407 CQuery::tQueryResult LastResult() const; 00408 00416 int LastHTTPCode() const; 00417 00425 std::string LastErrorMessage() const; 00426 00434 std::string Version() const; 00435 00436 private: 00437 CQueryPrivate * const m_d; 00438 00439 CMetadata PerformQuery(const std::string& Query); 00440 void WaitRequest() const; 00441 std::string UserAgent() const; 00442 bool EditCollection(const std::string& CollectionID, const std::vector<std::string>& Entries, const std::string& Action); 00443 std::string URIEscape(const std::string& URI); 00444 std::string URLEncode(const std::map<std::string,std::string>& Params); 00445 }; 00446 } 00447 00448 #endif