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 namespace Agi {
23 
34 class WagProperty {
35 // Constants, enumerations etc
36 public:
41  PC_GAMEDESC = 129,
51  PC_INVOBJDESC = 144,
52  PC_VOCABWORDDESC = 160,
53  PC_PALETTE = 172,
54  PC_USERESNAMES = 180,
55  PC_LOGIC = 192,
56  PC_PICTURE = 208,
57  PC_SOUND = 224,
58  PC_VIEW = 240,
59  PC_UNDEFINED = 0x100
60  };
61 
67  PT_ID,
68  PT_DESC,
69  PT_SYNTAX,
70  PT_CRC32,
71  PT_KEY,
72  PT_INST0,
73  PT_INST1,
74  PT_INST2,
75  PT_MUTE0,
76  PT_MUTE1,
77  PT_MUTE2,
78  PT_MUTE3,
79  PT_TPQN,
80  PT_ROOM,
81  PT_VIS0,
82  PT_VIS1,
83  PT_VIS2,
84  PT_VIS3,
85  PT_ALL = 0xff,
86  PT_UNDEFINED = 0x100
87  };
88 
89 // Constructors, destructors, operators etc
90 public:
95  WagProperty();
96 
100  ~WagProperty();
101 
105  WagProperty(const WagProperty &other);
106 
110  WagProperty &operator=(const WagProperty &other);
111 
112 // Non-public helper methods
113 protected:
117  void setDefaults();
118 
122  void deleteData();
123 
128  void deepCopy(const WagProperty &other);
129 
130 // Public methods that have side-effects
131 public:
136  bool read(Common::SeekableReadStream &stream);
137 
142  void clear();
143 
144 // Public access functions
145 public:
149  bool readOk() const { return _readOk; }
150 
155  enum WagPropertyCode getCode() const { return _propCode; }
156 
161  enum WagPropertyType getType() const { return _propType; }
162 
167  byte getNumber() const { return _propNum; }
168 
173  uint16 getSize() const { return _propSize; }
174 
180  const char *getData() const { return _propData; }
181 
186  void setPropCode(WagPropertyCode propCode);
187 
193 
194 // Member variables
195 protected:
196  bool _readOk;
199  byte _propNum;
200  uint16 _propSize;
201  char *_propData;
202 };
203 
204 
210 // Constants, type definitions, enumerations etc.
211 public:
212  enum {
213  WINAGI_VERSION_LENGTH = 16
214  };
216 
217 public:
221  WagFileParser();
222 
226  ~WagFileParser();
227 
235  void addPropFromIni(Common::INIFile &iniWagFile, Common::String section, Common::String key, Agi::WagProperty::WagPropertyCode code);
236 
243  bool parse(const Common::FSNode &node);
244 
250  const PropertyList &getProperties() const { return _propList; }
251 
262  const WagProperty *getProperty(const WagProperty::WagPropertyCode code) const;
263 
271  bool checkAgiVersionProperty(const WagProperty &version) const;
272 
278  uint16 convertToAgiVersionNumber(const WagProperty &version);
279 
284  bool parsedOk() const { return _parsedOk; }
285 
286 protected:
292  bool checkWagVersion(Common::SeekableReadStream &stream);
293 
299  bool endOfProperties(const Common::SeekableReadStream &stream) const;
300 
301 // Member variables
302 protected:
303  PropertyList _propList;
304  bool _parsedOk;
305 };
306 
307 } // End of namespace Agi
void setPropCode(WagPropertyCode propCode)
Game description (WinAGI 1.1.21 limits these to 4096 bytes)
Definition: wagparser.h:41
Definition: str.h:59
bool _readOk
Was the property read ok from the source stream?
Definition: wagparser.h:196
Game executable.
Definition: wagparser.h:48
void deepCopy(const WagProperty &other)
const PropertyList & getProperties() const
Definition: wagparser.h:250
WagPropertyType
Definition: wagparser.h:66
uint16 _propSize
Property&#39;s size (Part of the property&#39;s header)
Definition: wagparser.h:200
PropertyList _propList
List of loaded properties from the file.
Definition: wagparser.h:303
Last edit date.
Definition: wagparser.h:45
byte _propNum
Property number (Part of the property&#39;s header)
Definition: wagparser.h:199
Definition: stream.h:745
Definition: wagparser.h:34
bool parsedOk() const
Definition: wagparser.h:284
Common::Array< WagProperty > PropertyList
A type definition for an array of *.wag file properties.
Definition: wagparser.h:215
An undefined property code (Added for ScummVM).
Definition: wagparser.h:59
Default syntax.
Definition: wagparser.h:50
char * _propData
The property&#39;s data (Plus a trailing zero for C-style string access)
Definition: wagparser.h:201
Game ID.
Definition: wagparser.h:43
bool readOk() const
Definition: wagparser.h:149
enum WagPropertyType getType() const
Definition: wagparser.h:161
Definition: fs.h:69
WagProperty & operator=(const WagProperty &other)
byte getNumber() const
Definition: wagparser.h:167
WagPropertyCode
Definition: wagparser.h:40
bool read(Common::SeekableReadStream &stream)
enum WagPropertyCode _propCode
Property code (Part of the property&#39;s header)
Definition: wagparser.h:197
void setPropDataSize(Common::String str)
Resource directory name.
Definition: wagparser.h:49
About game (WinAGI 1.1.21 limits these to 4096 bytes)
Definition: wagparser.h:47
Game version (WinAGI 1.1.21 limits these to 256 bytes)
Definition: wagparser.h:46
An undefined property type (Added for ScummVM).
Definition: wagparser.h:86
Definition: ini-file.h:58
const char * getData() const
Definition: wagparser.h:180
uint16 getSize() const
Definition: wagparser.h:173
Game author (WinAGI 1.1.21 limits these to 256 bytes)
Definition: wagparser.h:42
Interpreter version (WinAGI 1.1.21 defaults to version 2.917)
Definition: wagparser.h:44
Definition: agi.h:63
enum WagPropertyType _propType
Property type (Part of the property&#39;s header)
Definition: wagparser.h:198
bool _parsedOk
Did the parsing of the file go ok?
Definition: wagparser.h:304
Definition: wagparser.h:209
enum WagPropertyCode getCode() const
Definition: wagparser.h:155