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_ */
PlayListFile::m_entries
QList< PlayListFileEntry * > m_entries
Definition: pls.h:118
PlayListFile::get
PlayListFileEntry * get(int i)
Get a file entry.
Definition: pls.h:60
PlayListFileEntry::File
QString File(void)
Definition: pls.h:25
PlayListFileEntry::setTitle
void setTitle(const QString &t)
Definition: pls.h:30
PlayListFileEntry::m_file
QString m_file
Definition: pls.h:34
PlayListFileEntry
Class for representing entries in a pls file.
Definition: pls.h:19
PlayListFileEntry::m_title
QString m_title
Definition: pls.h:35
PlayListFile::parse
static int parse(PlayListFile *pls, const QString &filename)
Parse a pls, m3u or asx playlist file.
Definition: pls.cpp:34
hardwareprofile.i18n.t
t
Definition: i18n.py:36
PlayListFileEntry::PlayListFileEntry
PlayListFileEntry(void)=default
PlayListFileEntry::setFile
void setFile(const QString &f)
Definition: pls.h:29
PlayListFileEntry::Length
int Length(void) const
Definition: pls.h:27
PlayListFile::m_version
int m_version
Definition: pls.h:119
PlayListFile::~PlayListFile
~PlayListFile(void)
Definition: pls.cpp:29
PlayListFile
Class for containing the info of a pls or m3u file.
Definition: pls.h:41
PlayListFileEntry::Title
QString Title(void)
Definition: pls.h:26
PlayListFile::size
int size(void) const
Get the number of entries in the pls file.
Definition: pls.h:54
PlayListFile::clear
void clear(void)
Clear out all the entries.
Definition: pls.h:83
PlayListFile::PlayListFile
PlayListFile(void)=default
PlayListFile::parseM3U
static int parseM3U(PlayListFile *pls, const QString &filename)
Parse a m3u file.
Definition: pls.cpp:103
PlayListFileEntry::setLength
void setLength(int l)
Definition: pls.h:31
PlayListFile::parseASX
static int parseASX(PlayListFile *pls, const QString &filename)
Parse a asx file.
Definition: pls.cpp:140
PlayListFileEntry::~PlayListFileEntry
~PlayListFileEntry(void)=default
PlayListFile::add
void add(PlayListFileEntry *e)
Add a entry to the playlist.
Definition: pls.h:80
PlayListFile::parsePLS
static int parsePLS(PlayListFile *pls, const QString &filename)
Parse a pls file.
Definition: pls.cpp:49
build_compdb.filename
filename
Definition: build_compdb.py:21
PlayListFile::version
int version(void) const
Version of the parsed pls file.
Definition: pls.h:75
PlayListFileEntry::m_length
int m_length
Definition: pls.h:36