Added daisychain methods to easily create more complex parameter constraints

This commit is contained in:
Leonetienne
2021-09-05 12:56:34 +02:00
parent 93746d40cf
commit b45e305122
4 changed files with 159 additions and 10 deletions

View File

@@ -22,6 +22,17 @@ namespace Hazelnp
return pc;
}
//! Daisychain-method. Will add a the "required-argument" aspect.
//! Think of the default value like of a list ofparameters. Like {"--width", "800"}
ParamConstraint AddRequire(const std::initializer_list<std::string>& defaultValue = {}, bool required = true)
{
ParamConstraint pc = *this;
pc.defaultValue = defaultValue;
pc.required = required;
return pc;
}
//! Constructs a type-safety constraint
static ParamConstraint TypeSafety(DATA_TYPE requiredType, bool constrainType = true)
{
@@ -32,6 +43,17 @@ namespace Hazelnp
return pc;
}
//! Daisychain-method. Will add a the "type-safety" aspect.
//! Constructs a type-safety constraint
ParamConstraint AddTypeSafety(DATA_TYPE requiredType, bool constrainType = true)
{
ParamConstraint pc = *this;
pc.constrainType = constrainType;
pc.requiredType = requiredType;
return pc;
}
//! Constructs an incompatibility constraint.
//! This means, that the following parameters are NOT compatible with this one and will throw an error if passed together
static ParamConstraint Incompatibility(const std::initializer_list<std::string>& incompatibleParameters)
@@ -53,6 +75,17 @@ namespace Hazelnp
return pc;
}
//! Daisychain-method. Will add a the "incompatiblity" aspect.
//! This means, that the following parameters are NOT compatible with this one and will throw an error if passed together.
//! Syntactical-sugar proxy method that will convert the lonely string to an initializer list for you :3
ParamConstraint AddIncompatibility(const std::string& incompatibleParameters)
{
ParamConstraint pc = *this;
pc.incompatibleParameters = { incompatibleParameters };
return pc;
}
//! Whole constructor
ParamConstraint(bool constrainType, DATA_TYPE requiredType, const std::initializer_list<std::string>& defaultValue, bool required, const std::initializer_list<std::string>& incompatibleParameters)
:

View File

@@ -1,2 +1,2 @@
#pragma once
#define HAZELNUPP_VERSION (1.11)
#define HAZELNUPP_VERSION (1.12)