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 
34 #include "musicbrainz5/Metadata.h"
35 
36 #include "musicbrainz5/xmlParser.h"
37 
38 #include <string>
39 #include <map>
40 #include <vector>
41 
158 namespace 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 
221  ~CQuery();
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
std::map< std::string, std::string > tParamMap
Definition: Query.h:188
void SetProxyPort(int ProxyPort)
Set proxy server port.
CMetadata Query(const std::string &Entity, const std::string &ID="", const std::string &Resource="", const tParamMap &Params=tParamMap())
Perform a generic query.
std::string LastErrorMessage() const
Return error message from the last query.
Definition: Alias.h:36
void SetUserName(const std::string &UserName)
Set the user name.
int LastHTTPCode() const
Return HTTP code of the last query.
Definition: Metadata.h:69
Main object for generating queries to MusicBrainz.
Definition: Query.h:185
CReleaseList LookupDiscID(const std::string &DiscID)
Return a list of releases that match a disc ID.
void SetProxyHost(const std::string &ProxyHost)
Set proxy server.
void SetProxyUserName(const std::string &ProxyUserName)
Set proxy server user name.
Definition: ListImpl.h:34
bool AddCollectionEntries(const std::string &CollectionID, const std::vector< std::string > &Entries)
Add entries to the specified collection.
std::string Version() const
Return the library version.
tQueryResult
Enumerated type for query status.
Definition: Query.h:195
CQuery::tQueryResult LastResult() const
Return result of the last query.
void SetProxyPassword(const std::string &ProxyPassword)
Set proxy server password.
Definition: Release.h:49
bool DeleteCollectionEntries(const std::string &CollectionID, const std::vector< std::string > &Entries)
Delete entries from the specified collection.
CQuery(const std::string &UserAgent, const std::string &Server="musicbrainz.org", int Port=80)
Constructor for MusicBrainz::CQuery object.
CRelease LookupRelease(const std::string &ReleaseID)
Return full information about a release.
void SetPassword(const std::string &Password)
Set the password.