MythTV master
pls.h
Go to the documentation of this file.
1/*
2 playlistfile (.pls) parser
3 Eskil Heyn Olsen, 2005, distributed under the GPL as part of mythtv.
4
5 Update July 2010 updated for Qt4 (Paul Harrison)
6 Update December 2012 updated to use QSettings for the pls parser
7*/
8
9#ifndef PLS_H_
10#define PLS_H_
11
12#include <QString>
13#include <QBuffer>
14#include <QList>
15#include <QTextStream>
16
20{
21 public:
22 PlayListFileEntry(void) = default;
23 ~PlayListFileEntry(void) = default;
24
25 QString File(void) { return m_file; }
26 QString Title(void) { return m_title; }
27 int Length(void) const { return m_length; }
28
29 void setFile(const QString &f) { m_file = f; }
30 void setTitle(const QString &t) { m_title = t; }
31 void setLength(int l) { m_length = l; }
32
33 private:
34 QString m_file;
35 QString m_title;
36 int m_length {0};
37};
38
42{
43 public:
44 PlayListFile(void) = default;
45 ~PlayListFile(void);
46
54 int size(void) const { return m_entries.count(); }
55
61 {
62 if (i >= 0 && i < m_entries.count())
63 return m_entries.at(i);
64
65 return nullptr;
66 }
67
75 int version(void) const { return m_version; }
76
80 void add(PlayListFileEntry *e) { m_entries.append(e); }
81
83 void clear(void)
84 {
85 while (!m_entries.isEmpty())
86 delete m_entries.takeFirst();
87 }
88
94 static int parse(PlayListFile *pls, const QString &filename);
95
101 static int parsePLS(PlayListFile *pls, const QString &filename);
102
108 static int parseM3U(PlayListFile *pls, const QString &filename);
109
115 static int parseASX(PlayListFile *pls, const QString &filename);
116
117 private:
118 QList<PlayListFileEntry*> m_entries;
119 int m_version {0};
120};
121
122#endif /* PLS_H_ */
Class for representing entries in a pls file.
Definition: pls.h:20
void setTitle(const QString &t)
Definition: pls.h:30
QString File(void)
Definition: pls.h:25
QString m_file
Definition: pls.h:34
void setFile(const QString &f)
Definition: pls.h:29
PlayListFileEntry(void)=default
void setLength(int l)
Definition: pls.h:31
int m_length
Definition: pls.h:36
QString m_title
Definition: pls.h:35
~PlayListFileEntry(void)=default
int Length(void) const
Definition: pls.h:27
QString Title(void)
Definition: pls.h:26
Class for containing the info of a pls or m3u file.
Definition: pls.h:42
static int parsePLS(PlayListFile *pls, const QString &filename)
Parse a pls file.
Definition: pls.cpp:49
void add(PlayListFileEntry *e)
Add a entry to the playlist.
Definition: pls.h:80
static int parseASX(PlayListFile *pls, const QString &filename)
Parse a asx file.
Definition: pls.cpp:141
static int parseM3U(PlayListFile *pls, const QString &filename)
Parse a m3u file.
Definition: pls.cpp:103
void clear(void)
Clear out all the entries.
Definition: pls.h:83
QList< PlayListFileEntry * > m_entries
Definition: pls.h:118
static int parse(PlayListFile *pls, const QString &filename)
Parse a pls, m3u or asx playlist file.
Definition: pls.cpp:34
PlayListFile(void)=default
PlayListFileEntry * get(int i)
Get a file entry.
Definition: pls.h:60
int version(void) const
Version of the parsed pls file.
Definition: pls.h:75
int m_version
Definition: pls.h:119
int size(void) const
Get the number of entries in the pls file.
Definition: pls.h:54
~PlayListFile(void)
Definition: pls.cpp:29