Commit 019077cc authored by twanvl's avatar twanvl

Working on installer packages;

Nicer warnings about using spaces for indentation
parent 3babaadb
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/installer.hpp>
#include <script/to_value.hpp>
// ----------------------------------------------------------------------------- : Installer
String Installer::typeName() const { return _("installer"); }
IMPLEMENT_REFLECTION(Installer) {
REFLECT_BASE(Packaged);
REFLECT(packages);
}
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_INSTALLER
#define HEADER_DATA_INSTALLER
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/io/package.hpp>
// ----------------------------------------------------------------------------- : Installer
/// A package that contains other packages that can be installed
class Installer : public Packaged {
public:
String prefered_filename; ///< What filename should be used (by default)
vector<String> packages; ///< Packages to install
/// Install all the packages
void install();
/// Add a package to the installer (if it is not already added).
/** The first package gives the name of the installer.
*/
void addPackage(const Packaged& package);
protected:
String typeName() const;
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : EOF
#endif
......@@ -1636,6 +1636,12 @@
<File
RelativePath=".\data\font.hpp">
</File>
<File
RelativePath=".\data\installer.cpp">
</File>
<File
RelativePath=".\data\installer.hpp">
</File>
<File
RelativePath=".\data\keyword.cpp">
</File>
......@@ -2933,10 +2939,10 @@
RelativePath="..\conversion-todo.txt">
</File>
<File
RelativePath="..\data\nl.mse-locale\locale">
RelativePath="..\data\en.mse-locale\locale">
</File>
<File
RelativePath="..\data\en.mse-locale\locale">
RelativePath="..\data\nl.mse-locale\locale">
</File>
<File
RelativePath=".\main.cpp">
......
......@@ -28,11 +28,6 @@ String IncludePackage::typeName() const { return _("include"); }
IMPLEMENT_REFLECTION(IncludePackage) {
REFLECT_BASE(Packaged);
REFLECT_IF_READING {
// ingore
String version;
REFLECT(version);
}
}
// ----------------------------------------------------------------------------- : PackageManager
......
......@@ -100,7 +100,7 @@ void Reader::moveNext() {
}
}
void Reader::readLine() {
void Reader::readLine(bool in_string) {
// fix UTF8 in ascii builds; skip BOM
line = decodeUTF8BOM(stream.ReadLine());
line_number += 1;
......@@ -121,7 +121,16 @@ void Reader::readLine() {
indent = -1;
return;
}
key = cannocial_name_form(trim(line.substr(indent, pos - indent)));
key = line.substr(indent, pos - indent);
if (!in_string && starts_with(key, _(" "))) {
warning(_("key: '") + key + _("' starts with a space; only use TABs for indentation!"));
// try to fix up: 8 spaces is a tab
while (starts_with(key, _(" "))) {
key = key.substr(8);
indent += 1;
}
}
key = cannocial_name_form(trim(key));
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
}
......@@ -177,7 +186,7 @@ const String& Reader::getValue() {
if (!first) multi_line_str += _('\n');
first = false;
multi_line_str += line.substr(expected_indent); // strip expected indent
readLine();
readLine(true);
}
// moveNext(), but without emptying multi_line_str
just_opened = false;
......
......@@ -151,7 +151,7 @@ class Reader {
/// Move to the next non empty line
void moveNext();
/// Reads the next line from the input, and stores it in line/key/value/indent
void readLine();
void readLine(bool in_string = false);
/// Return the value on the current line
const String& getValue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment