Make extension optional in --export command.

Added add_extension function
Added ExportTemplate::byName
Use ExportTemplate::byName in main
This commit is contained in:
Twan van Laarhoven
2020-04-21 00:23:42 +02:00
parent 59d59e97fd
commit e8e7e10fa0
5 changed files with 25 additions and 3 deletions
+5
View File
@@ -11,6 +11,7 @@
#include <data/game.hpp>
#include <data/set.hpp>
#include <data/field.hpp>
#include <util/io/package_manager.hpp>
// ----------------------------------------------------------------------------- : Export template, basics
@@ -19,6 +20,10 @@ ExportTemplate::ExportTemplate()
, create_directory(false)
{}
ExportTemplateP ExportTemplate::byName(const String& name) {
return package_manager.open<ExportTemplate>(add_extension(name, _(".mse-export-template")));
}
String ExportTemplate::typeNameStatic() { return _("export-template"); }
String ExportTemplate::typeName() const { return _("export-template"); }
Version ExportTemplate::fileVersion() const { return file_version_export_template; }
+4 -2
View File
@@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(Package);
/// A template for exporting sets to HTML or text format
class ExportTemplate : public Packaged {
public:
public:
ExportTemplate();
GameP game; ///< Game this template is for
@@ -38,7 +38,9 @@ class ExportTemplate : public Packaged {
virtual String typeName() const;
Version fileVersion() const;
virtual void validate(Version = app_version);
private:
/// Loads the export template with a particular name
static ExportTemplateP byName(const String & name);
private:
DECLARE_REFLECTION();
};