lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 5569029 3/4: Waking


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 5569029 3/4: Waking
Date: Fri, 3 Feb 2017 01:24:16 +0000 (UTC)

branch: master
commit 55690293be825e895a16bf2005c885a89c4a2cfd
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Waking
    
    --and it really *was* a kitten, after all.
---
 input_sequence.cpp |   52 ++++++++++++++++++++++++++++--
 input_sequence.hpp |   90 ++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 112 insertions(+), 30 deletions(-)

diff --git a/input_sequence.cpp b/input_sequence.cpp
index d5bf65b..fa3f493 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -48,7 +48,7 @@ ValueInterval::ValueInterval()
     ,insane           (false)
 {}
 
-InputSequence::InputSequence
+SequenceParser::SequenceParser
     (std::string const&              input_expression
     ,int                             a_years_to_maturity
     ,int                             a_issue_age
@@ -74,6 +74,54 @@ InputSequence::InputSequence
     ,last_input_duration           (0)
 {
     sequence();
+}
+
+SequenceParser::~SequenceParser() = default;
+
+std::string SequenceParser::EXPEDIENTdiagnostics() const
+{
+    return diagnostics.str();
+}
+
+std::vector<ValueInterval> const& SequenceParser::EXPEDIENTintervals() const
+{
+    return intervals;
+}
+
+InputSequence::InputSequence
+    (std::string const&              input_expression
+    ,int                             a_years_to_maturity
+    ,int                             a_issue_age
+    ,int                             a_retirement_age
+    ,int                             a_inforce_duration
+    ,int                             a_effective_year
+    ,std::vector<std::string> const& a_extra_keywords
+    ,std::string const&              a_default_keyword
+    ,bool                            a_keywords_only
+    )
+    :years_to_maturity             (a_years_to_maturity)
+    ,issue_age                     (a_issue_age)
+    ,retirement_age                (a_retirement_age)
+    ,inforce_duration              (a_inforce_duration)
+    ,effective_year                (a_effective_year)
+    ,extra_keywords                (a_extra_keywords)
+    ,default_keyword               (a_default_keyword)
+    ,keywords_only                 (a_keywords_only)
+{
+    SequenceParser parser
+        (input_expression
+        ,years_to_maturity
+        ,issue_age
+        ,retirement_age
+        ,inforce_duration
+        ,effective_year
+        ,extra_keywords
+        ,default_keyword
+        ,keywords_only
+        );
+
+    EXPEDIENTdiagnostics = parser.EXPEDIENTdiagnostics();
+    intervals = parser.EXPEDIENTintervals();
 
     // Inception and maturity endpoints exist, so the interval they
     // define must exist. However, parsing an empty expression
@@ -977,7 +1025,7 @@ std::string InputSequence::formatted_diagnostics
     (bool show_first_message_only
     ) const
 {
-    std::string s(diagnostics.str());
+    std::string s(EXPEDIENTdiagnostics);
     if(show_first_message_only)
         {
         std::string::size_type z(s.find('\n'));
diff --git a/input_sequence.hpp b/input_sequence.hpp
index 6989a4e..71e6fa2 100644
--- a/input_sequence.hpp
+++ b/input_sequence.hpp
@@ -168,15 +168,12 @@ struct ValueInterval
     bool          insane;
 };
 
-class InputSequence;
-using SequenceParser = InputSequence;
-
-class LMI_SO InputSequence
-    :        private lmi::uncopyable <InputSequence>
-    ,virtual private obstruct_slicing<InputSequence>
+class SequenceParser
+    :        private lmi::uncopyable <SequenceParser>
+    ,virtual private obstruct_slicing<SequenceParser>
 {
   public:
-    InputSequence
+    SequenceParser
         (std::string const&              input_expression
         ,int                             a_years_to_maturity
         ,int                             a_issue_age
@@ -184,31 +181,16 @@ class LMI_SO InputSequence
         ,int                             a_inforce_duration
         ,int                             a_effective_year
         ,std::vector<std::string> const& a_extra_keywords
-            = std::vector<std::string>()
-        ,std::string const&              a_default_keyword = ""
-        ,bool                            a_keywords_only = false
+        ,std::string const&              a_default_keyword
+        ,bool                            a_keywords_only
         );
 
-    InputSequence(std::vector<double> const&);
-    InputSequence(std::vector<std::string> const&);
-    InputSequence(std::vector<double> const&, std::vector<std::string> const&);
-
-    ~InputSequence();
-
-    std::vector<double>      const& linear_number_representation()  const;
-    std::vector<std::string> const& linear_keyword_representation() const;
-
-    std::string mathematical_representation() const;
+    ~SequenceParser();
 
-    std::vector<ValueInterval> const& interval_representation() const;
-
-    std::string formatted_diagnostics
-        (bool show_first_message_only = false
-        ) const;
+    std::string EXPEDIENTdiagnostics() const;
+    std::vector<ValueInterval> const& EXPEDIENTintervals() const;
 
   private:
-    void realize_vector();
-
     enum token_type
         {e_eof             = 0
         ,e_major_separator = ';'
@@ -260,12 +242,64 @@ class LMI_SO InputSequence
     int current_duration_scalar;
     duration_mode previous_duration_scalar_mode;
     duration_mode current_duration_scalar_mode;
+    ValueInterval current_interval;
 
     int last_input_duration;
 
     std::ostringstream diagnostics;
 
-    ValueInterval current_interval;
+    std::vector<ValueInterval> intervals;
+};
+
+class LMI_SO InputSequence
+    :        private lmi::uncopyable <InputSequence>
+    ,virtual private obstruct_slicing<InputSequence>
+{
+  public:
+    InputSequence
+        (std::string const&              input_expression
+        ,int                             a_years_to_maturity
+        ,int                             a_issue_age
+        ,int                             a_retirement_age
+        ,int                             a_inforce_duration
+        ,int                             a_effective_year
+        ,std::vector<std::string> const& a_extra_keywords
+            = std::vector<std::string>()
+        ,std::string const&              a_default_keyword = ""
+        ,bool                            a_keywords_only = false
+        );
+
+    InputSequence(std::vector<double> const&);
+    InputSequence(std::vector<std::string> const&);
+    InputSequence(std::vector<double> const&, std::vector<std::string> const&);
+
+    ~InputSequence();
+
+    std::vector<double>      const& linear_number_representation()  const;
+    std::vector<std::string> const& linear_keyword_representation() const;
+
+    std::string mathematical_representation() const;
+
+    std::vector<ValueInterval> const& interval_representation() const;
+
+    std::string formatted_diagnostics
+        (bool show_first_message_only = false
+        ) const;
+
+  private:
+    void realize_vector();
+
+    int years_to_maturity;
+    int issue_age;
+    int retirement_age;
+    int inforce_duration;
+    int effective_year;
+    std::vector<std::string> extra_keywords;
+    std::string default_keyword;
+    bool keywords_only;
+
+    std::string EXPEDIENTdiagnostics;
+
     std::vector<ValueInterval> intervals;
     std::vector<double> number_result;
     std::vector<std::string> keyword_result;



reply via email to

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