Leonetienne/Hazelnupp
Simple, easy to use, command line parameter interface
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
Hazelnp::ParamConstraint Struct Reference

#include <ParamConstraint.h>

Collaboration diagram for Hazelnp::ParamConstraint:
Collaboration graph
[legend]

Public Member Functions

 ParamConstraint ()=default
 Empty constructor. More...
 
ParamConstraint AddRequire (const std::initializer_list< std::string > &defaultValue={}, bool required=true)
 Daisychain-method. More...
 
ParamConstraint AddTypeSafety (DATA_TYPE requiredType, bool constrainType=true)
 Daisychain-method. More...
 
ParamConstraint AddIncompatibilities (const std::string &incompatibleParameters)
 Daisychain-method. More...
 
ParamConstraint AddIncompatibilities (const std::initializer_list< std::string > &incompatibleParameters)
 Daisychain-method. More...
 
 ParamConstraint (bool constrainType, DATA_TYPE requiredType, const std::initializer_list< std::string > &defaultValue, bool required, const std::initializer_list< std::string > &incompatibleParameters)
 Whole constructor. More...
 

Static Public Member Functions

static ParamConstraint Require (const std::initializer_list< std::string > &defaultValue={}, bool required=true)
 Constructs a require constraint. More...
 
static ParamConstraint TypeSafety (DATA_TYPE requiredType, bool constrainType=true)
 Constructs a type-safety constraint. More...
 
static ParamConstraint Incompatibility (const std::initializer_list< std::string > &incompatibleParameters)
 Constructs an incompatibility constraint. More...
 
static ParamConstraint Incompatibility (const std::string &incompatibleParameters)
 Constructs an incompatibility constraint. More...
 

Public Attributes

bool constrainType = false
 Should this parameter be forced to be of a certain type? Remember to set constrainTo to the wanted type. More...
 
DATA_TYPE requiredType = DATA_TYPE::VOID
 Constrain the parameter to this value. Requires constrainType to be set to true. More...
 
std::vector< std::string > defaultValue
 The default value for this parameter. More...
 
bool required = false
 If set to true, and no default value set, an error will be produced if this parameter is not supplied by the user. More...
 
std::vector< std::string > incompatibleParameters
 Parameters that are incompatible with this parameter. More...
 

Friends

class CmdArgsInterface
 

Detailed Description

Definition at line 8 of file ParamConstraint.h.

Constructor & Destructor Documentation

◆ ParamConstraint() [1/2]

Hazelnp::ParamConstraint::ParamConstraint ( )
default

Empty constructor.

◆ ParamConstraint() [2/2]

Hazelnp::ParamConstraint::ParamConstraint ( bool  constrainType,
DATA_TYPE  requiredType,
const std::initializer_list< std::string > &  defaultValue,
bool  required,
const std::initializer_list< std::string > &  incompatibleParameters 
)
inline

Whole constructor.

Definition at line 100 of file ParamConstraint.h.

101  :
105  required{ required },
107  {
108  return;
109  }
std::vector< std::string > incompatibleParameters
Parameters that are incompatible with this parameter.
std::vector< std::string > defaultValue
The default value for this parameter.
DATA_TYPE requiredType
Constrain the parameter to this value. Requires constrainType to be set to true.
bool required
If set to true, and no default value set, an error will be produced if this parameter is not supplied...
bool constrainType
Should this parameter be forced to be of a certain type? Remember to set constrainTo to the wanted ty...

Member Function Documentation

◆ AddIncompatibilities() [1/2]

ParamConstraint Hazelnp::ParamConstraint::AddIncompatibilities ( const std::string &  incompatibleParameters)
inline

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

Definition at line 81 of file ParamConstraint.h.

82  {
83  ParamConstraint pc = *this;
84  pc.incompatibleParameters = { incompatibleParameters };
85 
86  return pc;
87  }
std::vector< std::string > incompatibleParameters
Parameters that are incompatible with this parameter.
ParamConstraint()=default
Empty constructor.

◆ AddIncompatibilities() [2/2]

ParamConstraint Hazelnp::ParamConstraint::AddIncompatibilities ( const std::initializer_list< std::string > &  incompatibleParameters)
inline

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.

Definition at line 91 of file ParamConstraint.h.

92  {
93  ParamConstraint pc = *this;
94  pc.incompatibleParameters = incompatibleParameters;
95 
96  return pc;
97  }
std::vector< std::string > incompatibleParameters
Parameters that are incompatible with this parameter.
ParamConstraint()=default
Empty constructor.

◆ AddRequire()

ParamConstraint Hazelnp::ParamConstraint::AddRequire ( const std::initializer_list< std::string > &  defaultValue = {},
bool  required = true 
)
inline

Daisychain-method.

Will add a the "required-argument" aspect. Think of the default value like of a list ofparameters. Like {"--width", "800"}

Definition at line 27 of file ParamConstraint.h.

