18inline void openFile(std::string
const& filepath, std::ofstream& filestream,
bool append =
false,
bool silent =
false) {
20 filestream.open(filepath, std::ios::app);
22 filestream.open(filepath);
24 STORM_LOG_THROW(filestream, storm::exceptions::FileIoException,
"Could not open file " << filepath <<
".");
25 filestream.precision(std::cout.precision());
37inline void openFile(std::string
const& filepath, std::ifstream& filestream) {
38 filestream.open(filepath);
39 STORM_LOG_THROW(filestream, storm::exceptions::FileIoException,
"Could not open file " << filepath <<
".");
68 std::ifstream filestream;
69 filestream.open(filename);
70 return filestream.good();
79template<
class CharT,
class Traits,
class Allocator>
80inline std::basic_istream<CharT, Traits>&
getline(std::basic_istream<CharT, Traits>& input, std::basic_string<CharT, Traits, Allocator>& str) {
81 auto& res = std::getline(input, str);
83 std::string::reverse_iterator rit = str.rbegin();
84 while (rit != str.rend()) {
85 if (*rit ==
'\r' || *rit ==
'\n') {
#define STORM_LOG_THROW(cond, exception, message)
#define STORM_PRINT_AND_LOG(message)
std::basic_istream< CharT, Traits > & getline(std::basic_istream< CharT, Traits > &input, std::basic_string< CharT, Traits, Allocator > &str)
Overloaded getline function which handles different types of newline ( and \r).
void closeFile(std::ofstream &stream)
Close the given file after writing.
bool fileExistsAndIsReadable(std::string const &filename)
Tests whether the given file exists and is readable.
void openFile(std::string const &filepath, std::ofstream &filestream, bool append=false, bool silent=false)
Open the given file for writing.