lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 016531f 3/3: Improve physical design


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 016531f 3/3: Improve physical design
Date: Sat, 4 Apr 2020 10:08:29 -0400 (EDT)

branch: master
commit 016531fe04e8fc02bb07c360ea2dc77467bd9560
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Improve physical design
    
    Instead of writing stream inserters and extractors as 'inline' functions
    in a header (which must then include <[io]stream>), only declare them in
    the header (where <iosfwd> suffices), and implement them in a '.cpp'
    file (which includes <[io]stream>).
    
    Don't do this for header-only facilities.
    
    Don't touch this inserter in 'path_utility.hpp':
      inline std::ostream& operator<<(std::ostream& os, fs::path const& z)
    because the standard <filesystem> header provides such an inserter. It
    would not be good to add a 'path_utility.o' dependency now, only to
    remove it when <filesystem> becomes usable.
    
    Incidentally, avoid dummy argument names in the header, such as:
      std::istream& operator>>(std::istream& TheStream, foo& TheFooThing);
    They're just clutter, and over years of maintenance they can easily come
    to differ from the argument names used in the implementation.
---
 Makefile.am       |  2 ++
 calendar_date.hpp |  4 ++--
 datum_base.cpp    | 13 +++++++++++++
 datum_base.hpp    | 11 ++---------
 objects.make      |  2 ++
 5 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index bd9662b..d27649c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -706,6 +706,7 @@ test_currency_CXXFLAGS = $(AM_CXXFLAGS)
 
 test_dbo_rules_SOURCES = \
   $(common_test_objects) \
+  datum_base.cpp \
   dbo_rules.cpp \
   dbo_rules_test.cpp \
   facets.cpp \
@@ -883,6 +884,7 @@ test_ledger_SOURCES = \
   configurable_settings.cpp \
   crc32.cpp \
   data_directory.cpp \
+  datum_base.cpp \
   facets.cpp \
   global_settings.cpp \
   ledger.cpp \
diff --git a/calendar_date.hpp b/calendar_date.hpp
index f950283..4c455b2 100644
--- a/calendar_date.hpp
+++ b/calendar_date.hpp
@@ -178,8 +178,8 @@ calendar_date LMI_SO operator+(int, calendar_date);
 calendar_date LMI_SO operator+(calendar_date, int);
 calendar_date LMI_SO operator-(calendar_date, int);
 
-std::ostream& LMI_SO operator<<(std::ostream& os, calendar_date const&);
-std::istream& LMI_SO operator>>(std::istream& is, calendar_date&);
+std::ostream& LMI_SO operator<<(std::ostream&, calendar_date const&);
+std::istream& LMI_SO operator>>(std::istream&, calendar_date&);
 
 calendar_date add_years
     (calendar_date const& date
diff --git a/datum_base.cpp b/datum_base.cpp
index 06033eb..3bb4c5e 100644
--- a/datum_base.cpp
+++ b/datum_base.cpp
@@ -23,6 +23,9 @@
 
 #include "datum_base.hpp"
 
+#include <istream>
+#include <ostream>
+
 void datum_base::enable(bool b)
 {
     enabled_ = b;
@@ -32,3 +35,13 @@ bool datum_base::is_enabled() const
 {
     return enabled_;
 }
+
+std::istream& operator>>(std::istream& is, datum_base& z)
+{
+    return z.read(is);
+}
+
+std::ostream& operator<<(std::ostream& os, datum_base const& z)
+{
+    return z.write(os);
+}
diff --git a/datum_base.hpp b/datum_base.hpp
index 825fe2f..5b59453 100644
--- a/datum_base.hpp
+++ b/datum_base.hpp
@@ -46,14 +46,7 @@ class LMI_SO datum_base
     bool enabled_ {true};
 };
 
-inline std::istream& operator>>(std::istream& is, datum_base& z)
-{
-    return z.read(is);
-}
-
-inline std::ostream& operator<<(std::ostream& os, datum_base const& z)
-{
-    return z.write(os);
-}
+std::istream& operator>>(std::istream&, datum_base&);
+std::ostream& operator<<(std::ostream&, datum_base const&);
 
 #endif // datum_base_hpp
diff --git a/objects.make b/objects.make
index f9f5400..1f58504 100644
--- a/objects.make
+++ b/objects.make
@@ -615,6 +615,7 @@ currency_test$(EXEEXT): \
 
 dbo_rules_test$(EXEEXT): \
   $(common_test_objects) \
+  datum_base.o \
   dbo_rules.o \
   dbo_rules_test.o \
   facets.o \
@@ -774,6 +775,7 @@ ledger_test$(EXEEXT): \
   configurable_settings.o \
   crc32.o \
   data_directory.o \
+  datum_base.o \
   facets.o \
   global_settings.o \
   ledger.o \



reply via email to

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