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

#include <ParamConstraint.h>

Collaboration diagram for ParamConstraint:
Collaboration graph
[legend]

Public Member Functions

 ParamConstraint ()=default
 Empty constructor. More...
 
 ParamConstraint (const std::string &key, bool constrainType, DATA_TYPE wantedType, const std::vector< std::string > &defaultValue, bool required)
 Whole constructor. More...
 

Static Public Member Functions

static ParamConstraint Require (const std::string &key, const std::vector< std::string > &defaultValue={}, bool required=true)
 Constructs a require constraint. More...
 
static ParamConstraint TypeSafety (const std::string &key, DATA_TYPE wantedType, bool constrainType=true)
 Constructs a type-safety constraint. More...
 

Public Attributes

std::string key
 The key of the parameter to constrain. More...
 
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 wantedType = 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...
 

Detailed Description

Definition at line 6 of file ParamConstraint.h.

Constructor & Destructor Documentation

◆ ParamConstraint() [1/2]

ParamConstraint::ParamConstraint ( )
default

Empty constructor.

◆ ParamConstraint() [2/2]

ParamConstraint::ParamConstraint ( const std::string &  key,
bool  constrainType,
DATA_TYPE  wantedType,
const std::vector< std::string > &  defaultValue,
bool  required 
)
inline

Whole constructor.

Definition at line 36 of file ParamConstraint.h.

37  :
38  key { key },
43  {
44  return;
45  }

Member Function Documentation

◆ Require()

static ParamConstraint ParamConstraint::Require ( const std::string &  key,
const std::vector< 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 14 of file ParamConstraint.h.

14  {}, bool required = true)
15  {
16  ParamConstraint pc;
17  pc.key = key;
19  pc.required = required;
20 
21  return pc;
22  }

◆ TypeSafety()

static ParamConstraint ParamConstraint::TypeSafety ( const std::string &  key,
DATA_TYPE  wantedType,
bool  constrainType = true 
)
inlinestatic

Constructs a type-safety constraint.

Definition at line 25 of file ParamConstraint.h.

26  {
27  ParamConstraint pc;
28  pc.key = key;
31 
32  return pc;
33  }

Member Data Documentation

◆ constrainType

bool 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 52 of file ParamConstraint.h.

◆ defaultValue

std::vector<std::string> 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 60 of file ParamConstraint.h.

◆ key

std::string ParamConstraint::key

The key of the parameter to constrain.

Definition at line 48 of file ParamConstraint.h.

◆ required

bool 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 64 of file ParamConstraint.h.

◆ wantedType

DATA_TYPE ParamConstraint::wantedType = DATA_TYPE::VOID

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

Definition at line 55 of file ParamConstraint.h.


The documentation for this struct was generated from the following file:
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:64
ParamConstraint::defaultValue
std::vector< std::string > defaultValue
The default value for this parameter.
Definition: ParamConstraint.h:60
ParamConstraint::key
std::string key
The key of the parameter to constrain.
Definition: ParamConstraint.h:48
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:52
ParamConstraint::wantedType
DATA_TYPE wantedType
Constrain the parameter to this value. Requires constrainType to be set to true.
Definition: ParamConstraint.h:55
ParamConstraint
Definition: ParamConstraint.h:6