| 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:
[legend]

## Public Member Functions
| ParamConstraint ()=default
| Empty constructor. More...
| ParamConstraint (bool constrainType, DATA_TYPE requiredType, const std::vector< std::string > &defaultValue, bool required)
| Whole constructor. More...

## Static Public Member Functions
static ParamConstraint | Require (const std::vector< 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...

## 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...

## 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::vector< std::string > & | defaultValue,
|  | bool | required
| ) |  |
| inline

Whole constructor.

Definition at line 36 of file ParamConstraint.h.

37 :
38 constrainType{ constrainType },
39 requiredType{ requiredType },
40 defaultValue{ defaultValue },
41 required{ required }
42 {
43 return;
44 }

## Member Function Documentation

## ◆ Require()

static ParamConstraint Hazelnp::ParamConstraint::Require | ( | const std::vector< std::string > & | defaultValue = `{}`,
|  | bool | required = `true`
| ) |  |
| inline static

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 }

## ◆ TypeSafety()

static ParamConstraint Hazelnp::ParamConstraint::TypeSafety | ( | DATA_TYPE | requiredType,
|  | bool | constrainType = `true`
| ) |  |
| inline static

Constructs a type-safety constraint.

Definition at line 26 of file ParamConstraint.h.

27 {
28 ParamConstraint pc;
29 pc.constrainType = constrainType;
30 pc.requiredType = requiredType;
31
32 return pc;
33 }

## Friends And Related Function Documentation

## ◆ CmdArgsInterface

friend class CmdArgsInterface
| friend

Definition at line 67 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 48 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 56 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 60 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 51 of file ParamConstraint.h.

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

- Hazelnupp/ParamConstraint.h

Hazelnp::ParamConstraint::requiredType
DATA_TYPE requiredType
Constrain the parameter to this value. Requires constrainType to be set to true.
Definition: ParamConstraint.h:51
Hazelnp::ParamConstraint::constrainType
bool constrainType
Should this parameter be forced to be of a certain type? Remember to set constrainTo to the wanted ...
Definition: ParamConstraint.h:48
Hazelnp::ParamConstraint::ParamConstraint
ParamConstraint()=default
Empty constructor.
Hazelnp::ParamConstraint::required
bool required
If set to true, and no default value set, an error will be produced if this parameter is not supplied...
Definition: ParamConstraint.h:60
Hazelnp::ParamConstraint::defaultValue
std::vector< std::string > defaultValue
The default value for this parameter.
Definition: ParamConstraint.h:56