libmusicbrainz5  5.0.1
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 v2 of the GNU Lesser General Public
11  License as published by the Free Software Foundation.
12 
13  libmusicbrainz5 is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this library. If not, see <http://www.gnu.org/licenses/>.
20 
21  $Id$
22 
23 ----------------------------------------------------------------------------*/
24 
25 #ifndef _MUSICBRAINZ5_QUERY_H
26 #define _MUSICBRAINZ5_QUERY_H
27 
28 #include "defines.h"
29 
30 #include "Entity.h"
31 
33 #include "musicbrainz5/Metadata.h"
34 
35 #include "musicbrainz5/xmlParser.h"
36 
37 #include <string>
38 #include <map>
39 #include <vector>
40 
157 namespace MusicBrainz5
158 {
159  class CQueryPrivate;
160 
184  class CQuery
185  {
186  public:
187  typedef std::map<std::string,std::string> tParamMap;
188 
195  {
203  };
204 
218  CQuery(const std::string& UserAgent, const std::string& Server="musicbrainz.org", int Port=80);
219 
220  ~CQuery();
221 
230  void SetUserName(const std::string& UserName);
231 
240  void SetPassword(const std::string& Password);
241 
252  void SetProxyHost(const std::string& ProxyHost);
253 
264  void SetProxyPort(int ProxyPort);
265 
276  void SetProxyUserName(const std::string& ProxyUserName);
277 
288  void SetProxyPassword(const std::string& ProxyPassword);
289 
300  CReleaseList LookupDiscID(const std::string& DiscID);
301 
319  CRelease LookupRelease(const std::string& ReleaseID);
320 
357  CMetadata Query(const std::string& Entity,const std::string& ID="",const std::string& Resource="",const tParamMap& Params=tParamMap());
358 
377  bool AddCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries);
378 
397  bool DeleteCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries);
398 
408 
416  int LastHTTPCode() const;
417 
425  std::string LastErrorMessage() const;
426 
434  std::string Version() const;
435 
436  private:
437  CQueryPrivate * const m_d;
438 
439  CMetadata PerformQuery(const std::string& Query);
440  void WaitRequest() const;
441  std::string UserAgent() const;
442  bool EditCollection(const std::string& CollectionID, const std::vector<std::string>& Entries, const std::string& Action);
443  std::string URIEscape(const std::string& URI);
444  std::string URLEncode(const std::map<std::string,std::string>& Params);
445  };
446 }
447 
448 #endif
std::map< std::string, std::string > tParamMap
Definition: Query.h:187
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.
Definition: Alias.h:35
CQuery::tQueryResult LastResult() const
Return result of the last query.
void SetUserName(const std::string &UserName)
Set the user name.
Definition: Metadata.h:68
Main object for generating queries to MusicBrainz.
Definition: Query.h:184
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:33
bool AddCollectionEntries(const std::string &CollectionID, const std::vector< std::string > &Entries)
Add entries to the specified collection.
tQueryResult
Enumerated type for query status.
Definition: Query.h:194
std::string LastErrorMessage() const
Return error message from the last query.
void SetProxyPassword(const std::string &ProxyPassword)
Set proxy server password.
std::string Version() const
Return the library version.
Definition: Release.h:48
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.
int LastHTTPCode() const
Return HTTP code of the last query.