duration_get
is used to parse a character sequence, extracting components of a duration into a class duration.
More...
#include <duration_get.hpp>
Public Types | |
typedef CharT | char_type |
Type of character the facet is instantiated on. More... | |
typedef std::basic_string< CharT > | string_type |
Type of character string passed to member functions. More... | |
typedef InputIterator | iter_type |
Type of iterator used to scan the character buffer. More... | |
Public Member Functions | |
duration_get (size_t refs=0) | |
Construct a duration_get facet. More... | |
template<typename Rep , typename Period > | |
iter_type | get (iter_type s, iter_type end, std::ios_base &ios, std::ios_base::iostate &err, duration< Rep, Period > &d, const char_type *pattern, const char_type *pat_end) const |
template<typename Rep , typename Period > | |
iter_type | get (duration_units< CharT > const &facet, iter_type s, iter_type end, std::ios_base &ios, std::ios_base::iostate &err, duration< Rep, Period > &d, const char_type *pattern, const char_type *pat_end) const |
template<typename Rep > | |
iter_type | get_value (iter_type s, iter_type end, std::ios_base &ios, std::ios_base::iostate &err, Rep &r) const |
template<typename Rep > | |
iter_type | get_value (iter_type s, iter_type end, std::ios_base &ios, std::ios_base::iostate &err, process_times< Rep > &r) const |
iter_type | get_unit (iter_type i, iter_type e, std::ios_base &is, std::ios_base::iostate &err, rt_ratio &rt) const |
iter_type | get_unit (duration_units< CharT > const &facet, iter_type i, iter_type e, std::ios_base &is, std::ios_base::iostate &err, rt_ratio &rt) const |
~duration_get () | |
Destroy the facet More... | |
Static Public Attributes | |
static std::locale::id | id |
Unique identifier for this type of facet. More... | |
Protected Member Functions | |
iter_type | do_get_n_d_valid_unit (duration_units< CharT > const &facet, iter_type i, iter_type e, std::ios_base &, std::ios_base::iostate &err) const |
Extracts the run-time ratio associated to the duration when it is given in prefix form. More... | |
iter_type | do_get_valid_unit (duration_units< CharT > const &facet, iter_type i, iter_type e, std::ios_base &, std::ios_base::iostate &err, rt_ratio &rt) const |
Extracts the run-time ratio associated to the duration when it is given in prefix form. More... | |
duration_get
is used to parse a character sequence, extracting components of a duration into a class duration.
Each get member parses a format as produced by a corresponding format specifier to time_put<>::put. If the sequence being parsed matches the correct format, the corresponding member of the class duration argument are set to the value used to produce the sequence; otherwise either an error is reported or unspecified values are assigned. In other words, user confirmation is required for reliable parsing of user-entered durations, but machine-generated formats can be parsed reliably. This allows parsers to be aggressive about interpreting user variations on standard formats.
If the end iterator is reached during parsing of the get() member function, the member sets std::ios_base::eofbit in err.
typedef CharT boost::chrono::duration_get< CharT, InputIterator >::char_type |
Type of character the facet is instantiated on.
typedef InputIterator boost::chrono::duration_get< CharT, InputIterator >::iter_type |
Type of iterator used to scan the character buffer.
typedef std::basic_string<CharT> boost::chrono::duration_get< CharT, InputIterator >::string_type |
Type of character string passed to member functions.
|
inlineexplicit |
Construct a duration_get
facet.
refs | Construct a duration_get facet. If the refs argument is 0 then destruction of the object is delegated to the locale , or locales, containing it. This allows the user to ignore lifetime management issues. On the other had, if refs is 1 then the object must be explicitly deleted; the locale will not do so. In this case, the object can be maintained across the lifetime of multiple locales. |
|
inline |
Destroy the facet
|
inlineprotected |
Extracts the run-time ratio associated to the duration when it is given in prefix form.
This is an extension point of this facet so that we can take in account other periods that can have a useful translation in other contexts, as e.g. days and weeks.
facet | the duration_units facet |
i | start input stream iterator. |
e | end input stream iterator. |
ios | a reference to a ios_base. |
err | the ios_base state. |
s
References boost::regex_constants::failbit, boost::chrono::duration_units< CharT >::get_n_d_valid_units_end(), boost::chrono::duration_units< CharT >::get_n_d_valid_units_start(), boost::multiprecision::backends::i, and boost::chrono::duration_units< CharT >::match_n_d_valid_unit().
Referenced by boost::chrono::duration_get< CharT, InputIterator >::get_unit().
|
inlineprotected |
Extracts the run-time ratio associated to the duration when it is given in prefix form.
This is an extension point of this facet so that we can take in account other periods that can have a useful translation in other contexts, as e.g. days and weeks.
facet | the duration_units facet |
i | start input stream iterator. |
e | end input stream iterator. |
ios | a reference to a ios_base. |
err | the ios_base state. |
rt | a reference to the duration run-time ratio. An iterator pointing just beyond the last character that can be determined to be part of a valid name. |
References boost::regex_constants::failbit, boost::chrono::duration_units< CharT >::get_valid_units_end(), boost::chrono::duration_units< CharT >::get_valid_units_start(), boost::multiprecision::backends::i, and boost::chrono::duration_units< CharT >::match_valid_unit().
Referenced by boost::chrono::duration_get< CharT, InputIterator >::get_unit().
|
inline |
s | start input stream iterator |
end | end input stream iterator |
ios | a reference to a ios_base |
err | the ios_base state |
d | the duration |
pattern | begin of the formatting pattern |
pat_end | end of the formatting pattern |
Requires: [pattern,pat_end) shall be a valid range.
Effects: The function starts by evaluating err = std::ios_base::goodbit. It then enters a loop, reading zero or more characters from s at each iteration. Unless otherwise specified below, the loop terminates when the first of the following conditions holds:
Once r and rt are retrieved, Returns: s
References boost::end, and boost::asio::s.
Referenced by boost::chrono::time_point_get< CharT, InputIterator >::get_duration().
|
inline |
References BOOST_ASSERT, boost::chrono::rt_ratio::den, boost::regex_constants::failbit, boost::chrono::duration_get< CharT, InputIterator >::get_unit(), boost::chrono::duration_get< CharT, InputIterator >::get_value(), boost::tuples::detail::gt(), boost::accumulators::extract::max, boost::chrono::rt_ratio::num, boost::chrono::detail::reduce(), boost::asio::s, boost::spirit::ascii::space, and boost::flyweights::t.
|
inline |
s | start input stream iterator |
e | end input stream iterator |
ios | a reference to a ios_base |
err | the ios_base state |
rt | a reference to the duration run-time ratio. An iterator pointing just beyond the last character that can be determined to be part of a valid name |
Referenced by boost::chrono::duration_get< CharT, InputIterator >::get().
|
inline |
References boost::chrono::rt_ratio::den, boost::chrono::duration_get< CharT, InputIterator >::do_get_n_d_valid_unit(), boost::chrono::duration_get< CharT, InputIterator >::do_get_valid_unit(), boost::regex_constants::failbit, boost::multiprecision::backends::i, boost::chrono::rt_ratio::num, and boost::flyweights::x.
|
inline |
s | start input stream iterator |
end | end input stream iterator |
ios | a reference to a ios_base |
err | the ios_base state |
d | the duration Stores the duration pattern from the duration_unit facet in let say str . Last as if @codeend
@Returns An iterator pointing just beyond the last character that can be determined to be part of a valid name
/
template <typename Rep, typename Period>
duration<Rep, Period> & d) const
{
if (std::has_facet<duration_units<CharT> >(ios.getloc()))
{
duration_units<CharT> const&facet = std::use_facet<duration_units<CharT> >(ios.getloc());
std::basic_string<CharT> str = facet.get_pattern();
}
else
{
duration_units_default<CharT> facet;
std::basic_string<CharT> str = facet.get_pattern();
}
}
|
An iterator pointing just beyond the last character that can be determined to be part of a valid name
Referenced by boost::chrono::duration_get< CharT, InputIterator >::get().
|
inline |
References boost::regex_constants::failbit, and boost::asio::s.
|
static |
Unique identifier for this type of facet.