1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
/*
* Cantata
*
* Copyright (c) 2011-2022 Craig Drummond <craig.p.drummond@gmail.com>
*
*/
/*
* Copyright (c) 2008 Sander Knopper (sander AT knopper DOT tk) and
* Roeland Douma (roeland AT rullzer DOT com)
*
* This file is part of QtMPC.
*
* QtMPC is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* QtMPC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QtMPC. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MPD_PARSE_UTILS_H
#define MPD_PARSE_UTILS_H
#include "config.h"
#include "song.h"
#include <QSet>
#include <QString>
struct Playlist;
struct Partition;
struct Output;
struct MPDStatsValues;
struct MPDStatusValues;
namespace MPDParseUtils {
extern void enableDebug();
struct IdPos {
IdPos(qint32 i, quint32 p)
: id(i), pos(p)
{
}
qint32 id;
quint32 pos;
};
enum Location {
Loc_Library,
Loc_Playlists,
Loc_PlayQueue,
Loc_Streams,
Loc_Search,
Loc_Browse
};
enum CueSupport {
Cue_Parse,
Cue_ListButDontParse,
Cue_Ignore,
Cue_Count
};
struct Sticker {
QByteArray file;
QByteArray value;
};
extern QString toStr(CueSupport cs);
extern CueSupport toCueSupport(const QString& cs);
extern void setCueFileSupport(CueSupport cs);
extern CueSupport cueFileSupport();
extern void setSingleTracksFolders(const QSet<QString>& folders);
extern QList<Playlist> parsePlaylists(const QByteArray& data);
extern MPDStatsValues parseStats(const QByteArray& data);
extern MPDStatusValues parseStatus(const QByteArray& data);
extern Song parseSong(const QList<QByteArray>& lines, Location location);
inline Song parseSong(const QByteArray& data, Location location) { return parseSong(data.split('\n'), location); }
extern QList<Song> parseSongs(const QByteArray& data, Location location);
extern QList<IdPos> parseChanges(const QByteArray& data);
extern QStringList parseList(const QByteArray& data, const QByteArray& key);
typedef QMap<QByteArray, QStringList> MessageMap;
extern MessageMap parseMessages(const QByteArray& data);
extern void parseDirItems(const QByteArray& data, const QString& mpdDir, long mpdVersion, QList<Song>& songList, const QString& dir, QStringList& subDirs, Location loc);
extern QList<Partition> parsePartitions(const QByteArray& data);
extern QList<Output> parseOuputs(const QByteArray& data);
extern QByteArray parseSticker(const QByteArray& data, const QByteArray& sticker);
extern QList<Sticker> parseStickers(const QByteArray& data, const QByteArray& sticker);
// Single hash when saving streams to [Radio Streams] - for compatability
extern QString addStreamName(const QString& url, const QString& name, bool singleHash = false);
extern QString getStreamName(const QString& url);
// checkSingleHash - check for #<Name> as well as #StreamName:<Name>
extern QString getAndRemoveStreamName(QString& url, bool checkSingleHash = false);
}// namespace MPDParseUtils
#endif
|