libmusicbrainz5 5.1.0
Query.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------------
2
3 libmusicbrainz5 - Client library to access MusicBrainz
4
5 Copyright (C) 2012 Andrew Hawkins
6
7 This file is part of libmusicbrainz5.
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 libmusicbrainz5 is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this library. If not, see <http://www.gnu.org/licenses/>.
21
22 $Id$
23
24----------------------------------------------------------------------------*/
25
26#ifndef _MUSICBRAINZ5_QUERY_H
27#define _MUSICBRAINZ5_QUERY_H
28
29#include "defines.h"
30
31#include "Entity.h"
32
35
36#include "musicbrainz5/xmlParser.h"
37
38#include <string>
39#include <map>
40#include <vector>
41
158namespace MusicBrainz5
159{
160 class CQueryPrivate;
161
185 class CQuery
186 {
187 public:
188 typedef std::map<std::string,std::string> tParamMap;
189
196 {
204 };
205
219 CQuery(const std::string& UserAgent, const std::string& Server="musicbrainz.org", int Port=80);
220
222
231 void SetUserName(const std::string& UserName);
232
241 void SetPassword(const std::string& Password);
242
253 void SetProxyHost(const std::string& ProxyHost);
254
265 void SetProxyPort(int ProxyPort);
266
277 void SetProxyUserName(const std::string& ProxyUserName);
278
289 void SetProxyPassword(const std::string& ProxyPassword);
290
301 CReleaseList LookupDiscID(const std::string& DiscID);
302
320 CRelease LookupRelease(const std::string& ReleaseID);
321
358 CMetadata Query(const std::string& Entity,const std::string& ID="",const std::string& Resource="",const tParamMap& Params=tParamMap());
359
378 bool AddCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries);
379
398 bool DeleteCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries);
399
409
417 int LastHTTPCode() const;
418
426 std::string LastErrorMessage() const;
427
435 std::string Version() const;
436
437 private:
438 CQueryPrivate * const m_d;
439
440 CMetadata PerformQuery(const std::string& Query);
441 void WaitRequest() const;
442 std::string UserAgent() const;
443 bool EditCollection(const std::string& CollectionID, const std::vector<std::string>& Entries, const std::string& Action);
444 std::string URIEscape(const std::string& URI);
445 std::string URLEncode(const std::map<std::string,std::string>& Params);
446 };
447}
448
449#endif
Definition: ListImpl.h:35
Definition: Metadata.h:70
Main object for generating queries to MusicBrainz.
Definition: Query.h:186
void SetPassword(const std::string &Password)
Set the password.
CRelease LookupRelease(const std::string &ReleaseID)
Return full information about a release.
std::string LastErrorMessage() const
Return error message from the last query.
std::string Version() const
Return the library version.
int LastHTTPCode() const
Return HTTP code of the last query.
bool AddCollectionEntries(const std::string &CollectionID, const std::vector< std::string > &Entries)
Add entries to the specified collection.
void SetProxyPort(int ProxyPort)
Set proxy server port.
std::map< std::string, std::string > tParamMap
Definition: Query.h:188
void SetProxyUserName(const std::string &ProxyUserName)
Set proxy server user name.
tQueryResult
Enumerated type for query status.
Definition: Query.h:196
@ eQuery_RequestError
Definition: Query.h:202
@ eQuery_AuthenticationError
Definition: Query.h:200
@ eQuery_Timeout
Definition: Query.h:199
@ eQuery_Success
Definition: Query.h:197
@ eQuery_ResourceNotFound
Definition: Query.h:203
@ eQuery_ConnectionError
Definition: Query.h:198
@ eQuery_FetchError
Definition: Query.h:201
void SetProxyHost(const std::string &ProxyHost)
Set proxy server.
bool DeleteCollectionEntries(const std::string &CollectionID, const std::vector< std::string > &Entries)
Delete entries from the specified collection.
CMetadata Query(const std::string &Entity, const std::string &ID="", const std::string &Resource="", const tParamMap &Params=tParamMap())
Perform a generic query.
CReleaseList LookupDiscID(const std::string &DiscID)
Return a list of releases that match a disc ID.
CQuery::tQueryResult LastResult() const
Return result of the last query.
void SetUserName(const std::string &UserName)
Set the user name.
void SetProxyPassword(const std::string &ProxyPassword)
Set proxy server password.
CQuery(const std::string &UserAgent, const std::string &Server="musicbrainz.org", int Port=80)
Constructor for MusicBrainz::CQuery object.
Definition: Release.h:50
Definition: Alias.h:37