modreader.h
1 //------------------------------------------------------------------------------
2 // modreader.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2019 Pol Marcet Sardà <polmarcetsarda@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __MODREADER_H_
24 #define __MODREADER_H_
25 
26 #include "dptr.h"
27 
28 #include <QSharedPointer>
29 #include <QString>
30 
39 {
40  QString name;
41  int position;
42  int size;
43 };
44 
45 class ModReader
46 {
47 public:
48  virtual ~ModReader() {}
49  virtual bool load() = 0;
50  virtual QStringList getAllMaps() = 0;
51  virtual bool isIwad() = 0;
52  static QSharedPointer<ModReader> create(const QString &path);
53 };
54 
58 class WadReader : public ModReader
59 {
60 public:
66  WadReader(const QString &path);
67  ~WadReader() override;
73  bool load() override;
77  bool isIwad() override;
81  QList<DirectoryEntry> getDirectory();
87  QStringList getAllMaps() override;
88 
89 private:
93  QStringList getClassicMaps(const QStringList &names);
97  QStringList getUdmfMaps(const QStringList &names);
98 
99 private:
100  DPtr<WadReader> d;
101 };
102 
108 {
109 public:
115  CompressedReader(const QString &path);
116  ~CompressedReader() override;
122  bool load() override;
126  bool isIwad() override
127  {
128  return false;
129  }
135  QStringList getAllMaps() override;
136 protected:
137  QStringList getAllMapsRootDir();
139 };
140 
145 {
146 public:
147  PkReader(const QString &path);
153  QStringList getAllMaps() override;
154 };
155 
156 #endif
File reader for PK3/7 format.
Definition: modreader.h:144
File reader for the WAD format.
Definition: modreader.h:58
bool isIwad() override
returns whether or not this is a IWAD. It will always be false.
Definition: modreader.h:126
Contains an entry of a WAD directory.
Definition: modreader.h:38
File reader for generic compression file formats. Current formats: ZIP, 7Z.
Definition: modreader.h:107