added support for includes

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@31 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-19 13:42:20 +00:00
parent ba4785ac49
commit 89aa0254ab
4 changed files with 73 additions and 14 deletions
+19 -1
View File
@@ -9,10 +9,11 @@
#include "reader.hpp"
#include <util/vector2d.hpp>
#include <util/error.hpp>
#include <util/io/package_manager.hpp>
// ----------------------------------------------------------------------------- : Reader
Reader::Reader(const InputStreamP& input, String filename)
Reader::Reader(const InputStreamP& input, const String& filename)
: input(input), filename(filename), line_number(0)
, indent(0), expected_indent(0), just_opened(false)
, stream(*input)
@@ -20,6 +21,16 @@ Reader::Reader(const InputStreamP& input, String filename)
moveNext();
}
Reader::Reader(const String& filename)
: input(packages.openFileFromPackage(filename))
, filename(filename), line_number(0)
, indent(0), expected_indent(0), just_opened(false)
, stream(*input)
{
moveNext();
}
void Reader::warning(const String& msg) {
wxMessageBox((msg + _("\nOn line: ")) << line_number << _("\nIn file: ") << filename, _("Warning"), wxOK | wxICON_EXCLAMATION);
}
@@ -84,6 +95,13 @@ void Reader::readLine() {
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
}
void Reader::unknownKey() {
warning(_("Unexpected key: '") + key + _("'"));
do {
moveNext();
} while (indent > expected_indent);
}
// ----------------------------------------------------------------------------- : Handling basic types
template <> void Reader::handle(String& s) {