PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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