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