23#include <ql/errors.hpp>
25#include <boost/algorithm/string.hpp>
44 while (getline(*
stream_, line)) {
52 if (line.empty() || boost::starts_with(line,
comment_))
56 DLOG(
"Processing line number " <<
lineNo_ <<
": " << line);
57 vector<string> entries;
59 entries, line, [
this](
char c) {
return c ==
delim_; }, boost::token_compress_off);
70 stream_->seekg(0, std::ios::beg);
76 QL_REQUIRE(entries.size() == 10,
"On line number " <<
lineNo_ <<
": A sensitivity record needs 10 entries");
104 file_ =
new std::ifstream(fileName);
105 QL_REQUIRE(
file_->is_open(),
"error opening file " << fileName);
106 LOG(
"The file " << fileName <<
" has been opened for streaming");
114 if (
file_->is_open()) {
117 LOG(
"The file stream has been closed");
122 std::stringstream* stream =
new std::stringstream(buffer);
SensitivityBufferStream(const std::string &buffer, char delim=',', const std::string &comment="#")
Constructor providing path to csv file fileName.
SensitivityFileStream(const std::string &fileName, char delim=',', const std::string &comment="#")
Constructor providing path to csv file fileName.
~SensitivityFileStream() override
bool tryParseReal(const string &s, QuantLib::Real &result)
bool parseBool(const string &s)
Real parseReal(const string &s)
pair< RiskFactorKey, string > deconstructFactor(const string &factor)
Class for streaming SensitivityRecords from file.
Shift scenario generation.