17template<
typename ValueType>
21 char const* buf = file.
getData();
24 std::vector<ValueType> stateRewards(stateCount);
27 uint_fast64_t state = 0;
28 uint_fast64_t lastState = (uint_fast64_t)-1;
29 uint_fast64_t
const startIndexComparison = lastState;
33 while (buf[0] !=
'\0') {
40 if (state <= lastState && lastState != startIndexComparison) {
41 STORM_LOG_ERROR(
"Error while parsing " << filename <<
": State " << state <<
" was found but has already been read or skipped previously.");
42 throw storm::exceptions::WrongFormatException()
43 <<
"Error while parsing " << filename <<
": State " << state <<
" was found but has already been read or skipped previously.";
46 if (stateCount <= state) {
47 STORM_LOG_ERROR(
"Error while parsing " << filename <<
": Found reward for a state of an invalid index \"" << state <<
"\". The model has only "
48 << stateCount <<
" states.");
49 throw storm::exceptions::OutOfRangeException()
50 <<
"Error while parsing " << filename <<
": Found reward for a state of an invalid index \"" << state <<
"\"";
57 STORM_LOG_ERROR(
"Error while parsing " << filename <<
": Expected positive reward value but got \"" << reward <<
"\".");
58 throw storm::exceptions::WrongFormatException() <<
"Error while parsing " << filename <<
": State reward file specifies illegal reward value.";
61 stateRewards[state] = reward;
Opens a file and maps it to memory providing a char* containing the file content.
char const * getData() const
Returns a pointer to the beginning of the mapped file data.
A class providing the functionality to parse a the state rewards of a model.
static std::vector< ValueType > parseSparseStateReward(uint_fast64_t stateCount, std::string const &filename)
Reads a state reward file and puts the result in a state reward vector.
#define STORM_LOG_ERROR(message)
double checked_strtod(char const *str, char const **end)
Calls strtod() internally and checks if the new pointer is different from the original one,...
uint_fast64_t checked_strtol(char const *str, char const **end)
Calls strtol() internally and checks if the new pointer is different from the original one,...
char const * trimWhitespaces(char const *buf)
Skips spaces, tabs, newlines and carriage returns.