27  {}, bool required = true)
28  {
29  ParamConstraint pc = *this;
30  pc.defaultValue = defaultValue;
31  pc.required = required;
32 
33  return pc;
34  }
std::vector< std::string > defaultValue
The default value for this parameter.
bool required
If set to true, and no default value set, an error will be produced if this parameter is not supplied...
ParamConstraint()=default
Empty constructor.

◆ AddTypeSafety()

ParamConstraint Hazelnp::ParamConstraint::AddTypeSafety ( DATA_TYPE  requiredType,
bool  constrainType = true 
)
inline

Daisychain-method.

Will add a the "type-safety" aspect. Constructs a type-safety constraint

Definition at line 48 of file ParamConstraint.h.

49  {
50  ParamConstraint pc = *this;
51  pc.constrainType = constrainType;
52  pc.requiredType = requiredType;
53 
54  return pc;
55  }
DATA_TYPE requiredType
Constrain the parameter to this value. Requires constrainType to be set to true.
ParamConstraint()=default
Empty constructor.
bool constrainType
Should this parameter be forced to be of a certain type? Remember to set constrainTo to the wanted ty...

◆ Incompatibility() [1/2]

static ParamConstraint Hazelnp::ParamConstraint::Incompatibility ( const std::initializer_list< std::string > &  incompatibleParameters)
inlinestatic

Constructs an incompatibility constraint.

This means, that the following parameters are NOT compatible with this one and will throw an error if passed together

Definition at line 59 of file ParamConstraint.h.

60  {
61  ParamConstraint pc;
62  pc.incompatibleParameters = incompatibleParameters;
63 
64  return pc;
65  }
std::vector< std::string > incompatibleParameters
Parameters that are incompatible with this parameter.
ParamConstraint()=default
Empty constructor.

◆ Incompatibility() [2/2]

static ParamConstraint Hazelnp::ParamConstraint::Incompatibility ( const std::string &  incompatibleParameters)
inlinestatic

Constructs an incompatibility constraint.

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

Definition at line 70 of file ParamConstraint.h.

71  {
72  ParamConstraint pc;
73  pc.incompatibleParameters = { incompatibleParameters };
74 
75  return pc;
76  }
std::vector< std::string > incompatibleParameters
Parameters that are incompatible with this parameter.
ParamConstraint()=default
Empty constructor.

◆ Require()

static ParamConstraint Hazelnp::ParamConstraint::Require ( const std::initializer_list< std::string > &  defaultValue = {},
bool  required = true 
)
inlinestatic

Constructs a require constraint.

Think of the default value like of a list ofparameters. Like {"--width", "800"}

Definition at line 16 of file ParamConstraint.h.

16  {}, bool required = true)
17  {
18  ParamConstraint pc;
19  pc.defaultValue = defaultValue;
20  pc.required = required;
21 
22  return pc;
23  }
std::vector< std::string > defaultValue
The default value for this parameter.
bool required
If set to true, and no default value set, an error will be produced if this parameter is not supplied...
ParamConstraint()=default
Empty constructor.

◆ TypeSafety()

static ParamConstraint Hazelnp::ParamConstraint::TypeSafety ( DATA_TYPE  requiredType,
bool  constrainType = true 
)
inlinestatic

Constructs a type-safety constraint.

Definition at line 37 of file ParamConstraint.h.

38  {
39  ParamConstraint pc;
40  pc.constrainType = constrainType;
41  pc.requiredType = requiredType;
42 
43  return pc;
44  }
DATA_TYPE requiredType
Constrain the parameter to this value. Requires constrainType to be set to true.
ParamConstraint()=default
Empty constructor.
bool constrainType
Should this parameter be forced to be of a certain type? Remember to set constrainTo to the wanted ty...

Friends And Related Function Documentation

◆ CmdArgsInterface

friend class CmdArgsInterface
friend

Definition at line 135 of file ParamConstraint.h.

Member Data Documentation

◆ constrainType

bool Hazelnp::ParamConstraint::constrainType = false

Should this parameter be forced to be of a certain type? Remember to set constrainTo to the wanted type.

Definition at line 113 of file ParamConstraint.h.

◆ defaultValue

std::vector<std::string> Hazelnp::ParamConstraint::defaultValue

The default value for this parameter.

Gets applied if this parameter was not given. Think of this like a list of parameters. Like {"--width", "800"}

Definition at line 121 of file ParamConstraint.h.

◆ incompatibleParameters

std::vector<std::string> Hazelnp::ParamConstraint::incompatibleParameters

Parameters that are incompatible with this parameter.

Definition at line 128 of file ParamConstraint.h.

◆ required

bool Hazelnp::ParamConstraint::required = false

If set to true, and no default value set, an error will be produced if this parameter is not supplied by the user.

Definition at line 125 of file ParamConstraint.h.

◆ requiredType

DATA_TYPE Hazelnp::ParamConstraint::requiredType = DATA_TYPE::VOID

Constrain the parameter to this value. Requires constrainType to be set to true.

Definition at line 116 of file ParamConstraint.h.


The documentation for this struct was generated from the following file: