Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
ArgumentValidators.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6
7#include <boost/optional.hpp>
8
9namespace storm {
10namespace settings {
11
12template<typename ValueType>
14 public:
15 virtual ~ArgumentValidator() = default;
16
20 virtual bool isValid(ValueType const& value) = 0;
21
25 virtual std::string toString() const = 0;
26};
27
28template<typename ValueType>
29class RangeArgumentValidator : public ArgumentValidator<ValueType> {
30 public:
31 RangeArgumentValidator(boost::optional<ValueType> const& lower, boost::optional<ValueType> const& upper, bool lowerIncluded, bool upperIncluded);
32
33 virtual bool isValid(ValueType const& value) override;
34 virtual std::string toString() const override;
35
36 private:
37 boost::optional<ValueType> lower;
38 boost::optional<ValueType> upper;
39 bool lowerIncluded;
40 bool upperIncluded;
41};
42
43class FileValidator : public ArgumentValidator<std::string> {
44 public:
45 enum class Mode { Exists, Writable };
46
47 FileValidator(Mode mode);
48
49 virtual bool isValid(std::string const& value) override;
50 virtual std::string toString() const override;
51
52 private:
53 Mode mode;
54};
55
56class MultipleChoiceValidator : public ArgumentValidator<std::string> {
57 public:
58 MultipleChoiceValidator(std::vector<std::string> const& legalValues);
59
60 virtual bool isValid(std::string const& value) override;
61 virtual std::string toString() const override;
62
63 private:
64 std::vector<std::string> legalValues;
65};
66
68 public:
69 static std::shared_ptr<ArgumentValidator<int64_t>> createIntegerRangeValidatorExcluding(int_fast64_t lowerBound, int_fast64_t upperBound);
70 static std::shared_ptr<ArgumentValidator<uint64_t>> createUnsignedRangeValidatorExcluding(uint64_t lowerBound, uint64_t upperBound);
71 static std::shared_ptr<ArgumentValidator<uint64_t>> createUnsignedRangeValidatorIncluding(uint64_t lowerBound, uint64_t upperBound);
72 static std::shared_ptr<ArgumentValidator<double>> createDoubleRangeValidatorExcluding(double lowerBound, double upperBound);
73
74 static std::shared_ptr<ArgumentValidator<double>> createDoubleRangeValidatorIncluding(double lowerBound, double upperBound);
75
76 static std::shared_ptr<ArgumentValidator<int64_t>> createIntegerGreaterValidator(int_fast64_t lowerBound);
77 static std::shared_ptr<ArgumentValidator<uint64_t>> createUnsignedGreaterValidator(uint64_t lowerBound);
78 static std::shared_ptr<ArgumentValidator<double>> createDoubleGreaterValidator(double lowerBound);
79
80 static std::shared_ptr<ArgumentValidator<int64_t>> createIntegerGreaterEqualValidator(int_fast64_t lowerBound);
81 static std::shared_ptr<ArgumentValidator<uint64_t>> createUnsignedGreaterEqualValidator(uint64_t lowerBound);
82 static std::shared_ptr<ArgumentValidator<double>> createDoubleGreaterEqualValidator(double lowerBound);
83
84 static std::shared_ptr<ArgumentValidator<std::string>> createExistingFileValidator();
85 static std::shared_ptr<ArgumentValidator<std::string>> createWritableFileValidator();
86
87 static std::shared_ptr<ArgumentValidator<std::string>> createMultipleChoiceValidator(std::vector<std::string> const& choices);
88
89 private:
90 template<typename ValueType>
91 static std::shared_ptr<ArgumentValidator<ValueType>> createRangeValidatorExcluding(ValueType lowerBound, ValueType upperBound);
92
93 template<typename ValueType>
94 static std::shared_ptr<ArgumentValidator<ValueType>> createRangeValidatorIncluding(ValueType lowerBound, ValueType upperBound);
95
96 template<typename ValueType>
97 static std::shared_ptr<ArgumentValidator<ValueType>> createGreaterValidator(ValueType lowerBound, bool equalAllowed);
98};
99
100} // namespace settings
101} // namespace storm
static std::shared_ptr< ArgumentValidator< uint64_t > > createUnsignedRangeValidatorIncluding(uint64_t lowerBound, uint64_t upperBound)
static std::shared_ptr< ArgumentValidator< uint64_t > > createUnsignedRangeValidatorExcluding(uint64_t lowerBound, uint64_t upperBound)
static std::shared_ptr< ArgumentValidator< double > > createDoubleRangeValidatorExcluding(double lowerBound, double upperBound)
static std::shared_ptr< ArgumentValidator< double > > createDoubleGreaterValidator(double lowerBound)
static std::shared_ptr< ArgumentValidator< uint64_t > > createUnsignedGreaterValidator(uint64_t lowerBound)
static std::shared_ptr< ArgumentValidator< int64_t > > createIntegerGreaterEqualValidator(int_fast64_t lowerBound)
static std::shared_ptr< ArgumentValidator< int64_t > > createIntegerGreaterValidator(int_fast64_t lowerBound)
static std::shared_ptr< ArgumentValidator< double > > createDoubleGreaterEqualValidator(double lowerBound)
static std::shared_ptr< ArgumentValidator< uint64_t > > createUnsignedGreaterEqualValidator(uint64_t lowerBound)
static std::shared_ptr< ArgumentValidator< std::string > > createMultipleChoiceValidator(std::vector< std::string > const &choices)
static std::shared_ptr< ArgumentValidator< std::string > > createExistingFileValidator()
static std::shared_ptr< ArgumentValidator< int64_t > > createIntegerRangeValidatorExcluding(int_fast64_t lowerBound, int_fast64_t upperBound)
static std::shared_ptr< ArgumentValidator< double > > createDoubleRangeValidatorIncluding(double lowerBound, double upperBound)
static std::shared_ptr< ArgumentValidator< std::string > > createWritableFileValidator()
virtual std::string toString() const =0
Retrieves a string representation of the valid values.
virtual bool isValid(ValueType const &value)=0
Checks whether the argument passes the validation.
virtual ~ArgumentValidator()=default
virtual std::string toString() const override
Retrieves a string representation of the valid values.
virtual bool isValid(std::string const &value) override
Checks whether the argument passes the validation.
virtual bool isValid(std::string const &value) override
Checks whether the argument passes the validation.
virtual std::string toString() const override
Retrieves a string representation of the valid values.
virtual bool isValid(ValueType const &value) override
Checks whether the argument passes the validation.
virtual std::string toString() const override
Retrieves a string representation of the valid values.
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18