Browse Source
Added functions responsible for printing the help. Started adapting the tests to the new option system.
Added functions responsible for printing the help. Started adapting the tests to the new option system.
Former-commit-id: 0407d8223e
tempestpy_adaptions
dehnert
10 years ago
38 changed files with 763 additions and 288 deletions
-
2src/counterexamples/MILPMinimalLabelSetGenerator.h
-
4src/settings/Argument.h
-
76src/settings/ArgumentBase.cpp
-
48src/settings/ArgumentBase.h
-
17src/settings/ArgumentType.cpp
-
12src/settings/ArgumentType.h
-
37src/settings/ArgumentTypeInferationHelper.cpp
-
87src/settings/Option.cpp
-
21src/settings/Option.h
-
6src/settings/OptionBuilder.h
-
152src/settings/SettingsManager.cpp
-
94src/settings/SettingsManager.h
-
8src/settings/modules/CuddSettings.cpp
-
2src/settings/modules/DebugSettings.cpp
-
7src/settings/modules/GeneralSettings.cpp
-
10src/settings/modules/GeneralSettings.h
-
12src/settings/modules/GlpkSettings.cpp
-
56src/settings/modules/GmmxxEquationSolverSettings.cpp
-
18src/settings/modules/GurobiSettings.cpp
-
55src/settings/modules/ModuleSettings.cpp
-
16src/settings/modules/ModuleSettings.h
-
28src/settings/modules/NativeEquationSolverSettings.cpp
-
5src/settings/modules/NativeEquationSolverSettings.h
-
2src/storm.cpp
-
4src/utility/CLI.h
-
18test/functional/modelchecker/ActionTest.cpp
-
4test/functional/modelchecker/FilterTest.cpp
-
40test/functional/modelchecker/GmmxxDtmcPrctlModelCheckerTest.cpp
-
38test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp
-
6test/functional/parser/DeterministicSparseTransitionParserTest.cpp
-
6test/functional/parser/MarkovAutomatonSparseTransitionParserTest.cpp
-
6test/functional/parser/NondeterministicSparseTransitionParserTest.cpp
-
24test/functional/solver/GlpkLpSolverTest.cpp
-
68test/functional/solver/GmmxxLinearEquationSolverTest.cpp
-
14test/functional/solver/GmmxxNondeterministicLinearEquationSolverTest.cpp
-
8test/functional/solver/NativeLinearEquationSolverTest.cpp
-
14test/functional/solver/NativeNondeterministicLinearEquationSolverTest.cpp
-
26test/functional/storm-functional-tests.cpp
@ -0,0 +1,76 @@ |
|||
#include "src/settings/ArgumentBase.h"
|
|||
|
|||
#include <iomanip>
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
uint_fast64_t ArgumentBase::getPrintLength() const { |
|||
return this->getName().length() + 2; |
|||
} |
|||
|
|||
std::ostream& operator<<(std::ostream& out, ArgumentBase const& argument) { |
|||
std::streamsize width = out.width(); |
|||
uint_fast64_t charactersPrinted = 0; |
|||
out << std::setw(0) << std::left << "<" << argument.getName() << "> "; |
|||
charactersPrinted += 2 + argument.getName().length(); |
|||
|
|||
for (uint_fast64_t i = charactersPrinted; i < width; ++i) { |
|||
out << out.fill(); |
|||
} |
|||
|
|||
out << "\t" << argument.getDescription(); |
|||
return out; |
|||
} |
|||
|
|||
template <typename TargetType> |
|||
TargetType ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful) { |
|||
std::istringstream stream(valueAsString); |
|||
TargetType t; |
|||
conversionSuccessful = (stream >> t) && (stream >> std::ws).eof(); |
|||
return t; |
|||
} |
|||
|
|||
template <> |
|||
bool ArgumentBase::convertFromString<bool>(std::string const& s, bool& ok) { |
|||
static const std::string lowerTrueString = "true"; |
|||
static const std::string lowerFalseString = "false"; |
|||
static const std::string lowerYesString = "yes"; |
|||
static const std::string lowerNoString = "no"; |
|||
|
|||
std::string lowerInput = boost::algorithm::to_lower_copy(s); |
|||
|
|||
if (s.compare(lowerTrueString) == 0 || s.compare(lowerYesString) == 0) { |
|||
ok = true; |
|||
return true; |
|||
} else if (s.compare(lowerFalseString) == 0 || s.compare(lowerNoString) == 0) { |
|||
ok = true; |
|||
return false; |
|||
} |
|||
|
|||
std::istringstream stream(s); |
|||
bool t; |
|||
ok = (stream >> t) && (stream >> std::ws).eof(); |
|||
return t; |
|||
} |
|||
|
|||
template <typename ValueType> |
|||
std::string ArgumentBase::convertToString(ValueType const& value) { |
|||
std::ostringstream stream; |
|||
stream << value; |
|||
return stream.str(); |
|||
} |
|||
|
|||
// Explicitly instantiate the templates.
|
|||
template std::string ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); |
|||
template int_fast64_t ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); |
|||
template uint_fast64_t ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); |
|||
template double ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); |
|||
template bool ArgumentBase::convertFromString(std::string const& valueAsString, bool& conversionSuccessful); |
|||
|
|||
template std::string ArgumentBase::convertToString(std::string const& value); |
|||
template std::string ArgumentBase::convertToString(int_fast64_t const& value); |
|||
template std::string ArgumentBase::convertToString(uint_fast64_t const& value); |
|||
template std::string ArgumentBase::convertToString(double const& value); |
|||
template std::string ArgumentBase::convertToString(bool const& value); |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
#include "src/settings/ArgumentType.h"
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
std::ostream& operator<<(std::ostream& out, ArgumentType& argumentType) { |
|||
switch (argumentType) { |
|||
case ArgumentType::String: out << "string"; break; |
|||
case ArgumentType::Integer: out << "integer"; break; |
|||
case ArgumentType::UnsignedInteger: out << "unsigned integer"; break; |
|||
case ArgumentType::Double: out << "double"; break; |
|||
case ArgumentType::Boolean: out << "boolean"; break; |
|||
} |
|||
|
|||
return out; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,87 @@ |
|||
#include "src/settings/Option.h"
|
|||
|
|||
#include <iomanip>
|
|||
|
|||
namespace storm { |
|||
namespace settings { |
|||
uint_fast64_t Option::getPrintLength() const { |
|||
uint_fast64_t length = 2; |
|||
if (!this->getRequiresModulePrefix()) { |
|||
length += 2; |
|||
} |
|||
length += this->getModuleName().length() + 1; |
|||
length += this->getLongName().length(); |
|||
if (this->getHasShortName()) { |
|||
length += 4; |
|||
if (!this->getRequiresModulePrefix()) { |
|||
length += 2; |
|||
} |
|||
length += this->getModuleName().length() + 1; |
|||
length += this->getShortName().length(); |
|||
} |
|||
return length; |
|||
} |
|||
|
|||
std::vector<std::shared_ptr<ArgumentBase>> const& Option::getArguments() const { |
|||
return this->arguments; |
|||
} |
|||
|
|||
std::ostream& operator<<(std::ostream& out, Option const& option) { |
|||
std::streamsize width = out.width(); |
|||
|
|||
uint_fast64_t charactersPrinted = 0; |
|||
out << std::setw(0) << "--"; |
|||
charactersPrinted += 2; |
|||
if (!option.getRequiresModulePrefix()) { |
|||
out << "["; |
|||
++charactersPrinted; |
|||
} |
|||
out << option.getModuleName() << ":"; |
|||
charactersPrinted += option.getModuleName().length() + 1; |
|||
if (!option.getRequiresModulePrefix()) { |
|||
out << "]"; |
|||
++charactersPrinted; |
|||
} |
|||
out << option.getLongName(); |
|||
charactersPrinted += option.getLongName().length(); |
|||
if (option.getHasShortName()) { |
|||
out << " | -"; |
|||
charactersPrinted += 4; |
|||
if (!option.getRequiresModulePrefix()) { |
|||
out << "["; |
|||
++charactersPrinted; |
|||
} |
|||
out << option.getModuleName() << ":"; |
|||
charactersPrinted += option.getModuleName().length() + 1; |
|||
if (!option.getRequiresModulePrefix()) { |
|||
out << "]"; |
|||
++charactersPrinted; |
|||
} |
|||
out << option.getShortName(); |
|||
charactersPrinted += option.getShortName().length(); |
|||
} |
|||
|
|||
// Now fill the width.
|
|||
for (uint_fast64_t i = charactersPrinted; i < width; ++i) { |
|||
out << out.fill(); |
|||
} |
|||
|
|||
out << "\t" << option.getDescription(); |
|||
|
|||
if (option.getArgumentCount() > 0) { |
|||
// Start by determining the longest print length of the arguments.
|
|||
uint_fast64_t maxLength = 0; |
|||
for (auto const& argument : option.getArguments()) { |
|||
maxLength = std::max(maxLength, argument->getPrintLength()); |
|||
} |
|||
|
|||
for (auto const& argument : option.getArguments()) { |
|||
out << std::endl; |
|||
out << "\t* " << std::setw(maxLength) << std::left << *argument; |
|||
} |
|||
} |
|||
|
|||
return out; |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue