/thirdparty/liblastfm2/src/types/FingerprintId.h

http://github.com/tomahawk-player/tomahawk · C Header · 62 lines · 29 code · 10 blank · 23 comment · 3 complexity · 906b15ad9470e08949ccf3279306383c MD5 · raw file

  1. /*
  2. Copyright 2009 Last.fm Ltd.
  3. - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4. This file is part of liblastfm.
  5. liblastfm is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. liblastfm is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef LASTFM_FINGERPRINT_ID_H
  17. #define LASTFM_FINGERPRINT_ID_H
  18. #include <lastfm/Track>
  19. #include <QMap>
  20. namespace lastfm
  21. {
  22. class LASTFM_DLLEXPORT FingerprintId
  23. {
  24. int id;
  25. public:
  26. FingerprintId() : id( -1 )
  27. {}
  28. FingerprintId( uint i ) : id( i )
  29. {}
  30. bool isNull() const { return id == -1; }
  31. /** we query Last.fm for suggested metadata, how awesome is that?
  32. * @returns null if isNull() */
  33. QNetworkReply* getSuggestions() const;
  34. static QMap<float,Track> getSuggestions( QNetworkReply* );
  35. /** -1 if you need to generate it */
  36. operator int() const { return id; }
  37. /** isEmpty() if you need to generate it */
  38. operator QString() const { return id == -1 ? "" : QString::number( id ); }
  39. };
  40. }
  41. inline QDebug operator<<( QDebug d, lastfm::FingerprintId id)
  42. {
  43. if (id.isNull())
  44. return d << "(null)";
  45. else
  46. return d << int(id);
  47. }
  48. #endif