2008-06-18 23:49:47 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XML_PARSER_H
|
|
|
|
#define XML_PARSER_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/xmlparser.h"
|
2008-06-25 11:34:58 +00:00
|
|
|
#include "common/stream.h"
|
2008-06-25 14:19:56 +00:00
|
|
|
#include "common/file.h"
|
2008-08-16 14:06:26 +00:00
|
|
|
#include "common/fs.h"
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
#include "common/hashmap.h"
|
|
|
|
#include "common/hash-str.h"
|
|
|
|
#include "common/stack.h"
|
|
|
|
|
|
|
|
namespace Common {
|
2008-07-30 13:33:32 +00:00
|
|
|
|
2008-09-05 14:48:47 +00:00
|
|
|
/*
|
|
|
|
XMLParser.cpp/h -- Generic XML Parser
|
|
|
|
=====================================
|
2008-07-30 13:33:32 +00:00
|
|
|
|
2008-09-05 14:48:47 +00:00
|
|
|
External documentation available at:
|
|
|
|
http://www.smartlikearoboc.com/scummvm_doc/xmlparser_doc.html
|
2008-07-30 13:33:32 +00:00
|
|
|
*/
|
2008-10-05 10:19:09 +00:00
|
|
|
|
|
|
|
#define MAX_XML_DEPTH 8
|
2008-08-09 14:15:34 +00:00
|
|
|
|
2008-07-30 13:33:32 +00:00
|
|
|
#define XML_KEY(keyName) {\
|
2008-10-12 22:05:26 +00:00
|
|
|
lay = new CustomXMLKeyLayout;\
|
2008-08-09 14:15:34 +00:00
|
|
|
lay->callback = (&kLocalParserName::parserCallback_##keyName);\
|
|
|
|
layout.top()->children[#keyName] = lay;\
|
2008-08-08 18:30:16 +00:00
|
|
|
layout.push(lay); \
|
2008-08-09 14:15:34 +00:00
|
|
|
_layoutList.push_back(lay);\
|
2008-08-08 18:30:16 +00:00
|
|
|
for (Common::List<XMLKeyLayout::XMLKeyProperty>::const_iterator p = globalProps.begin(); p != globalProps.end(); ++p){\
|
|
|
|
layout.top()->properties.push_back(*p);}
|
2008-08-04 16:59:55 +00:00
|
|
|
|
|
|
|
#define XML_KEY_RECURSIVE(keyName) {\
|
|
|
|
layout.top()->children[#keyName] = layout.top();\
|
|
|
|
layout.push(layout.top());\
|
|
|
|
}
|
2008-07-30 13:33:32 +00:00
|
|
|
|
|
|
|
#define KEY_END() layout.pop(); }
|
|
|
|
|
|
|
|
#define XML_PROP(propName, req) {\
|
|
|
|
prop.name = #propName; \
|
|
|
|
prop.required = req; \
|
2008-08-08 18:30:16 +00:00
|
|
|
layout.top()->properties.push_back(prop); }
|
|
|
|
|
|
|
|
#define XML_GLOBAL_PROP(propName, req) {\
|
|
|
|
prop.name = #propName; \
|
|
|
|
prop.required = req;\
|
|
|
|
globalProps.push_back(prop); }
|
2008-08-01 10:18:47 +00:00
|
|
|
|
2008-07-30 13:33:32 +00:00
|
|
|
|
|
|
|
#define CUSTOM_XML_PARSER(parserName) \
|
|
|
|
protected: \
|
|
|
|
typedef parserName kLocalParserName; \
|
2008-08-09 14:15:34 +00:00
|
|
|
bool keyCallback(ParserNode *node) {return node->layout->doCallback(this, node); }\
|
|
|
|
struct CustomXMLKeyLayout : public XMLKeyLayout {\
|
|
|
|
typedef bool (parserName::*ParserCallback)(ParserNode *node);\
|
|
|
|
ParserCallback callback;\
|
|
|
|
bool doCallback(XMLParser *parent, ParserNode *node) {return ((kLocalParserName*)parent->*callback)(node);} };\
|
2008-07-30 13:33:32 +00:00
|
|
|
virtual void buildLayout() { \
|
|
|
|
Common::Stack<XMLKeyLayout*> layout; \
|
2008-08-09 14:15:34 +00:00
|
|
|
CustomXMLKeyLayout *lay = 0; \
|
2008-07-30 13:33:32 +00:00
|
|
|
XMLKeyLayout::XMLKeyProperty prop; \
|
2008-08-08 18:30:16 +00:00
|
|
|
Common::List<XMLKeyLayout::XMLKeyProperty> globalProps; \
|
2008-08-09 14:15:34 +00:00
|
|
|
_XMLkeys = new CustomXMLKeyLayout; \
|
2008-07-30 13:33:32 +00:00
|
|
|
layout.push(_XMLkeys);
|
|
|
|
|
|
|
|
#define PARSER_END() layout.clear(); }
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The base XMLParser class implements generic functionality for parsing
|
|
|
|
* XML-like files.
|
|
|
|
*
|
|
|
|
* In order to use it, it must be inherited with a child class that implements
|
|
|
|
* the XMLParser::keyCallback() function.
|
|
|
|
*
|
|
|
|
* @see XMLParser::keyCallback()
|
|
|
|
*/
|
|
|
|
class XMLParser {
|
2008-10-14 19:00:21 +00:00
|
|
|
static const int kErrorMessageWidth = 512;
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Parser constructor.
|
|
|
|
*/
|
2008-09-05 14:48:47 +00:00
|
|
|
XMLParser() : _XMLkeys(0), _stream(0) {}
|
2008-06-18 23:49:47 +00:00
|
|
|
|
2008-06-25 14:19:56 +00:00
|
|
|
virtual ~XMLParser() {
|
|
|
|
while (!_activeKey.empty())
|
2008-10-05 10:19:09 +00:00
|
|
|
freeNode(_activeKey.pop());
|
2008-08-09 14:15:34 +00:00
|
|
|
|
2008-07-30 14:08:07 +00:00
|
|
|
delete _XMLkeys;
|
2008-09-05 14:48:47 +00:00
|
|
|
delete _stream;
|
2008-08-09 14:15:34 +00:00
|
|
|
|
|
|
|
for (Common::List<XMLKeyLayout*>::iterator i = _layoutList.begin();
|
|
|
|
i != _layoutList.end(); ++i)
|
|
|
|
delete *i;
|
|
|
|
|
|
|
|
_layoutList.clear();
|
2008-06-25 14:19:56 +00:00
|
|
|
}
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
/** Active state for the parser */
|
|
|
|
enum ParserState {
|
|
|
|
kParserNeedKey,
|
|
|
|
kParserNeedKeyName,
|
|
|
|
|
|
|
|
kParserNeedPropertyName,
|
|
|
|
kParserNeedPropertyOperator,
|
|
|
|
kParserNeedPropertyValue,
|
|
|
|
|
|
|
|
kParserError
|
|
|
|
};
|
2008-07-30 13:33:32 +00:00
|
|
|
|
|
|
|
struct XMLKeyLayout;
|
2008-08-09 14:15:34 +00:00
|
|
|
struct ParserNode;
|
2008-07-30 13:33:32 +00:00
|
|
|
|
|
|
|
typedef Common::HashMap<Common::String, XMLParser::XMLKeyLayout*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ChildMap;
|
|
|
|
|
|
|
|
/** nested struct representing the layout of the XML file */
|
|
|
|
struct XMLKeyLayout {
|
|
|
|
struct XMLKeyProperty {
|
|
|
|
Common::String name;
|
|
|
|
bool required;
|
|
|
|
};
|
|
|
|
|
|
|
|
Common::List<XMLKeyProperty> properties;
|
|
|
|
ChildMap children;
|
2008-07-30 14:08:07 +00:00
|
|
|
|
2008-08-09 14:15:34 +00:00
|
|
|
virtual bool doCallback(XMLParser *parent, ParserNode *node) = 0;
|
|
|
|
|
|
|
|
virtual ~XMLKeyLayout() {
|
2008-07-30 14:08:07 +00:00
|
|
|
properties.clear();
|
|
|
|
}
|
2008-07-30 13:33:32 +00:00
|
|
|
} *_XMLkeys;
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
/** Struct representing a parsed node */
|
|
|
|
struct ParserNode {
|
|
|
|
Common::String name;
|
|
|
|
Common::StringMap values;
|
2008-06-24 19:48:01 +00:00
|
|
|
bool ignore;
|
2008-06-25 17:56:00 +00:00
|
|
|
int depth;
|
2008-07-30 13:33:32 +00:00
|
|
|
XMLKeyLayout *layout;
|
2008-06-18 23:49:47 +00:00
|
|
|
};
|
2008-10-05 10:19:09 +00:00
|
|
|
|
2008-10-12 22:05:26 +00:00
|
|
|
ObjectPool<ParserNode, MAX_XML_DEPTH> _nodePool;
|
2008-10-05 10:19:09 +00:00
|
|
|
|
|
|
|
ParserNode *allocNode() {
|
2008-10-12 22:05:26 +00:00
|
|
|
return new (_nodePool) ParserNode;
|
2008-10-05 10:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void freeNode(ParserNode *node) {
|
2008-10-12 22:05:26 +00:00
|
|
|
_nodePool.deleteChunk(node);
|
2008-10-05 10:19:09 +00:00
|
|
|
}
|
2008-06-18 23:49:47 +00:00
|
|
|
|
2008-06-26 13:50:16 +00:00
|
|
|
/**
|
|
|
|
* Loads a file into the parser.
|
|
|
|
* Used for the loading of Theme Description files
|
|
|
|
* straight from the filesystem.
|
|
|
|
*
|
|
|
|
* @param filename Name of the file to load.
|
|
|
|
*/
|
2008-08-16 14:06:26 +00:00
|
|
|
bool loadFile(const Common::String &filename) {
|
2008-10-11 22:11:02 +00:00
|
|
|
_stream = SearchMan.openFile(filename);
|
|
|
|
if (!_stream)
|
2008-06-25 14:19:56 +00:00
|
|
|
return false;
|
|
|
|
|
2008-06-26 13:50:16 +00:00
|
|
|
_fileName = filename;
|
2008-06-25 14:19:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-08-16 14:06:26 +00:00
|
|
|
|
Merged several revisions from SVNMerge.
Fixed theme loading to use the new ArchiveMember class.
Original SVNMerge.py log:
=====================
Merged revisions 34686,34688-34689,34691-34698,34700-34705,34707-34713,34715-34722,34725-34727,34731-34732,34734-34738,34746 via svnmerge from
https://tanoku@scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk
........
r34686 | cyx | 2008-09-29 21:09:56 +0200 (Mon, 29 Sep 2008) | 1 line
add constructor to SearchSet::Node for proper init of structure members with gcc 3.4.x (see tracker items #2120595, #2106292)
........
r34688 | cyx | 2008-09-29 22:08:26 +0200 (Mon, 29 Sep 2008) | 1 line
restrict _heXmapNum to HE versions, should fix #2135822
........
r34689 | eriktorbjorn | 2008-09-29 22:40:58 +0200 (Mon, 29 Sep 2008) | 4 lines
Since no one has come up with any better suggestion... this should fix #2123258
("COMI: Crash after video (SAN) play"). The eos() function won't return true
until we've tried to read *past* the end of the stream.
........
r34691 | tanoku | 2008-09-30 00:29:07 +0200 (Tue, 30 Sep 2008) | 1 line
Ported ZipArchive::getAllNames() implementation from GUI branch.
........
r34692 | fingolfin | 2008-09-30 11:07:03 +0200 (Tue, 30 Sep 2008) | 1 line
Order alphabetically
........
r34693 | fingolfin | 2008-09-30 11:08:17 +0200 (Tue, 30 Sep 2008) | 1 line
SAGA: Removed patchesCount from SAGAGameDescription
........
r34694 | fingolfin | 2008-09-30 11:09:39 +0200 (Tue, 30 Sep 2008) | 1 line
SCUMM HE: Use FilesystemNode::openForReading() instead of 'new Common::File' (didn't cover all instances, though)
........
r34695 | fingolfin | 2008-09-30 11:11:25 +0200 (Tue, 30 Sep 2008) | 1 line
SAGA: Forgot to commit saga.h
........
r34696 | fingolfin | 2008-09-30 11:12:02 +0200 (Tue, 30 Sep 2008) | 1 line
Added multiple new open() methods to Common::File, which make it possible to use this class as a generic convenience wrapper around all kinds of SeekableReadStream; also renamed the name() method to the less confusing getName()
........
r34697 | fingolfin | 2008-09-30 13:33:43 +0200 (Tue, 30 Sep 2008) | 1 line
cleanup
........
r34698 | tanoku | 2008-09-30 13:53:37 +0200 (Tue, 30 Sep 2008) | 1 line
Fixed functionality of ZipArchive::getAllNames(). Now it expects a possibly non-empty string list and returns the amount of new filenames added to it.
........
r34700 | fingolfin | 2008-09-30 14:27:38 +0200 (Tue, 30 Sep 2008) | 1 line
Renamed Engine::quit to Engine::shouldQuit (previously, it was easily confused with Engine::quitGame); also cleaned up engine.h a bit
........
r34701 | fingolfin | 2008-09-30 14:37:28 +0200 (Tue, 30 Sep 2008) | 1 line
cleanup
........
r34702 | fingolfin | 2008-09-30 14:38:44 +0200 (Tue, 30 Sep 2008) | 1 line
AdvancedDetector: Do not (ab)use paths to keep track of files, rather, use FSNodes -- partial (?) fix for bug #2137680
........
r34703 | fingolfin | 2008-09-30 14:58:27 +0200 (Tue, 30 Sep 2008) | 1 line
SAGA: Some code cleanup
........
r34704 | fingolfin | 2008-09-30 14:59:29 +0200 (Tue, 30 Sep 2008) | 1 line
SKY: Fix detector to not (ab)use FSNode::getPath; if you want to open a FSNode, just pass it to File::open
........
r34705 | thebluegr | 2008-09-30 15:19:14 +0200 (Tue, 30 Sep 2008) | 1 line
Fixed crash when starting IHNM, a regression from commit #34693
........
r34707 | fingolfin | 2008-09-30 17:42:19 +0200 (Tue, 30 Sep 2008) | 1 line
Fixing ConfigManager::loadConfigFile
........
r34708 | fingolfin | 2008-09-30 18:23:35 +0200 (Tue, 30 Sep 2008) | 1 line
AGI: Another case where it is better to use FSNodes directly, instead of converting them to path strings
........
r34709 | fingolfin | 2008-09-30 18:34:38 +0200 (Tue, 30 Sep 2008) | 1 line
Modified FilePluginProvider to use FSNodes (instead of raw filenames / paths) in its API
........
r34710 | fingolfin | 2008-09-30 18:38:46 +0200 (Tue, 30 Sep 2008) | 1 line
AGI: Got rid of yet another unwarranted use of FSNode::getPath
........
r34711 | fingolfin | 2008-09-30 18:53:04 +0200 (Tue, 30 Sep 2008) | 1 line
AGI: Simplify WagFileParser by not reading data into a memory stream first (this was there to improve performance on systems with slow seeking; those systems should use another approach, see scummvm-devel)
........
r34712 | thebluegr | 2008-09-30 18:55:10 +0200 (Tue, 30 Sep 2008) | 1 line
Fix crash when starting ITE, a regression from commit #34705
........
r34713 | fingolfin | 2008-09-30 19:09:41 +0200 (Tue, 30 Sep 2008) | 1 line
Fix ThemeBrowser to use FSNodes, not getPath()
........
r34715 | Kirben | 2008-10-02 16:41:50 +0200 (Thu, 02 Oct 2008) | 1 line
Correct HE version for Putt-Putt Enters the Race (French/Windows).
........
r34716 | fingolfin | 2008-10-02 18:58:59 +0200 (Thu, 02 Oct 2008) | 1 line
Renamed FilesystemNode -> FSNode
........
r34717 | fingolfin | 2008-10-02 19:08:15 +0200 (Thu, 02 Oct 2008) | 1 line
cleanup
........
r34718 | fingolfin | 2008-10-02 19:17:18 +0200 (Thu, 02 Oct 2008) | 1 line
Ignore String::deleteLastChar when called on an empty string
........
r34719 | fingolfin | 2008-10-02 19:20:21 +0200 (Thu, 02 Oct 2008) | 1 line
Fix for bug #2142743: Assertion on clicking "Theme" in Options
........
r34720 | fingolfin | 2008-10-02 19:48:01 +0200 (Thu, 02 Oct 2008) | 7 lines
Engine class changed:
- Moved initCommonGFX() && GUIErrorMessage() out of class Engine
- got rid of the _autosavePeriod member (this prevented users from
changing the autosave period during runtime)
- Got rid of an evil 'using GUI::Dialog' statement
- Clarified some Doxygen comments
........
r34721 | fingolfin | 2008-10-02 19:52:29 +0200 (Thu, 02 Oct 2008) | 1 line
Add the current dir to the global SearchSet, i.e. to SearchMan (this should fix the problems on Windows, and maybe other systems, see 'bug' #2137680)
........
r34722 | fingolfin | 2008-10-02 19:55:08 +0200 (Thu, 02 Oct 2008) | 1 line
Forgot to mention yet another Engine class change: mainMenuDialog -> openMainMenuDialog; and also forgot to commit this related file :/
........
r34725 | fingolfin | 2008-10-02 20:11:40 +0200 (Thu, 02 Oct 2008) | 1 line
typo
........
r34726 | thebluegr | 2008-10-03 00:04:34 +0200 (Fri, 03 Oct 2008) | 1 line
Merged loadHotSpotsMads() and loadHotSpotsM4()
........
r34727 | lordhoto | 2008-10-03 02:16:21 +0200 (Fri, 03 Oct 2008) | 2 lines
Fixed typos (thanks to Raziel^ for spotting them).
........
r34731 | fingolfin | 2008-10-03 18:07:57 +0200 (Fri, 03 Oct 2008) | 1 line
Fixed Engine::hasFeature to use proper types (i.e., MetaEngine::MetaEngineFeature instead of int)
........
r34732 | fingolfin | 2008-10-03 18:14:12 +0200 (Fri, 03 Oct 2008) | 1 line
SCUMM: Added french Monkey VGA variant, see bug #2129199
........
r34734 | lordhoto | 2008-10-03 18:57:40 +0200 (Fri, 03 Oct 2008) | 2 lines
Committed slightly modified patch #2034983 "Case-insensitivy and directory handling for engines".
........
r34735 | lordhoto | 2008-10-03 20:18:42 +0200 (Fri, 03 Oct 2008) | 2 lines
Check all 'kyra.dat' files in setup paths instead of only the first one found.
........
r34736 | lordhoto | 2008-10-03 20:23:57 +0200 (Fri, 03 Oct 2008) | 2 lines
Cleanup.
........
r34737 | dreammaster | 2008-10-04 13:10:25 +0200 (Sat, 04 Oct 2008) | 1 line
Bugfix to prevent NPC characters managing to walk beyond room exits without leaving the room, and thus getting stuck
........
r34738 | fingolfin | 2008-10-04 15:09:01 +0200 (Sat, 04 Oct 2008) | 1 line
Renamed some MetaEngine feature flags; removed explicit numbers from this feature flag list (nothing should rely on their specific values, anyway); added a note that Engine::hasFeature should become independant of MetaEngine::hasFeature
........
r34746 | john_doe | 2008-10-04 23:40:14 +0200 (Sat, 04 Oct 2008) | 3 lines
- Declared all stack functions as inline
- Sleep some ms after 500 opcodes to reduce CPU load
- Fixed odd bug in LGoP2 where text disappeared quickly without waiting for user input by returning 0x38 in sfShowPage
........
svn-id: r34749
2008-10-05 11:21:07 +00:00
|
|
|
bool loadFile(const FSNode &node) {
|
2008-10-11 22:11:02 +00:00
|
|
|
_stream = node.openForReading();
|
|
|
|
if (!_stream)
|
2008-08-16 14:06:26 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
_fileName = node.getName();
|
|
|
|
return true;
|
|
|
|
}
|
2008-06-25 14:19:56 +00:00
|
|
|
|
2008-06-26 13:50:16 +00:00
|
|
|
/**
|
|
|
|
* Loads a memory buffer into the parser.
|
|
|
|
* Used for loading the default theme fallback directly
|
|
|
|
* from memory if no themes can be found.
|
|
|
|
*
|
|
|
|
* @param buffer Pointer to the buffer.
|
2008-07-03 16:09:54 +00:00
|
|
|
* @param size Size of the buffer
|
2008-06-26 13:50:16 +00:00
|
|
|
* @param disposable Sets if the XMLParser owns the buffer,
|
|
|
|
* i.e. if it can be freed safely after it's
|
|
|
|
* no longer needed by the parser.
|
|
|
|
*/
|
2008-07-30 14:08:07 +00:00
|
|
|
bool loadBuffer(const byte *buffer, uint32 size, bool disposable = false) {
|
2008-09-05 14:48:47 +00:00
|
|
|
_stream = new MemoryReadStream(buffer, size, disposable);
|
2008-06-26 13:50:16 +00:00
|
|
|
_fileName = "Memory Stream";
|
2008-06-25 14:19:56 +00:00
|
|
|
return true;
|
2008-08-09 18:34:16 +00:00
|
|
|
}
|
|
|
|
|
- Merged 75 revisions from trunk.
- Fixed new conflicts.
- Changed Theme loading to use the new ZipArchive class.
- Implemented ZipArchive::getAllNames()
Original log message from SVNMerge.py
================================
Merged revisions 34605,34613-34615,34617,34619-34624,34627-34628,34630-34639,34642-34649,34656-34661,34663-34664,34671-34672,34674-34676,34678-34685 via svnmerge from
https://tanoku@scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk
........
r34605 | Tanoku | 2008-09-20 12:32:59 +0200 (Sat, 20 Sep 2008) | 1 line
Fixed "empty control statement" warning in FSDirectory::matchPattern().
........
r34613 | lordhoto | 2008-09-20 16:53:31 +0200 (Sat, 20 Sep 2008) | 2 lines
Updated theme file version, to reflect latest addition of new required entries/files.
........
r34614 | wjpalenstijn | 2008-09-20 17:03:37 +0200 (Sat, 20 Sep 2008) | 1 line
fix drawing order in saveload choosers (draw container before contents)
........
r34615 | fingolfin | 2008-09-20 17:53:17 +0200 (Sat, 20 Sep 2008) | 1 line
Little readability tweak
........
r34617 | fingolfin | 2008-09-20 18:10:29 +0200 (Sat, 20 Sep 2008) | 1 line
Fix for bug #2120602: 5ALL: Starting the launcher with -f triggers assertion
........
r34619 | eriktorbjorn | 2008-09-20 18:21:27 +0200 (Sat, 20 Sep 2008) | 4 lines
I think this is the correct fix for bug #2081347 ("MM: Charset out of
bounds!"). If I understand correctly, version <= 2 games only have one (hard-
coded) font, so when that's initialised we can set _curId to 0.
........
r34620 | marcus_c | 2008-09-20 18:38:50 +0200 (Sat, 20 Sep 2008) | 1 line
game.h is now in engines, not base.
........
r34621 | marcus_c | 2008-09-20 18:47:31 +0200 (Sat, 20 Sep 2008) | 5 lines
In the CD filesystem, nothing can be opened for writing, so just
short-circuit any call to openForWriting(). Also, directories and
non-existing files can't be opened for reading either, so just
return 0 for those.
........
r34622 | sev | 2008-09-21 12:23:22 +0200 (Sun, 21 Sep 2008) | 2 lines
Patch #2054467: CRUISE: 64bits fixes
........
r34623 | sev | 2008-09-21 13:17:22 +0200 (Sun, 21 Sep 2008) | 2 lines
Add recent patch contributors. Reflect current ScummVM team in the credits
........
r34624 | sev | 2008-09-21 13:18:16 +0200 (Sun, 21 Sep 2008) | 2 lines
Reflect current team
........
r34627 | lordhoto | 2008-09-22 19:33:30 +0200 (Mon, 22 Sep 2008) | 1 line
Fixed full screen toggling via alt+enter.
........
r34628 | fingolfin | 2008-09-22 22:55:27 +0200 (Mon, 22 Sep 2008) | 1 line
Fix comments for random() funcs (thanks to salty-horse for pointing this out)
........
r34630 | fingolfin | 2008-09-23 11:39:37 +0200 (Tue, 23 Sep 2008) | 1 line
Moved ZipArchive implementation into unzip.cpp, added new ZipArchive::isOpen method
........
r34631 | fingolfin | 2008-09-23 11:42:38 +0200 (Tue, 23 Sep 2008) | 1 line
ImageManager: renamed remArchive() to removeArchive(); switched to using a SearchSet + ZipArchive to access ZIP files (code is much simpler now yet more flexible, yay)
........
r34632 | fingolfin | 2008-09-23 11:50:03 +0200 (Tue, 23 Sep 2008) | 1 line
Moved ZipArchive to namespace Common; moved unzip internals from unzip.h to unzip.cpp (to be cleaned up)
........
r34633 | fingolfin | 2008-09-23 12:08:45 +0200 (Tue, 23 Sep 2008) | 1 line
cleanup
........
r34634 | fingolfin | 2008-09-23 12:10:29 +0200 (Tue, 23 Sep 2008) | 1 line
Perform error checking when reading from a ZIP file
........
r34635 | fingolfin | 2008-09-23 13:43:57 +0200 (Tue, 23 Sep 2008) | 1 line
Fix for bug #1917981: Game crash when finishing Indy3 demo. At the same time, added a new paranoia check
........
r34636 | Kirben | 2008-09-23 14:34:02 +0200 (Tue, 23 Sep 2008) | 1 line
Add another French Windows version of Putt-Putt Enters the Race.
........
r34637 | lordhoto | 2008-09-23 18:40:41 +0200 (Tue, 23 Sep 2008) | 2 lines
Fix for bug #2120780 "GUI: gui-theme command-line option ignored", '-f' and '-g' command line switch behavior.
........
r34638 | john_doe | 2008-09-24 01:16:47 +0200 (Wed, 24 Sep 2008) | 1 line
Improved updateScreenAndWait; the mouse cursor is less jerky now in some scenes in Manhole:N&E
........
r34639 | thebluegr | 2008-09-24 09:26:45 +0200 (Wed, 24 Sep 2008) | 1 line
Readded missing special case for the storm animation in ITE. Fixes bug #2125675 - "ITE: Game locks up in storm clouds scene"
........
r34642 | fingolfin | 2008-09-24 22:29:29 +0200 (Wed, 24 Sep 2008) | 1 line
Changed Common::String to use a MemoryPool for its refcounts
........
r34643 | fingolfin | 2008-09-24 22:31:14 +0200 (Wed, 24 Sep 2008) | 1 line
cleanup
........
r34644 | fingolfin | 2008-09-24 22:35:31 +0200 (Wed, 24 Sep 2008) | 1 line
Changed builtin Common::String capacity to 24 (on 32 bit systems), to make sizeof(String) 32; reduces overall memory req by 200k on my system; overall # of mallocs after this + the refcount memory pool change is almost unchanged
........
r34645 | sev | 2008-09-25 00:44:01 +0200 (Thu, 25 Sep 2008) | 2 lines
Fix bugs #1981081: "ITE: No blinking disk icon" and #1971729: "IHNM: No Animation of Disk Icon"
........
r34646 | fingolfin | 2008-09-25 10:06:18 +0200 (Thu, 25 Sep 2008) | 1 line
SCUMM: Added a new ActorHE class, as well as a virtual Actor::prepareDrawActorCostume() method
........
r34647 | fingolfin | 2008-09-25 10:19:51 +0200 (Thu, 25 Sep 2008) | 1 line
SCUMM: Moved Actor::drawActorToBackBuf to class ActorHE
........
r34648 | fingolfin | 2008-09-25 12:11:06 +0200 (Thu, 25 Sep 2008) | 1 line
SCUMM: Moved more stuf from class Actor to ActorHE
........
r34649 | fingolfin | 2008-09-25 12:14:50 +0200 (Thu, 25 Sep 2008) | 1 line
cleanup
........
r34656 | eriktorbjorn | 2008-09-27 19:25:40 +0200 (Sat, 27 Sep 2008) | 2 lines
Fixed typos.
........
r34657 | eriktorbjorn | 2008-09-27 19:47:22 +0200 (Sat, 27 Sep 2008) | 2 lines
Allow quitting or returning to the launcher while cutscenes are playing.
........
r34658 | eriktorbjorn | 2008-09-27 19:51:22 +0200 (Sat, 27 Sep 2008) | 2 lines
Slight simplification of last commit.
........
r34659 | fingolfin | 2008-09-27 20:32:01 +0200 (Sat, 27 Sep 2008) | 1 line
Modified Common::SearchSet to take signed integer priorities, for convenience (so that one can add archives with less-than-default priority)
........
r34660 | fingolfin | 2008-09-27 20:34:24 +0200 (Sat, 27 Sep 2008) | 1 line
Fixed a nasty bug in SearchManager::addDirectory; made the 'char' constructor of Common::String explicit, to avoid such bugs in the future
........
r34661 | drmccoy | 2008-09-27 22:04:04 +0200 (Sat, 27 Sep 2008) | 2 lines
Added a spanish floppy version of Lost in Time, as supplied by goodoldgeorg in bug report #2105220
........
r34663 | fingolfin | 2008-09-28 01:00:46 +0200 (Sun, 28 Sep 2008) | 1 line
Changed Common::File to use SearchMan
........
r34664 | fingolfin | 2008-09-28 01:27:01 +0200 (Sun, 28 Sep 2008) | 1 line
SCUMM: Use FilesystemNode::openForReading instead of Common::File::open(FilesystemNode) in the detector
........
r34671 | john_doe | 2008-09-28 22:02:01 +0200 (Sun, 28 Sep 2008) | 1 line
Return 32000 in sfGetCdTime instead of 0; this fixes the Manhole intro/credits (until the function is actually implemented)
........
r34672 | sev | 2008-09-28 23:07:41 +0200 (Sun, 28 Sep 2008) | 2 lines
Add Italian C64 Zak
........
r34674 | sev | 2008-09-28 23:53:14 +0200 (Sun, 28 Sep 2008) | 2 lines
Fix bug #2043489: DRASCULA: Cannot disable speech
........
r34675 | sev | 2008-09-29 00:07:16 +0200 (Mon, 29 Sep 2008) | 3 lines
- Renamed withVoices to _subtitlesDisabled as it reflect the true meaning.
- Allowed to disable subtitles from options dialogs including RTL.
........
r34676 | sev | 2008-09-29 00:19:11 +0200 (Mon, 29 Sep 2008) | 2 lines
Use better "silence" without clicks when speech is disabled.
........
r34678 | fingolfin | 2008-09-29 12:29:01 +0200 (Mon, 29 Sep 2008) | 1 line
Added FIXME to GP2x port
........
r34679 | fingolfin | 2008-09-29 12:30:31 +0200 (Mon, 29 Sep 2008) | 1 line
Add priority parameter to the SearchMan API
........
r34680 | fingolfin | 2008-09-29 12:32:06 +0200 (Mon, 29 Sep 2008) | 1 line
File::open no longer falls back to searching the current dir (if this causes any regressions, please report them; don't work around them, don't revert this change, without discussing it first)
........
r34681 | fingolfin | 2008-09-29 12:49:36 +0200 (Mon, 29 Sep 2008) | 1 line
Don't subclass ArjFile from Common::File (there seems to be no good reason for it). BTW, this code is an abomination and should be replaced by an Archive/SearchSet approach
........
r34682 | fingolfin | 2008-09-29 13:01:25 +0200 (Mon, 29 Sep 2008) | 1 line
Added const qualifiers
........
r34683 | fingolfin | 2008-09-29 13:02:11 +0200 (Mon, 29 Sep 2008) | 1 line
SCUMM HE: Fixed leak in Win32ResExtractor::extractResource_, use _filename instead of File::name
........
r34684 | fingolfin | 2008-09-29 13:03:10 +0200 (Mon, 29 Sep 2008) | 1 line
Added const qualifiers
........
r34685 | fingolfin | 2008-09-29 13:07:39 +0200 (Mon, 29 Sep 2008) | 1 line
Don't use File::name() needlessly (i.e. if you still know which file you just opened :)
........
svn-id: r34687
2008-09-29 19:23:36 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream *stream) {
|
2008-09-05 14:48:47 +00:00
|
|
|
_stream = stream;
|
- Merged 75 revisions from trunk.
- Fixed new conflicts.
- Changed Theme loading to use the new ZipArchive class.
- Implemented ZipArchive::getAllNames()
Original log message from SVNMerge.py
================================
Merged revisions 34605,34613-34615,34617,34619-34624,34627-34628,34630-34639,34642-34649,34656-34661,34663-34664,34671-34672,34674-34676,34678-34685 via svnmerge from
https://tanoku@scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk
........
r34605 | Tanoku | 2008-09-20 12:32:59 +0200 (Sat, 20 Sep 2008) | 1 line
Fixed "empty control statement" warning in FSDirectory::matchPattern().
........
r34613 | lordhoto | 2008-09-20 16:53:31 +0200 (Sat, 20 Sep 2008) | 2 lines
Updated theme file version, to reflect latest addition of new required entries/files.
........
r34614 | wjpalenstijn | 2008-09-20 17:03:37 +0200 (Sat, 20 Sep 2008) | 1 line
fix drawing order in saveload choosers (draw container before contents)
........
r34615 | fingolfin | 2008-09-20 17:53:17 +0200 (Sat, 20 Sep 2008) | 1 line
Little readability tweak
........
r34617 | fingolfin | 2008-09-20 18:10:29 +0200 (Sat, 20 Sep 2008) | 1 line
Fix for bug #2120602: 5ALL: Starting the launcher with -f triggers assertion
........
r34619 | eriktorbjorn | 2008-09-20 18:21:27 +0200 (Sat, 20 Sep 2008) | 4 lines
I think this is the correct fix for bug #2081347 ("MM: Charset out of
bounds!"). If I understand correctly, version <= 2 games only have one (hard-
coded) font, so when that's initialised we can set _curId to 0.
........
r34620 | marcus_c | 2008-09-20 18:38:50 +0200 (Sat, 20 Sep 2008) | 1 line
game.h is now in engines, not base.
........
r34621 | marcus_c | 2008-09-20 18:47:31 +0200 (Sat, 20 Sep 2008) | 5 lines
In the CD filesystem, nothing can be opened for writing, so just
short-circuit any call to openForWriting(). Also, directories and
non-existing files can't be opened for reading either, so just
return 0 for those.
........
r34622 | sev | 2008-09-21 12:23:22 +0200 (Sun, 21 Sep 2008) | 2 lines
Patch #2054467: CRUISE: 64bits fixes
........
r34623 | sev | 2008-09-21 13:17:22 +0200 (Sun, 21 Sep 2008) | 2 lines
Add recent patch contributors. Reflect current ScummVM team in the credits
........
r34624 | sev | 2008-09-21 13:18:16 +0200 (Sun, 21 Sep 2008) | 2 lines
Reflect current team
........
r34627 | lordhoto | 2008-09-22 19:33:30 +0200 (Mon, 22 Sep 2008) | 1 line
Fixed full screen toggling via alt+enter.
........
r34628 | fingolfin | 2008-09-22 22:55:27 +0200 (Mon, 22 Sep 2008) | 1 line
Fix comments for random() funcs (thanks to salty-horse for pointing this out)
........
r34630 | fingolfin | 2008-09-23 11:39:37 +0200 (Tue, 23 Sep 2008) | 1 line
Moved ZipArchive implementation into unzip.cpp, added new ZipArchive::isOpen method
........
r34631 | fingolfin | 2008-09-23 11:42:38 +0200 (Tue, 23 Sep 2008) | 1 line
ImageManager: renamed remArchive() to removeArchive(); switched to using a SearchSet + ZipArchive to access ZIP files (code is much simpler now yet more flexible, yay)
........
r34632 | fingolfin | 2008-09-23 11:50:03 +0200 (Tue, 23 Sep 2008) | 1 line
Moved ZipArchive to namespace Common; moved unzip internals from unzip.h to unzip.cpp (to be cleaned up)
........
r34633 | fingolfin | 2008-09-23 12:08:45 +0200 (Tue, 23 Sep 2008) | 1 line
cleanup
........
r34634 | fingolfin | 2008-09-23 12:10:29 +0200 (Tue, 23 Sep 2008) | 1 line
Perform error checking when reading from a ZIP file
........
r34635 | fingolfin | 2008-09-23 13:43:57 +0200 (Tue, 23 Sep 2008) | 1 line
Fix for bug #1917981: Game crash when finishing Indy3 demo. At the same time, added a new paranoia check
........
r34636 | Kirben | 2008-09-23 14:34:02 +0200 (Tue, 23 Sep 2008) | 1 line
Add another French Windows version of Putt-Putt Enters the Race.
........
r34637 | lordhoto | 2008-09-23 18:40:41 +0200 (Tue, 23 Sep 2008) | 2 lines
Fix for bug #2120780 "GUI: gui-theme command-line option ignored", '-f' and '-g' command line switch behavior.
........
r34638 | john_doe | 2008-09-24 01:16:47 +0200 (Wed, 24 Sep 2008) | 1 line
Improved updateScreenAndWait; the mouse cursor is less jerky now in some scenes in Manhole:N&E
........
r34639 | thebluegr | 2008-09-24 09:26:45 +0200 (Wed, 24 Sep 2008) | 1 line
Readded missing special case for the storm animation in ITE. Fixes bug #2125675 - "ITE: Game locks up in storm clouds scene"
........
r34642 | fingolfin | 2008-09-24 22:29:29 +0200 (Wed, 24 Sep 2008) | 1 line
Changed Common::String to use a MemoryPool for its refcounts
........
r34643 | fingolfin | 2008-09-24 22:31:14 +0200 (Wed, 24 Sep 2008) | 1 line
cleanup
........
r34644 | fingolfin | 2008-09-24 22:35:31 +0200 (Wed, 24 Sep 2008) | 1 line
Changed builtin Common::String capacity to 24 (on 32 bit systems), to make sizeof(String) 32; reduces overall memory req by 200k on my system; overall # of mallocs after this + the refcount memory pool change is almost unchanged
........
r34645 | sev | 2008-09-25 00:44:01 +0200 (Thu, 25 Sep 2008) | 2 lines
Fix bugs #1981081: "ITE: No blinking disk icon" and #1971729: "IHNM: No Animation of Disk Icon"
........
r34646 | fingolfin | 2008-09-25 10:06:18 +0200 (Thu, 25 Sep 2008) | 1 line
SCUMM: Added a new ActorHE class, as well as a virtual Actor::prepareDrawActorCostume() method
........
r34647 | fingolfin | 2008-09-25 10:19:51 +0200 (Thu, 25 Sep 2008) | 1 line
SCUMM: Moved Actor::drawActorToBackBuf to class ActorHE
........
r34648 | fingolfin | 2008-09-25 12:11:06 +0200 (Thu, 25 Sep 2008) | 1 line
SCUMM: Moved more stuf from class Actor to ActorHE
........
r34649 | fingolfin | 2008-09-25 12:14:50 +0200 (Thu, 25 Sep 2008) | 1 line
cleanup
........
r34656 | eriktorbjorn | 2008-09-27 19:25:40 +0200 (Sat, 27 Sep 2008) | 2 lines
Fixed typos.
........
r34657 | eriktorbjorn | 2008-09-27 19:47:22 +0200 (Sat, 27 Sep 2008) | 2 lines
Allow quitting or returning to the launcher while cutscenes are playing.
........
r34658 | eriktorbjorn | 2008-09-27 19:51:22 +0200 (Sat, 27 Sep 2008) | 2 lines
Slight simplification of last commit.
........
r34659 | fingolfin | 2008-09-27 20:32:01 +0200 (Sat, 27 Sep 2008) | 1 line
Modified Common::SearchSet to take signed integer priorities, for convenience (so that one can add archives with less-than-default priority)
........
r34660 | fingolfin | 2008-09-27 20:34:24 +0200 (Sat, 27 Sep 2008) | 1 line
Fixed a nasty bug in SearchManager::addDirectory; made the 'char' constructor of Common::String explicit, to avoid such bugs in the future
........
r34661 | drmccoy | 2008-09-27 22:04:04 +0200 (Sat, 27 Sep 2008) | 2 lines
Added a spanish floppy version of Lost in Time, as supplied by goodoldgeorg in bug report #2105220
........
r34663 | fingolfin | 2008-09-28 01:00:46 +0200 (Sun, 28 Sep 2008) | 1 line
Changed Common::File to use SearchMan
........
r34664 | fingolfin | 2008-09-28 01:27:01 +0200 (Sun, 28 Sep 2008) | 1 line
SCUMM: Use FilesystemNode::openForReading instead of Common::File::open(FilesystemNode) in the detector
........
r34671 | john_doe | 2008-09-28 22:02:01 +0200 (Sun, 28 Sep 2008) | 1 line
Return 32000 in sfGetCdTime instead of 0; this fixes the Manhole intro/credits (until the function is actually implemented)
........
r34672 | sev | 2008-09-28 23:07:41 +0200 (Sun, 28 Sep 2008) | 2 lines
Add Italian C64 Zak
........
r34674 | sev | 2008-09-28 23:53:14 +0200 (Sun, 28 Sep 2008) | 2 lines
Fix bug #2043489: DRASCULA: Cannot disable speech
........
r34675 | sev | 2008-09-29 00:07:16 +0200 (Mon, 29 Sep 2008) | 3 lines
- Renamed withVoices to _subtitlesDisabled as it reflect the true meaning.
- Allowed to disable subtitles from options dialogs including RTL.
........
r34676 | sev | 2008-09-29 00:19:11 +0200 (Mon, 29 Sep 2008) | 2 lines
Use better "silence" without clicks when speech is disabled.
........
r34678 | fingolfin | 2008-09-29 12:29:01 +0200 (Mon, 29 Sep 2008) | 1 line
Added FIXME to GP2x port
........
r34679 | fingolfin | 2008-09-29 12:30:31 +0200 (Mon, 29 Sep 2008) | 1 line
Add priority parameter to the SearchMan API
........
r34680 | fingolfin | 2008-09-29 12:32:06 +0200 (Mon, 29 Sep 2008) | 1 line
File::open no longer falls back to searching the current dir (if this causes any regressions, please report them; don't work around them, don't revert this change, without discussing it first)
........
r34681 | fingolfin | 2008-09-29 12:49:36 +0200 (Mon, 29 Sep 2008) | 1 line
Don't subclass ArjFile from Common::File (there seems to be no good reason for it). BTW, this code is an abomination and should be replaced by an Archive/SearchSet approach
........
r34682 | fingolfin | 2008-09-29 13:01:25 +0200 (Mon, 29 Sep 2008) | 1 line
Added const qualifiers
........
r34683 | fingolfin | 2008-09-29 13:02:11 +0200 (Mon, 29 Sep 2008) | 1 line
SCUMM HE: Fixed leak in Win32ResExtractor::extractResource_, use _filename instead of File::name
........
r34684 | fingolfin | 2008-09-29 13:03:10 +0200 (Mon, 29 Sep 2008) | 1 line
Added const qualifiers
........
r34685 | fingolfin | 2008-09-29 13:07:39 +0200 (Mon, 29 Sep 2008) | 1 line
Don't use File::name() needlessly (i.e. if you still know which file you just opened :)
........
svn-id: r34687
2008-09-29 19:23:36 +00:00
|
|
|
_fileName = "File Stream";
|
2008-08-09 18:34:16 +00:00
|
|
|
return true;
|
2008-06-25 14:19:56 +00:00
|
|
|
}
|
2008-09-29 10:27:16 +00:00
|
|
|
|
|
|
|
void close() {
|
2008-10-11 22:11:02 +00:00
|
|
|
delete _stream;
|
|
|
|
_stream = 0;
|
2008-09-29 10:27:16 +00:00
|
|
|
}
|
2008-06-25 14:19:56 +00:00
|
|
|
|
2008-06-26 13:50:16 +00:00
|
|
|
/**
|
|
|
|
* The actual parsing function.
|
|
|
|
* Parses the loaded data stream, returns true if successful.
|
|
|
|
*/
|
2008-07-30 14:08:07 +00:00
|
|
|
bool parse();
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the active node being parsed (the one on top of
|
|
|
|
* the node stack).
|
|
|
|
*/
|
2008-06-25 17:56:00 +00:00
|
|
|
ParserNode *getActiveNode() {
|
2008-06-18 23:49:47 +00:00
|
|
|
if (!_activeKey.empty())
|
|
|
|
return _activeKey.top();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-25 17:56:00 +00:00
|
|
|
/**
|
|
|
|
* Returns the parent of a given node in the stack.
|
|
|
|
*/
|
|
|
|
ParserNode *getParentNode(ParserNode *child) {
|
|
|
|
return child->depth > 0 ? _activeKey[child->depth - 1] : 0;
|
|
|
|
}
|
|
|
|
|
2008-06-18 23:49:47 +00:00
|
|
|
protected:
|
2008-07-30 13:33:32 +00:00
|
|
|
|
2008-06-18 23:49:47 +00:00
|
|
|
/**
|
2008-07-30 13:33:32 +00:00
|
|
|
* The buildLayout function builds the layout for the parser to use
|
|
|
|
* based on a series of helper macros. This function is automatically
|
|
|
|
* generated by the CUSTOM_XML_PARSER() macro on custom parsers.
|
2008-06-18 23:49:47 +00:00
|
|
|
*
|
2008-07-30 13:33:32 +00:00
|
|
|
* See the documentation regarding XML layouts.
|
|
|
|
*/
|
|
|
|
virtual void buildLayout() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The keycallback function is automatically overloaded on custom parsers
|
|
|
|
* when using the CUSTOM_XML_PARSER() macro.
|
2008-06-18 23:49:47 +00:00
|
|
|
*
|
2008-07-30 13:33:32 +00:00
|
|
|
* Its job is to call the corresponding Callback function for the given node.
|
|
|
|
* A function for each key type must be declared separately. See the custom
|
|
|
|
* parser creation instructions.
|
2008-06-18 23:49:47 +00:00
|
|
|
*
|
2008-07-30 13:33:32 +00:00
|
|
|
* When parsing a key in such function, one may chose to skip it, e.g. because it's not needed
|
2008-06-24 19:48:01 +00:00
|
|
|
* on the current configuration. In order to ignore a key, you must set
|
|
|
|
* the "ignore" field of its KeyNode struct to "true": The key and all its children
|
|
|
|
* will then be automatically ignored by the parser.
|
|
|
|
*
|
2008-07-30 13:33:32 +00:00
|
|
|
* The callback function must return true if the key was properly handled (this includes the case when the
|
|
|
|
* key is being ignored). False otherwise. The return of keyCallback() is the same as
|
|
|
|
* the callback function's.
|
2008-06-18 23:49:47 +00:00
|
|
|
* See the sample implementation in GUI::ThemeParser.
|
|
|
|
*/
|
2008-07-30 13:33:32 +00:00
|
|
|
virtual bool keyCallback(ParserNode *node) = 0;
|
2008-06-18 23:49:47 +00:00
|
|
|
|
2008-07-04 23:51:23 +00:00
|
|
|
/**
|
2008-07-30 13:33:32 +00:00
|
|
|
* The closed key callback function MAY be overloaded by inheriting classes to
|
2008-07-04 23:51:23 +00:00
|
|
|
* implement parser-specific functions.
|
|
|
|
*
|
|
|
|
* The closedKeyCallback is issued once a key has been finished parsing, to let
|
|
|
|
* the parser verify that all the required subkeys, etc, were included.
|
|
|
|
*
|
2008-08-08 18:48:12 +00:00
|
|
|
* Unlike the keyCallbacks(), there's just a closedKeyCallback() for all keys.
|
|
|
|
* Use "node->name" to distinguish between each key type.
|
|
|
|
*
|
2008-07-04 23:51:23 +00:00
|
|
|
* Returns true if the key was properly closed, false otherwise.
|
|
|
|
* By default, all keys are properly closed.
|
|
|
|
*/
|
2008-07-30 13:33:32 +00:00
|
|
|
virtual bool closedKeyCallback(ParserNode *node) {
|
2008-07-04 23:51:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-08-08 18:48:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a node is closed. Manages its cleanup and calls the
|
|
|
|
* closing callback function if needed.
|
|
|
|
*/
|
|
|
|
bool closeKey();
|
2008-07-04 23:51:23 +00:00
|
|
|
|
2008-06-18 23:49:47 +00:00
|
|
|
/**
|
|
|
|
* Parses the value of a given key. There's no reason to overload this.
|
|
|
|
*/
|
2008-07-30 13:33:32 +00:00
|
|
|
bool parseKeyValue(Common::String keyName);
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called once a key has been parsed. It handles the closing/cleanup of the
|
|
|
|
* node stack and calls the keyCallback.
|
|
|
|
*/
|
2008-07-30 13:33:32 +00:00
|
|
|
bool parseActiveKey(bool closed);
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints an error message when parsing fails and stops the parser.
|
2008-06-25 14:19:56 +00:00
|
|
|
* Parser error always returns "false" so we can pass the return value directly
|
|
|
|
* and break down the parsing.
|
2008-06-18 23:49:47 +00:00
|
|
|
*/
|
2008-07-30 13:33:32 +00:00
|
|
|
bool parserError(const char *errorString, ...) GCC_PRINTF(2, 3);
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Skips spaces/whitelines etc. Returns true if any spaces were skipped.
|
|
|
|
*/
|
2008-07-30 14:08:07 +00:00
|
|
|
bool skipSpaces() {
|
2008-09-05 14:48:47 +00:00
|
|
|
if (!isspace(_char))
|
2008-06-18 23:49:47 +00:00
|
|
|
return false;
|
|
|
|
|
2008-09-05 14:48:47 +00:00
|
|
|
while (_char && isspace(_char))
|
|
|
|
_char = _stream->readByte();
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Skips comment blocks and comment lines.
|
|
|
|
* Returns true if any comments were skipped.
|
|
|
|
* Overload this if you want to disable comments on your XML syntax
|
|
|
|
* or to change the commenting syntax.
|
|
|
|
*/
|
|
|
|
virtual bool skipComments() {
|
2008-10-15 13:34:18 +00:00
|
|
|
if (_char == '<') {
|
2008-09-05 14:48:47 +00:00
|
|
|
_char = _stream->readByte();
|
|
|
|
|
2008-10-15 13:34:18 +00:00
|
|
|
if (_char != '!') {
|
2008-09-05 14:48:47 +00:00
|
|
|
_stream->seek(-1, SEEK_CUR);
|
2008-10-15 13:34:18 +00:00
|
|
|
_char = '<';
|
2008-09-05 14:48:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-10-15 13:34:18 +00:00
|
|
|
if (_stream->readByte() != '-' || _stream->readByte() != '-')
|
|
|
|
return parserError("Malformed comment syntax.");
|
|
|
|
|
2008-09-05 14:48:47 +00:00
|
|
|
_char = _stream->readByte();
|
2008-10-15 13:34:18 +00:00
|
|
|
bool dash = false;
|
2008-09-05 14:48:47 +00:00
|
|
|
|
|
|
|
while (_char) {
|
2008-10-15 13:34:18 +00:00
|
|
|
if (_char == '-') {
|
|
|
|
if (dash && _stream->readByte() == '>') {
|
|
|
|
_char = _stream->readByte();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
dash = !dash;
|
|
|
|
}
|
|
|
|
|
2008-09-05 14:48:47 +00:00
|
|
|
_char = _stream->readByte();
|
2008-06-18 23:49:47 +00:00
|
|
|
}
|
2008-10-15 13:34:18 +00:00
|
|
|
|
|
|
|
return parserError("Comment has no closure.");
|
2008-06-18 23:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a given character can be part of a KEY or VALUE name.
|
|
|
|
* Overload this if you want to support keys with strange characters
|
|
|
|
* in their name.
|
|
|
|
*/
|
2008-09-05 14:48:47 +00:00
|
|
|
virtual inline bool isValidNameChar(char c) {
|
2008-06-18 23:49:47 +00:00
|
|
|
return isalnum(c) || c == '_';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses a the first textual token found.
|
|
|
|
* There's no reason to overload this.
|
|
|
|
*/
|
2008-07-30 13:33:32 +00:00
|
|
|
bool parseToken() {
|
2008-06-18 23:49:47 +00:00
|
|
|
_token.clear();
|
|
|
|
|
2008-09-05 14:48:47 +00:00
|
|
|
while (isValidNameChar(_char)) {
|
|
|
|
_token += _char;
|
|
|
|
_char = _stream->readByte();
|
|
|
|
}
|
|
|
|
|
|
|
|
return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/';
|
2008-06-18 23:49:47 +00:00
|
|
|
}
|
|
|
|
|
2008-06-28 00:02:54 +00:00
|
|
|
/**
|
|
|
|
* Parses the values inside an integer key.
|
|
|
|
* The count parameter specifies the number of values inside
|
|
|
|
* the key, which are expected to be separated with commas.
|
|
|
|
*
|
|
|
|
* Sample usage:
|
|
|
|
* parseIntegerKey("255, 255, 255", 3, &red, &green, &blue);
|
|
|
|
* [will parse each field into its own integer]
|
|
|
|
*
|
|
|
|
* parseIntegerKey("1234", 1, &number);
|
|
|
|
* [will parse the single number into the variable]
|
|
|
|
*
|
|
|
|
* @param key String containing the integers to be parsed.
|
|
|
|
* @param count Number of comma-separated ints in the string.
|
|
|
|
* @param ... Integer variables to store the parsed ints, passed
|
|
|
|
* by reference.
|
|
|
|
* @returns True if the parsing succeeded.
|
|
|
|
*/
|
2008-07-30 13:33:32 +00:00
|
|
|
bool parseIntegerKey(const char *key, int count, ...) {
|
2008-06-28 13:44:10 +00:00
|
|
|
char *parseEnd;
|
2008-06-28 00:02:54 +00:00
|
|
|
int *num_ptr;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, count);
|
|
|
|
|
|
|
|
while (count--) {
|
|
|
|
while (isspace(*key))
|
|
|
|
key++;
|
|
|
|
|
|
|
|
num_ptr = va_arg(args, int*);
|
|
|
|
*num_ptr = strtol(key, &parseEnd, 10);
|
|
|
|
|
2008-06-28 13:44:10 +00:00
|
|
|
key = parseEnd;
|
2008-06-28 00:02:54 +00:00
|
|
|
|
2008-06-28 13:44:10 +00:00
|
|
|
while (isspace(*key))
|
|
|
|
key++;
|
2008-06-28 00:02:54 +00:00
|
|
|
|
2008-06-28 13:44:10 +00:00
|
|
|
if (count && *key++ != ',')
|
|
|
|
return false;
|
2008-06-28 00:02:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
va_end(args);
|
2008-06-28 13:44:10 +00:00
|
|
|
return (*key == 0);
|
2008-06-28 00:02:54 +00:00
|
|
|
}
|
|
|
|
|
2008-07-03 19:42:04 +00:00
|
|
|
/**
|
|
|
|
* Overload if your parser needs to support parsing the same file
|
|
|
|
* several times, so you can clean up the internal state of the
|
|
|
|
* parser before each parse.
|
|
|
|
*/
|
|
|
|
virtual void cleanup() {}
|
|
|
|
|
2008-08-09 14:15:34 +00:00
|
|
|
Common::List<XMLKeyLayout*> _layoutList;
|
2008-07-30 14:08:07 +00:00
|
|
|
|
|
|
|
private:
|
2008-09-05 14:48:47 +00:00
|
|
|
char _char;
|
|
|
|
SeekableReadStream *_stream;
|
2008-06-25 17:56:00 +00:00
|
|
|
Common::String _fileName;
|
2008-06-18 23:49:47 +00:00
|
|
|
|
|
|
|
ParserState _state; /** Internal state of the parser */
|
|
|
|
|
|
|
|
Common::String _error; /** Current error message */
|
|
|
|
Common::String _token; /** Current text token */
|
|
|
|
|
2008-07-03 19:32:57 +00:00
|
|
|
Common::Stack<ParserNode*> _activeKey; /** Node stack of the parsed keys */
|
2008-06-18 23:49:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|