21#include <boost/algorithm/string/join.hpp>
30 data_.push_back(vector<ReportType>());
36 QL_REQUIRE(
i_ ==
headers_.size(),
"Cannot go to next line, only " <<
i_ <<
" entires filled, report headers are: "
44 QL_REQUIRE(
i_ <
headers_.size(),
"No column to add [" << rt <<
"] to.");
45 QL_REQUIRE(rt.which() ==
columnTypes_[
i_].which(),
"Cannot add value "
46 << rt <<
" of type " << rt.which() <<
" to column "
48 <<
", report headers are: " << boost::join(
headers_,
","));
56 QL_REQUIRE(
columns() == report.
columns(),
"Cannot combine reports of different sizes ("
58 <<
"), report headers are: " << boost::join(
headers_,
","));
60 for (Size i = 0; i <
columns(); i++) {
62 string h2 = report.
header(i);
63 QL_REQUIRE(h1 == h2,
"Cannot combine reports with different headers (\""
64 << h1 <<
"\" and \"" << h2
65 <<
"\"), report headers are: " << boost::join(
headers_,
","));
71 for (Size rowIdx = 0; rowIdx < report.
rows(); rowIdx++) {
72 for (Size columnIdx = 0; columnIdx < report.
columns(); columnIdx++) {
73 add(report.
data(columnIdx)[rowIdx]);
82 QL_REQUIRE(
i_ ==
headers_.size() ||
i_ == 0,
"report is finalized with incomplete row, got data for "
84 <<
", report headers are: " << boost::join(
headers_,
","));
88 QL_REQUIRE(
data_[i].
size() ==
rows(),
"internal error: report column "
90 <<
" rows, expected are " <<
rows()
91 <<
" rows, report headers are: " << boost::join(
headers_,
","));
96 const string& nullString,
bool lowerHeader) {
98 CSVFileReport cReport(filename, sep, commentCharacter, quoteChar, nullString, lowerHeader);
100 for (Size i = 0; i <
headers_.size(); i++) {
105 if (numColumns > 0) {
106 auto numRows =
data_[0].size();
108 for (Size i = 0; i < numRows; i++) {
110 for (Size j = 0; j < numColumns; j++) {
Report & add(const ReportType &rt) override
Report & addColumn(const string &name, const ReportType &rt, Size precision=0) override
vector< Size > columnPrecision_
Report & add(const ReportType &rt) override
vector< ReportType > columnTypes_
const string & header(Size i) const
const vector< ReportType > & data(Size i) const
Returns the data.
vector< string > headers_
vector< vector< ReportType > > data_
Report & addColumn(const string &name, const ReportType &rt, Size precision=0) override
void toFile(const string &filename, const char sep=',', const bool commentCharacter=true, char quoteChar='\0', const string &nullString="#N/A", bool lowerHeader=false)
boost::variant< Size, Real, string, Date, Period > ReportType
Size size(const ValueType &v)
Serializable Credit Default Swap.