lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 276c4ff 1/5: In TSV, show scalars' names and


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 276c4ff 1/5: In TSV, show scalars' names and values in two columns only
Date: Fri, 5 Oct 2018 20:32:46 -0400 (EDT)

branch: master
commit 276c4ff535591a9f5821151c10cf5e2ce0a492cb
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    In TSV, show scalars' names and values in two columns only
    
    "Vectors" are shown thus:
      name0    name1   ...
      value00  value10 ...
      value01  value11 ...
      ...      ...     ...
    which is natural because their values are almost all numeric with no
    more than about ten digits. "Scalars" were shown similarly:
      name0    name1  ...
      value0   value1 ...
    as an experiment, removed in this commit because it clearly failed:
    it was unnatural because their values are often strings of arbitrary
    length. Now scalars are shown only thus:
      name0   value0
      name1   value1-which-may-sprawl-all-the-way-across-the-screen
      ...     ...
    Revised a comment block accordingly. Incidentally, rearranged the
    code for clarity.
---
 ledger_evaluator.cpp | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/ledger_evaluator.cpp b/ledger_evaluator.cpp
index db452cf..ce30262 100644
--- a/ledger_evaluator.cpp
+++ b/ledger_evaluator.cpp
@@ -1005,38 +1005,16 @@ std::string ledger_evaluator::operator()
 /// alphabetically; 'scalars_', likewise. Other, more complicated
 /// techniques are faster, but direct copying favors simplicity over
 /// speed--appropriately, as this facility is rarely used.
-///
-/// For the nonce, 'scalars_' are shown two ways: 2 x N, and N x 2.
-/// Presumably only one way should be chosen for production; showing
-/// both ways informs that choice.
 
 void ledger_evaluator::write_tsv(fs::path const& pdf_out_file) const
 {
-    if("1" != operator()("WriteTsvFile"))
-        return;
+    if("1" != operator()("WriteTsvFile")) return;
 
     configurable_settings const& c = configurable_settings::instance();
     std::string const& z = c.spreadsheet_file_extension();
     fs::path filepath = unique_filepath(pdf_out_file, ".values" + z);
     fs::ofstream ofs(filepath, ios_out_trunc_binary());
 
-    using s_map_t = std::map<std::string,std::string> const;
-    s_map_t sorted_scalars(scalars_.begin(), scalars_.end());
-
-    for(auto const& j : sorted_scalars)
-        {
-        ofs << j.first << '\t';
-        }
-    ofs << '\n';
-
-    for(auto const& j : sorted_scalars)
-        {
-        ofs << j.second << '\t';
-        }
-    ofs << '\n';
-
-    ofs << '\n';
-
     using v_map_t = std::map<std::string,std::vector<std::string>> const;
     v_map_t sorted_vectors(vectors_.begin(), vectors_.end());
 
@@ -1066,6 +1044,9 @@ void ledger_evaluator::write_tsv(fs::path const& 
pdf_out_file) const
 
     ofs << '\n';
 
+    using s_map_t = std::map<std::string,std::string> const;
+    s_map_t sorted_scalars(scalars_.begin(), scalars_.end());
+
     for(auto const& j : sorted_scalars)
         {
         ofs << j.first << '\t' << j.second << '\n';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]