[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master b860e42 2/2: Rearrange member-function implem
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master b860e42 2/2: Rearrange member-function implementations in header order |
Date: |
Sat, 4 Feb 2017 01:13:29 +0000 (UTC) |
branch: master
commit b860e42705dae7a8054f55071576a52d4123732d
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Rearrange member-function implementations in header order
---
input_sequence.cpp | 778 ++++++++++++++++++++++++++--------------------------
1 file changed, 389 insertions(+), 389 deletions(-)
diff --git a/input_sequence.cpp b/input_sequence.cpp
index 59814b5..0e08fe5 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -82,346 +82,44 @@ std::vector<ValueInterval> const&
SequenceParser::intervals() 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_allowed_keywords
- ,bool a_keywords_only
- ,std::string const& a_default_keyword
- )
- :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)
- ,allowed_keywords_ (a_allowed_keywords)
- ,keywords_only_ (a_keywords_only)
- ,default_keyword_ (a_default_keyword)
-{
- // A default keyword should be specified (i.e., nonempty) only for
- // keyword-only sequences (otherwise, the default is numeric), and
- // it should always be allowable even though other keywords may be
- // disallowed in context. As this is written in 2017-02, the only
- // UDTs with default keywords are:
- // mode_sequence::default_keyword() // "annual"
- // dbo_sequence::default_keyword() // "a"
- // This assertion will provide useful guidance if, e.g., a new
- // policy form that forbids annual mode is implemented.
- LMI_ASSERT
- ( a_default_keyword.empty()
- || a_keywords_only && contains(a_allowed_keywords, a_default_keyword)
- );
-
- SequenceParser parser
- (input_expression
- ,a_years_to_maturity
- ,a_issue_age
- ,a_retirement_age
- ,a_inforce_duration
- ,a_effective_year
- ,a_allowed_keywords
- ,a_keywords_only
- );
-
- parser_diagnostics_ = parser.diagnostics();
- intervals_ = parser.intervals();
-
- // Inception and maturity endpoints exist, so the interval they
- // define must exist. However, parsing an empty expression
- // constructs zero intervals, so a default one must be created
- // to make the physical reality meet the conceptual requirement.
- if(intervals_.empty())
- {
- intervals_.push_back(ValueInterval());
- }
-
- // Extend the last interval's endpoint to maturity, replicating
- // the last element. (This doesn't need to be done by the ctors
- // that take vector arguments, because those arguments specify
- // each value in [inception, maturity) and deduce the terminal
- // (maturity) duration from size().)
-
- // This invariant has not yet been established, whether or not the
- // sequence was empty.
- intervals_.back().end_duration = a_years_to_maturity;
- // This invariant is established by realize_vector(), but it does
- // no harm to repeat it here, and it would be confusing not to do
- // so in conjunction with the line above.
- intervals_.back().end_mode = e_maturity;
-
- realize_vector();
-}
-
-// Constructors taking one or two vectors as their sole arguments are
-// intended to convert flat vectors to input sequences, compacted with
-// run-length encoding: 1 1 1 2 2 becomes 1[0,2), 2[2,4).
-//
-// The constructor that takes two vector arguments exists because some
-// sequences may have both numeric and keyword values. Distinct vectors
-// are supplied for these two value types; for each interval, the value
-// type chosen is keyword if the keyword is not blank, else numeric.
-//
-// The control constructs may appear nonobvious. This design treats
-// the push_back operation as fundamental: push_back is called exactly
-// when we know that a new interval must be added. This avoids special
-// handling
-// when the vectors are of length zero, and
-// for the last interval.
-// As a consequence, we always push_back a dummy interval exactly when
-// we know that it will be needed, and then write to intervals_.back().
-//
-// An alternative design would work with a temporary interval and
-// call push_back as needed. I tried that and concluded that this
-// design is simpler.
-//
-// Strings in input vectors are not validated against a map of
-// permissible strings: these constructors are designed for use only
-// with vectors of strings generated by the program from known-valid
-// input, and should not be used in any other situation.
-// SOMEDAY !! Ideally, therefore, they should be protected from
-// unintended use.
-
-InputSequence::InputSequence(std::vector<double> const& v)
- :years_to_maturity_(v.size())
-{
- ValueInterval dummy;
-
- double prior_value = v.empty() ? 0.0 : v.front();
- double current_value = prior_value;
-
- intervals_.push_back(dummy);
- intervals_.back().value_number = current_value;
-
- for(auto const& vi : v)
- {
- current_value = vi;
- if(prior_value == current_value)
- {
- ++intervals_.back().end_duration;
- }
- else
- {
- int value_change_duration = intervals_.back().end_duration;
- intervals_.push_back(dummy);
- intervals_.back().value_number = current_value;
- intervals_.back().begin_duration = value_change_duration;
- intervals_.back().end_duration = ++value_change_duration;
- prior_value = current_value;
- }
- }
-
- realize_vector();
-}
-
-InputSequence::InputSequence(std::vector<std::string> const& v)
- :years_to_maturity_(v.size())
-{
- ValueInterval dummy;
- dummy.value_is_keyword = true;
-
- std::string prior_value = v.empty() ? std::string() : v.front();
- std::string current_value = prior_value;
-
- intervals_.push_back(dummy);
- intervals_.back().value_keyword = current_value;
-
- for(auto const& vi : v)
- {
- current_value = vi;
- if(prior_value == current_value)
- {
- ++intervals_.back().end_duration;
- }
- else
- {
- int value_change_duration = intervals_.back().end_duration;
- intervals_.push_back(dummy);
- intervals_.back().value_keyword = current_value;
- intervals_.back().begin_duration = value_change_duration;
- intervals_.back().end_duration = ++value_change_duration;
- prior_value = current_value;
- }
- }
-
- realize_vector();
-}
-
-InputSequence::InputSequence
- (std::vector<double> const& n_v
- ,std::vector<std::string> const& s_v
- )
- :years_to_maturity_(n_v.size())
-{
- if(n_v.size() != s_v.size())
- {
- fatal_error()
- << "Vector lengths differ."
- << LMI_FLUSH
- ;
- }
-
- ValueInterval dummy;
-
- double n_prior_value = n_v.empty() ? 0.0 : n_v.front();
- double n_current_value = n_prior_value;
-
- std::string s_prior_value = s_v.empty() ? std::string() : s_v.front();
- std::string s_current_value = s_prior_value;
-
- intervals_.push_back(dummy);
- intervals_.back().value_number = n_current_value;
- intervals_.back().value_keyword = s_current_value;
- intervals_.back().value_is_keyword = "" != s_current_value;
-
- std::vector<double>::const_iterator n_vi;
- std::vector<std::string>::const_iterator s_vi;
- for
- (n_vi = n_v.begin(), s_vi = s_v.begin()
- ;n_vi != n_v.end() // s_v has same length, as 'asserted' above.
- ;++n_vi, ++s_vi
- )
- {
- n_current_value = *n_vi;
- s_current_value = *s_vi;
- if(n_prior_value == n_current_value && s_prior_value ==
s_current_value)
- {
- ++intervals_.back().end_duration;
- }
- else
- {
- int value_change_duration = intervals_.back().end_duration;
- intervals_.push_back(dummy);
- intervals_.back().value_number = n_current_value;
- intervals_.back().value_keyword = s_current_value;
- intervals_.back().value_is_keyword = "" != s_current_value;
- intervals_.back().begin_duration = value_change_duration;
- intervals_.back().end_duration = ++value_change_duration;
- n_prior_value = n_current_value;
- s_prior_value = s_current_value;
- }
- }
-
- realize_vector();
-}
-
-InputSequence::~InputSequence() = default;
-
-void InputSequence::realize_vector()
-{
- // Post-construction invariants.
- // Every ctor must already have established this...
- LMI_ASSERT(!intervals_.empty());
- // ...and this:
- LMI_ASSERT(years_to_maturity_ == intervals_.back().end_duration);
- // It cannot be assumed that all ctors have yet established this...
- intervals_.back().end_mode = e_maturity;
- // ...though now of course it has been established:
- LMI_ASSERT(e_maturity == intervals_.back().end_mode );
-
- std::vector<double> r(years_to_maturity_);
- std::vector<std::string> s(years_to_maturity_, default_keyword_);
- number_result_ = r;
- keyword_result_ = s;
-
- // Vectors have default values if the input expression could not be parsed.
- if(!formatted_diagnostics().empty())
- {
- return;
- }
-
- int prior_begin_duration = 0;
- for(auto const& interval_i : intervals_)
- {
- if(interval_i.insane)
- {
- fatal_error()
- << "Untrapped parser error."
- << LMI_FLUSH
- ;
- }
- if(e_invalid_mode == interval_i.begin_mode)
- {
- fatal_error()
- << "Interval "
- << "[ " << interval_i.begin_duration << ", "
- << interval_i.end_duration << " )"
- << " has invalid begin_mode."
- << LMI_FLUSH
- ;
- }
- if(e_invalid_mode == interval_i.end_mode)
+std::string SequenceParser::token_type_name(SequenceParser::token_type t)
+{
+ switch(t)
+ {
+ case 0:
{
- fatal_error()
- << "Interval "
- << "[ " << interval_i.begin_duration << ", "
- << interval_i.end_duration << " )"
- << " has invalid end_mode."
- << LMI_FLUSH
- ;
+ return "end of input";
}
- if(interval_i.value_is_keyword && "daft" == interval_i.value_keyword)
+ case e_major_separator:
+ case e_minor_separator:
+ case e_begin_incl:
+ case e_begin_excl:
+ case e_end_incl:
+ case e_end_excl:
+ case e_age_prefix:
+ case e_cardinal_prefix:
{
- fatal_error()
- << "Interval "
- << "[ " << interval_i.begin_duration << ", "
- << interval_i.end_duration << " )"
- << " has invalid value_keyword."
- << LMI_FLUSH
- ;
+ std::string s;
+ s += static_cast<char>(t);
+ return s;
}
- if(interval_i.begin_duration < prior_begin_duration)
+ case e_startup:
{
- fatal_error()
- << "Previous interval began at duration "
- << prior_begin_duration
- << "; current interval "
- << "[ " << interval_i.begin_duration << ", "
- << interval_i.end_duration << " )"
- << " would begin before that."
- << LMI_FLUSH
- ;
- return;
+ return "beginning of input";
}
- prior_begin_duration = interval_i.begin_duration;
- bool interval_is_ok =
- 0 <= interval_i.begin_duration
- && interval_i.begin_duration <= interval_i.end_duration
- && interval_i.end_duration <= years_to_maturity_
- ;
- if(!interval_is_ok)
+ case e_number:
{
- fatal_error()
- << "Interval "
- << "[ " << interval_i.begin_duration << ", "
- << interval_i.end_duration << " )"
- << " not valid."
- << LMI_FLUSH
- ;
+ return "number";
}
- if(interval_i.value_is_keyword)
+ case e_keyword:
{
- std::fill
- (s.begin() + interval_i.begin_duration
- ,s.begin() + interval_i.end_duration
- ,interval_i.value_keyword
- );
+ return "keyword";
}
- else
+ default:
{
- std::fill
- (r.begin() + interval_i.begin_duration
- ,r.begin() + interval_i.end_duration
- ,interval_i.value_number
- );
+ return std::string("unknown: ") + static_cast<char>(t);
}
}
-
- number_result_ = r;
- keyword_result_ = s;
}
// GRAMMAR interval-begin: one of [ (
@@ -963,94 +661,261 @@ SequenceParser::token_type SequenceParser::get_token()
}
}
-std::string SequenceParser::token_type_name(SequenceParser::token_type t)
+void SequenceParser::match(SequenceParser::token_type t)
{
- switch(t)
+ if(current_token_type_ == t)
{
- case 0:
- {
- return "end of input";
- }
- case e_major_separator:
- case e_minor_separator:
- case e_begin_incl:
- case e_begin_excl:
- case e_end_incl:
- case e_end_excl:
- case e_age_prefix:
- case e_cardinal_prefix:
- {
- std::string s;
- s += static_cast<char>(t);
- return s;
- }
- case e_startup:
+ current_token_type_ = get_token();
+ }
+ else
+ {
+ diagnostics_
+ << "Expected '"
+ << token_type_name(t)
+ << "' . "
+ ;
+ mark_diagnostic_context();
+ }
+}
+
+void SequenceParser::mark_diagnostic_context()
+{
+ diagnostics_
+ << "Current token '"
+ << token_type_name(current_token_type_)
+ << "' at position " << input_stream_.tellg()
+ << ".\n"
+ ;
+}
+
+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_allowed_keywords
+ ,bool a_keywords_only
+ ,std::string const& a_default_keyword
+ )
+ :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)
+ ,allowed_keywords_ (a_allowed_keywords)
+ ,keywords_only_ (a_keywords_only)
+ ,default_keyword_ (a_default_keyword)
+{
+ // A default keyword should be specified (i.e., nonempty) only for
+ // keyword-only sequences (otherwise, the default is numeric), and
+ // it should always be allowable even though other keywords may be
+ // disallowed in context. As this is written in 2017-02, the only
+ // UDTs with default keywords are:
+ // mode_sequence::default_keyword() // "annual"
+ // dbo_sequence::default_keyword() // "a"
+ // This assertion will provide useful guidance if, e.g., a new
+ // policy form that forbids annual mode is implemented.
+ LMI_ASSERT
+ ( a_default_keyword.empty()
+ || a_keywords_only && contains(a_allowed_keywords, a_default_keyword)
+ );
+
+ SequenceParser parser
+ (input_expression
+ ,a_years_to_maturity
+ ,a_issue_age
+ ,a_retirement_age
+ ,a_inforce_duration
+ ,a_effective_year
+ ,a_allowed_keywords
+ ,a_keywords_only
+ );
+
+ parser_diagnostics_ = parser.diagnostics();
+ intervals_ = parser.intervals();
+
+ // Inception and maturity endpoints exist, so the interval they
+ // define must exist. However, parsing an empty expression
+ // constructs zero intervals, so a default one must be created
+ // to make the physical reality meet the conceptual requirement.
+ if(intervals_.empty())
+ {
+ intervals_.push_back(ValueInterval());
+ }
+
+ // Extend the last interval's endpoint to maturity, replicating
+ // the last element. (This doesn't need to be done by the ctors
+ // that take vector arguments, because those arguments specify
+ // each value in [inception, maturity) and deduce the terminal
+ // (maturity) duration from size().)
+
+ // This invariant has not yet been established, whether or not the
+ // sequence was empty.
+ intervals_.back().end_duration = a_years_to_maturity;
+ // This invariant is established by realize_vector(), but it does
+ // no harm to repeat it here, and it would be confusing not to do
+ // so in conjunction with the line above.
+ intervals_.back().end_mode = e_maturity;
+
+ realize_vector();
+}
+
+// Constructors taking one or two vectors as their sole arguments are
+// intended to convert flat vectors to input sequences, compacted with
+// run-length encoding: 1 1 1 2 2 becomes 1[0,2), 2[2,4).
+//
+// The constructor that takes two vector arguments exists because some
+// sequences may have both numeric and keyword values. Distinct vectors
+// are supplied for these two value types; for each interval, the value
+// type chosen is keyword if the keyword is not blank, else numeric.
+//
+// The control constructs may appear nonobvious. This design treats
+// the push_back operation as fundamental: push_back is called exactly
+// when we know that a new interval must be added. This avoids special
+// handling
+// when the vectors are of length zero, and
+// for the last interval.
+// As a consequence, we always push_back a dummy interval exactly when
+// we know that it will be needed, and then write to intervals_.back().
+//
+// An alternative design would work with a temporary interval and
+// call push_back as needed. I tried that and concluded that this
+// design is simpler.
+//
+// Strings in input vectors are not validated against a map of
+// permissible strings: these constructors are designed for use only
+// with vectors of strings generated by the program from known-valid
+// input, and should not be used in any other situation.
+// SOMEDAY !! Ideally, therefore, they should be protected from
+// unintended use.
+
+InputSequence::InputSequence(std::vector<double> const& v)
+ :years_to_maturity_(v.size())
+{
+ ValueInterval dummy;
+
+ double prior_value = v.empty() ? 0.0 : v.front();
+ double current_value = prior_value;
+
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = current_value;
+
+ for(auto const& vi : v)
+ {
+ current_value = vi;
+ if(prior_value == current_value)
{
- return "beginning of input";
+ ++intervals_.back().end_duration;
}
- case e_number:
+ else
{
- return "number";
+ int value_change_duration = intervals_.back().end_duration;
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = current_value;
+ intervals_.back().begin_duration = value_change_duration;
+ intervals_.back().end_duration = ++value_change_duration;
+ prior_value = current_value;
}
- case e_keyword:
+ }
+
+ realize_vector();
+}
+
+InputSequence::InputSequence(std::vector<std::string> const& v)
+ :years_to_maturity_(v.size())
+{
+ ValueInterval dummy;
+ dummy.value_is_keyword = true;
+
+ std::string prior_value = v.empty() ? std::string() : v.front();
+ std::string current_value = prior_value;
+
+ intervals_.push_back(dummy);
+ intervals_.back().value_keyword = current_value;
+
+ for(auto const& vi : v)
+ {
+ current_value = vi;
+ if(prior_value == current_value)
{
- return "keyword";
+ ++intervals_.back().end_duration;
}
- default:
+ else
{
- return std::string("unknown: ") + static_cast<char>(t);
+ int value_change_duration = intervals_.back().end_duration;
+ intervals_.push_back(dummy);
+ intervals_.back().value_keyword = current_value;
+ intervals_.back().begin_duration = value_change_duration;
+ intervals_.back().end_duration = ++value_change_duration;
+ prior_value = current_value;
}
}
+
+ realize_vector();
}
-void SequenceParser::match(SequenceParser::token_type t)
+InputSequence::InputSequence
+ (std::vector<double> const& n_v
+ ,std::vector<std::string> const& s_v
+ )
+ :years_to_maturity_(n_v.size())
{
- if(current_token_type_ == t)
- {
- current_token_type_ = get_token();
- }
- else
+ if(n_v.size() != s_v.size())
{
- diagnostics_
- << "Expected '"
- << token_type_name(t)
- << "' . "
+ fatal_error()
+ << "Vector lengths differ."
+ << LMI_FLUSH
;
- mark_diagnostic_context();
}
-}
-void SequenceParser::mark_diagnostic_context()
-{
- diagnostics_
- << "Current token '"
- << token_type_name(current_token_type_)
- << "' at position " << input_stream_.tellg()
- << ".\n"
- ;
-}
+ ValueInterval dummy;
-/// Rationale for option to show only first diagnostic:
-/// downstream errors can confuse users.
+ double n_prior_value = n_v.empty() ? 0.0 : n_v.front();
+ double n_current_value = n_prior_value;
-std::string InputSequence::formatted_diagnostics
- (bool show_first_message_only
- ) const
-{
- // Data member parser_diagnostics_ exists only so that this function
- // can return it. Eliminate it when this function is eliminated.
- std::string s(parser_diagnostics_);
- if(show_first_message_only)
+ std::string s_prior_value = s_v.empty() ? std::string() : s_v.front();
+ std::string s_current_value = s_prior_value;
+
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = n_current_value;
+ intervals_.back().value_keyword = s_current_value;
+ intervals_.back().value_is_keyword = "" != s_current_value;
+
+ std::vector<double>::const_iterator n_vi;
+ std::vector<std::string>::const_iterator s_vi;
+ for
+ (n_vi = n_v.begin(), s_vi = s_v.begin()
+ ;n_vi != n_v.end() // s_v has same length, as 'asserted' above.
+ ;++n_vi, ++s_vi
+ )
{
- std::string::size_type z(s.find('\n'));
- if(std::string::npos != z)
+ n_current_value = *n_vi;
+ s_current_value = *s_vi;
+ if(n_prior_value == n_current_value && s_prior_value ==
s_current_value)
{
- s.erase(z);
+ ++intervals_.back().end_duration;
+ }
+ else
+ {
+ int value_change_duration = intervals_.back().end_duration;
+ intervals_.push_back(dummy);
+ intervals_.back().value_number = n_current_value;
+ intervals_.back().value_keyword = s_current_value;
+ intervals_.back().value_is_keyword = "" != s_current_value;
+ intervals_.back().begin_duration = value_change_duration;
+ intervals_.back().end_duration = ++value_change_duration;
+ n_prior_value = n_current_value;
+ s_prior_value = s_current_value;
}
}
- return s;
+
+ realize_vector();
}
+InputSequence::~InputSequence() = default;
+
std::vector<double> const& InputSequence::linear_number_representation() const
{
return number_result_;
@@ -1126,3 +991,138 @@ std::vector<ValueInterval> const&
InputSequence::interval_representation() const
return intervals_;
}
+/// Rationale for option to show only first diagnostic:
+/// downstream errors can confuse users.
+
+std::string InputSequence::formatted_diagnostics
+ (bool show_first_message_only
+ ) const
+{
+ // Data member parser_diagnostics_ exists only so that this function
+ // can return it. Eliminate it when this function is eliminated.
+ std::string s(parser_diagnostics_);
+ if(show_first_message_only)
+ {
+ std::string::size_type z(s.find('\n'));
+ if(std::string::npos != z)
+ {
+ s.erase(z);
+ }
+ }
+ return s;
+}
+
+void InputSequence::realize_vector()
+{
+ // Post-construction invariants.
+ // Every ctor must already have established this...
+ LMI_ASSERT(!intervals_.empty());
+ // ...and this:
+ LMI_ASSERT(years_to_maturity_ == intervals_.back().end_duration);
+ // It cannot be assumed that all ctors have yet established this...
+ intervals_.back().end_mode = e_maturity;
+ // ...though now of course it has been established:
+ LMI_ASSERT(e_maturity == intervals_.back().end_mode );
+
+ std::vector<double> r(years_to_maturity_);
+ std::vector<std::string> s(years_to_maturity_, default_keyword_);
+ number_result_ = r;
+ keyword_result_ = s;
+
+ // Vectors have default values if the input expression could not be parsed.
+ if(!formatted_diagnostics().empty())
+ {
+ return;
+ }
+
+ int prior_begin_duration = 0;
+ for(auto const& interval_i : intervals_)
+ {
+ if(interval_i.insane)
+ {
+ fatal_error()
+ << "Untrapped parser error."
+ << LMI_FLUSH
+ ;
+ }
+ if(e_invalid_mode == interval_i.begin_mode)
+ {
+ fatal_error()
+ << "Interval "
+ << "[ " << interval_i.begin_duration << ", "
+ << interval_i.end_duration << " )"
+ << " has invalid begin_mode."
+ << LMI_FLUSH
+ ;
+ }
+ if(e_invalid_mode == interval_i.end_mode)
+ {
+ fatal_error()
+ << "Interval "
+ << "[ " << interval_i.begin_duration << ", "
+ << interval_i.end_duration << " )"
+ << " has invalid end_mode."
+ << LMI_FLUSH
+ ;
+ }
+ if(interval_i.value_is_keyword && "daft" == interval_i.value_keyword)
+ {
+ fatal_error()
+ << "Interval "
+ << "[ " << interval_i.begin_duration << ", "
+ << interval_i.end_duration << " )"
+ << " has invalid value_keyword."
+ << LMI_FLUSH
+ ;
+ }
+ if(interval_i.begin_duration < prior_begin_duration)
+ {
+ fatal_error()
+ << "Previous interval began at duration "
+ << prior_begin_duration
+ << "; current interval "
+ << "[ " << interval_i.begin_duration << ", "
+ << interval_i.end_duration << " )"
+ << " would begin before that."
+ << LMI_FLUSH
+ ;
+ return;
+ }
+ prior_begin_duration = interval_i.begin_duration;
+ bool interval_is_ok =
+ 0 <= interval_i.begin_duration
+ && interval_i.begin_duration <= interval_i.end_duration
+ && interval_i.end_duration <= years_to_maturity_
+ ;
+ if(!interval_is_ok)
+ {
+ fatal_error()
+ << "Interval "
+ << "[ " << interval_i.begin_duration << ", "
+ << interval_i.end_duration << " )"
+ << " not valid."
+ << LMI_FLUSH
+ ;
+ }
+ if(interval_i.value_is_keyword)
+ {
+ std::fill
+ (s.begin() + interval_i.begin_duration
+ ,s.begin() + interval_i.end_duration
+ ,interval_i.value_keyword
+ );
+ }
+ else
+ {
+ std::fill
+ (r.begin() + interval_i.begin_duration
+ ,r.begin() + interval_i.end_duration
+ ,interval_i.value_number
+ );
+ }
+ }
+
+ number_result_ = r;
+ keyword_result_ = s;
+}
+