ScummVM API documentation
wagparser.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program 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  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AGI_WAGPARSER_H
23 #define AGI_WAGPARSER_H
24 
25 namespace Agi {
26 
37 class WagProperty {
38 // Constants, enumerations etc
39 public:
44  PC_GAMEDESC = 129,
54  PC_INVOBJDESC = 144,
55  PC_VOCABWORDDESC = 160,
56  PC_PALETTE = 172,
57  PC_USERESNAMES = 180,
58  PC_LOGIC = 192,
59  PC_PICTURE = 208,
60  PC_SOUND = 224,
61  PC_VIEW = 240,
62  PC_UNDEFINED = 0x100
63  };
64 
70  PT_ID,
71  PT_DESC,
72  PT_SYNTAX,
73  PT_CRC32,
74  PT_KEY,
75  PT_INST0,
76  PT_INST1,
77  PT_INST2,
78  PT_MUTE0,
79  PT_MUTE1,
80  PT_MUTE2,
81  PT_MUTE3,
82  PT_TPQN,
83  PT_ROOM,
84  PT_VIS0,
85  PT_VIS1,
86  PT_VIS2,
87  PT_VIS3,
88  PT_ALL = 0xff,
89  PT_UNDEFINED = 0x100
90  };
91 
92 // Constructors, destructors, operators etc
93 public:
98  WagProperty();
99 
103  ~WagProperty();
104 
108  WagProperty(const WagProperty &other);
109 
113  WagProperty &operator=(const WagProperty &other);
114 
115 // Non-public helper methods
116 protected:
120  void setDefaults();
121 
125  void deleteData();
126 
131  void deepCopy(const WagProperty &other);
132 
133 // Public methods that have side-effects
134 public:
139  bool read(Common::SeekableReadStream &stream);
140 
145  void clear();
146 
147 // Public access functions
148 public:
152  bool readOk() const { return _readOk; }
153 
158  enum WagPropertyCode getCode() const { return _propCode; }
159 
164  enum WagPropertyType getType() const { return _propType; }
165 
170  byte getNumber() const { return _propNum; }
171 
176  uint16 getSize() const { return _propSize; }
177 
183  const char *getData() const { return _propData; }
184 
189  void setPropCode(WagPropertyCode propCode);
190 
196 
197 // Member variables
198 protected:
199  bool _readOk;
202  byte _propNum;
203  uint16 _propSize;
204  char *_propData;
205 };
206 
207 
213 // Constants, type definitions, enumerations etc.
214 public:
215  enum {
216  WINAGI_VERSION_LENGTH = 16
217  };
219 
220 public:
224  WagFileParser();
225 
229  ~WagFileParser();
230 
238  void addPropFromIni(Common::INIFile &iniWagFile, Common::String section, Common::String key, Agi::WagProperty::WagPropertyCode code);
239 
246  bool parse(const Common::FSNode &node);
247 
253  const PropertyList &getProperties() const { return _propList; }
254 
265  const WagProperty *getProperty(const WagProperty::WagPropertyCode code) const;
266 
274  bool checkAgiVersionProperty(const WagProperty &version) const;
275 
281  uint16 convertToAgiVersionNumber(const WagProperty &version);
282 
287  bool parsedOk() const { return _parsedOk; }
288 
289 protected:
295  bool checkWagVersion(Common::SeekableReadStream &stream);
296 
302  bool endOfProperties(const Common::SeekableReadStream &stream) const;
303 
304 // Member variables
305 protected:
306  PropertyList _propList;
307  bool _parsedOk;
308 };
309 
310 } // End of namespace Agi
311 
312 #endif // AGI_WAGPARSER_H
void setPropCode(WagPropertyCode propCode)
Game description (WinAGI 1.1.21 limits these to 4096 bytes)
Definition: wagparser.h:44
Definition: str.h:59
bool _readOk
Was the property read ok from the source stream?
Definition: wagparser.h:199
Game executable.
Definition: wagparser.h:51
void deepCopy(const WagProperty &other)
const PropertyList & getProperties() const
Definition: wagparser.h:253
WagPropertyType
Definition: wagparser.h:69
uint16 _propSize
Property&#39;s size (Part of the property&#39;s header)
Definition: wagparser.h:203
PropertyList _propList
List of loaded properties from the file.
Definition: wagparser.h:306
Last edit date.
Definition: wagparser.h:48
byte _propNum
Property number (Part of the property&#39;s header)
Definition: wagparser.h:202
Definition: stream.h:745
Definition: wagparser.h:37
bool parsedOk() const
Definition: wagparser.h:287
Common::Array< WagProperty > PropertyList
A type definition for an array of *.wag file properties.
Definition: wagparser.h:218
An undefined property code (Added for ScummVM).
Definition: wagparser.h:62
Default syntax.
Definition: wagparser.h:53
char * _propData
The property&#39;s data (Plus a trailing zero for C-style string access)
Definition: wagparser.h:204
Game ID.
Definition: wagparser.h:46
bool readOk() const
Definition: wagparser.h:152
enum WagPropertyType getType() const
Definition: wagparser.h:164
Definition: fs.h:69
WagProperty & operator=(const WagProperty &other)
byte getNumber() const
Definition: wagparser.h:170
WagPropertyCode
Definition: wagparser.h:43
bool read(Common::SeekableReadStream &stream)
enum WagPropertyCode _propCode
Property code (Part of the property&#39;s header)
Definition: wagparser.h:200
void setPropDataSize(Common::String str)
Resource directory name.
Definition: wagparser.h:52
About game (WinAGI 1.1.21 limits these to 4096 bytes)
Definition: wagparser.h:50
Game version (WinAGI 1.1.21 limits these to 256 bytes)
Definition: wagparser.h:49
An undefined property type (Added for ScummVM).
Definition: wagparser.h:89
Definition: ini-file.h:58
const char * getData() const
Definition: wagparser.h:183
uint16 getSize() const
Definition: wagparser.h:176
Game author (WinAGI 1.1.21 limits these to 256 bytes)
Definition: wagparser.h:45
Interpreter version (WinAGI 1.1.21 defaults to version 2.917)
Definition: wagparser.h:47
Definition: agi.h:64
enum WagPropertyType _propType
Property type (Part of the property&#39;s header)
Definition: wagparser.h:201
bool _parsedOk
Did the parsing of the file go ok?
Definition: wagparser.h:307
Definition: wagparser.h:212
enum WagPropertyCode getCode() const
Definition: wagparser.h:158