[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 429acb9 1/9: Add missing 'pyx="values_tsv"' s
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 429acb9 1/9: Add missing 'pyx="values_tsv"' support |
Date: |
Thu, 27 Sep 2018 12:53:50 -0400 (EDT) |
branch: master
commit 429acb9a3fa4398cc6ffe7f4e932e9b152d99d6e
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Add missing 'pyx="values_tsv"' support
Copied this feature's implementation from
ledger_xml_io.cpp [XSL-FO original]
into
ledger_evaluator.cpp [modernized replacement]
, including headers as needed.
---
ledger_evaluator.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/ledger_evaluator.cpp b/ledger_evaluator.cpp
index 8f6fbbe..e3084e8 100644
--- a/ledger_evaluator.cpp
+++ b/ledger_evaluator.cpp
@@ -26,6 +26,7 @@
#include "alert.hpp"
#include "authenticity.hpp"
#include "calendar_date.hpp"
+#include "configurable_settings.hpp"
#include "contains.hpp"
#include "global_settings.hpp"
#include "handle_exceptions.hpp"
@@ -35,11 +36,16 @@
#include "ledger_variant.hpp"
#include "map_lookup.hpp"
#include "mc_enum_aux.hpp" // mc_e_vector_to_string_vector()
-#include "miscellany.hpp" // each_equal()
+#include "miscellany.hpp" // each_equal(), ios_out_trunc_binary()
#include "oecumenic_enumerations.hpp"
+#include "path_utility.hpp" // fs::path inserter
+#include "ssize_lmi.hpp"
#include "value_cast.hpp"
#include "version.hpp"
+#include <boost/filesystem/fstream.hpp>
+#include <boost/filesystem/path.hpp>
+
#include <algorithm> // fill(), transform()
#include <functional> // minus
#include <unordered_map>
@@ -989,7 +995,45 @@ ledger_evaluator Ledger::make_evaluator() const
stringvectors["SupplementalReportColumnsMasks" ] =
std::move(SupplementalReportColumnsMasks );
}
- // PDF !! Is the old pyx="values_tsv" facility still wanted?
+ if(is_composite() && contains(global_settings::instance().pyx(),
"values_tsv"))
+ {
+ throw_if_interdicted(*this);
+
+ configurable_settings const& z = configurable_settings::instance();
+ fs::path filepath
+ ( z.print_directory()
+ + "/values"
+ + z.spreadsheet_file_extension()
+ );
+ fs::ofstream ofs(filepath, ios_out_trunc_binary());
+
+ for(auto const& j : stringvectors)
+ {
+ ofs << j.first << '\t';
+ }
+ ofs << '\n';
+
+ for(int i = 0; i < GetMaxLength(); ++i)
+ {
+ for(auto const& j : stringvectors)
+ {
+ std::vector<std::string> const& v = j.second;
+ if(i < lmi::ssize(v))
+ {
+ ofs << v[i] << '\t';
+ }
+ else
+ {
+ ofs << '\t';
+ }
+ }
+ ofs << '\n';
+ }
+ if(!ofs)
+ {
+ alarum() << "Unable to write '" << filepath << "'." << LMI_FLUSH;
+ }
+ }
return ledger_evaluator(std::move(stringscalars),
std::move(stringvectors));
}
- [lmi-commits] [lmi] master updated (ea25cc6 -> 058e112), Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master 7d7cd0d 4/9: Adjust whitespace for vertical alignment, Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master 3d75aa3 2/9: Rearrange headers, Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master 429acb9 1/9: Add missing 'pyx="values_tsv"' support,
Greg Chicares <=
- [lmi-commits] [lmi] master 58b0c04 3/9: Sort columns alphabetically in TSV output, Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master 0593224 5/9: Reorder statements more logically, Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master bb0eb2c 7/9: Favor problem-domain terminology, Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master 16da526 6/9: Change the format of 'GenAcctAllocation', Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master 058e112 9/9: Assert a formerly implicit assumption, Greg Chicares, 2018/09/27
- [lmi-commits] [lmi] master 957fb26 8/9: Favor problem-domain terminology, Greg Chicares, 2018/09/27