Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
IntegerInterval.cpp
Go to the documentation of this file.
1#include "IntegerInterval.h"
2
3#include <iostream>
4#include <string>
5
8
9bool starts_with(const std::string& s1, const std::string& s2) {
10 return s2.size() <= s1.size() && s1.compare(0, s2.size(), s2) == 0;
11}
12
13namespace storm {
14namespace storage {
15IntegerInterval parseIntegerInterval(std::string const& stringRepr) {
16 if (starts_with(stringRepr, "[") && stringRepr.at(stringRepr.size() - 1) == ']') {
17 auto split = stringRepr.find(",");
18 std::string first = stringRepr.substr(1, split - 1);
19
20 std::string second = stringRepr.substr(split + 1, stringRepr.size() - split - 2);
21 return IntegerInterval(stoi(first), stoi(second));
22
23 } else {
24 STORM_LOG_THROW(false, storm::exceptions::InvalidArgumentException, "Cannot parse " << stringRepr << " as integer interval");
25 }
26}
27} // namespace storage
28} // namespace storm
bool starts_with(const std::string &s1, const std::string &s2)
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
IntegerInterval parseIntegerInterval(std::string const &stringRepr)
LabParser.cpp.
Definition cli.cpp:18