Commit 4eadae9c authored by twanvl's avatar twanvl

Added compact syntax for package dependencies:

  "depends on: package version"
parent c81123a3
...@@ -5,13 +5,17 @@ Data type: dependency ...@@ -5,13 +5,17 @@ Data type: dependency
[[type:Package]]s can depend on other packages. [[type:Package]]s can depend on other packages.
For example a [[type:stylesheet]] needs a particular version of the corresponding [[type:game]] package, and maybe some additional [[type:include]]s. For example a [[type:stylesheet]] needs a particular version of the corresponding [[type:game]] package, and maybe some additional [[type:include]]s.
--Proeprties-- --Properties--
! Property Type Description ! Property Type Description
| @package@ [[type:string]] Filename of the package this package depends on. | @package@ [[type:string]] Filename of the package this package depends on.
| @version@ [[type:version]] Minimal version of that package that is required. | @version@ [[type:version]] Minimal version of that package that is required.
The two properties can also be written on a single line, separated by a space (see the examples).
--Example-- --Example--
The magic-new stylesheet depends on a particular version of the game file: The magic-new stylesheet depends on a particular version of the game file:
>depends on: >depends on:
> package: magic.mse-game > package: magic.mse-game
> version: 2007-06-06 > version: 2007-06-06
This can be written more compactly as
>depends on: magic.mse-game 2007-06-06
...@@ -615,6 +615,12 @@ ...@@ -615,6 +615,12 @@
<File <File
RelativePath=".\gui\control\package_list.hpp"> RelativePath=".\gui\control\package_list.hpp">
</File> </File>
<File
RelativePath=".\gui\control\tree_list.cpp">
</File>
<File
RelativePath=".\gui\control\tree_list.hpp">
</File>
<Filter <Filter
Name="card_list" Name="card_list"
Filter=""> Filter="">
......
...@@ -436,9 +436,25 @@ String Package::toStandardName(const String& name) { ...@@ -436,9 +436,25 @@ String Package::toStandardName(const String& name) {
// ----------------------------------------------------------------------------- : Packaged // ----------------------------------------------------------------------------- : Packaged
IMPLEMENT_REFLECTION(PackageDependency) { template <> void Reader::handle(PackageDependency& dep) {
REFLECT(package); if (!isComplex()) {
REFLECT(version); handle(dep.package);
size_t pos = dep.package.find_first_of(_(' '));
if (pos != String::npos) {
dep.version = Version::fromString(dep.package.substr(pos+1));
dep.package = dep.package.substr(0,pos);
}
} else {
handle(_("package"), dep.package);
handle(_("version"), dep.version);
}
}
template <> void Writer::handle(const PackageDependency& dep) {
if (dep.version != Version()) {
handle(dep.package + _(" ") + dep.version.toString());
} else {
handle(dep.package);
}
} }
// note: reflection must be declared before it is used // note: reflection must be declared before it is used
......
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