Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::chrono::duration_get< CharT, InputIterator > Class Template Reference

duration_get is used to parse a character sequence, extracting components of a duration into a class duration. More...

#include <duration_get.hpp>

Inheritance diagram for boost::chrono::duration_get< CharT, InputIterator >:
Collaboration diagram for boost::chrono::duration_get< CharT, InputIterator >:

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...
 

Detailed Description

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
class boost::chrono::duration_get< CharT, InputIterator >

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.

Member Typedef Documentation

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
typedef CharT boost::chrono::duration_get< CharT, InputIterator >::char_type

Type of character the facet is instantiated on.

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
typedef InputIterator boost::chrono::duration_get< CharT, InputIterator >::iter_type

Type of iterator used to scan the character buffer.

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
typedef std::basic_string<CharT> boost::chrono::duration_get< CharT, InputIterator >::string_type

Type of character string passed to member functions.

Constructor & Destructor Documentation

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
boost::chrono::duration_get< CharT, InputIterator >::duration_get ( size_t  refs = 0)
inlineexplicit

Construct a duration_get facet.

Parameters
refsConstruct 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.
template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
boost::chrono::duration_get< CharT, InputIterator >::~duration_get ( )
inline

Destroy the facet

Member Function Documentation

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
iter_type boost::chrono::duration_get< CharT, InputIterator >::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
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.

Parameters
facetthe duration_units facet
istart input stream iterator.
eend input stream iterator.
iosa reference to a ios_base.
errthe ios_base state.
Returns
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().

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
iter_type boost::chrono::duration_get< CharT, InputIterator >::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
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.

Parameters
facetthe duration_units facet
istart input stream iterator.
eend input stream iterator.
iosa reference to a ios_base.
errthe ios_base state.
rta 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().

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
template<typename Rep , typename Period >
iter_type boost::chrono::duration_get< CharT, InputIterator >::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
inline
Parameters
sstart input stream iterator
endend input stream iterator
iosa reference to a ios_base
errthe ios_base state
dthe duration
patternbegin of the formatting pattern
pat_endend 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:

  • The expression pattern == pat_end evaluates to true.
  • The expression err == std::ios_base::goodbit evaluates to false.
  • The expression s == end evaluates to true, in which case the function evaluates err = std::ios_base::eofbit | std::ios_base::failbit.
  • The next element of pattern is equal to '', followed by a conversion specifier character, format. If the number of elements in the range [pattern,pat_end) is not sufficient to unambiguously determine whether the conversion specification is complete and valid, the function evaluates err = std::ios_base::failbit. Otherwise, the function evaluates s = get_value(s, end, ios, err, r) when the conversion specification is 'v' and s = get_value(s, end, ios, err, rt) when the conversion specification is 'u'. If err == std::ios_base::goodbit holds after the evaluation of the expression, the function increments pattern to point just past the end of the conversion specification and continues looping.
  • The expression isspace(*pattern, ios.getloc()) evaluates to true, in which case the function first increments pattern until pattern == pat_end || !isspace(*pattern, ios.getloc()) evaluates to true, then advances s until s == end || !isspace(*s, ios.getloc()) is true, and finally resumes looping.
  • The next character read from s matches the element pointed to by pattern in a case-insensitive comparison, in which case the function evaluates ++pattern, ++s and continues looping. Otherwise, the function evaluates err = std::ios_base::failbit.

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().

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
template<typename Rep , typename Period >
iter_type boost::chrono::duration_get< CharT, InputIterator >::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
inline
template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
iter_type boost::chrono::duration_get< CharT, InputIterator >::get_unit ( iter_type  i,
iter_type  e,
std::ios_base &  is,
std::ios_base::iostate &  err,
rt_ratio rt 
) const
inline
Parameters
sstart input stream iterator
eend input stream iterator
iosa reference to a ios_base
errthe ios_base state
rta 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().

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
iter_type boost::chrono::duration_get< CharT, InputIterator >::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
inline
template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
template<typename Rep >
iter_type boost::chrono::duration_get< CharT, InputIterator >::get_value ( iter_type  s,
iter_type  end,
std::ios_base &  ios,
std::ios_base::iostate &  err,
Rep &  r 
) const
inline
Parameters
sstart input stream iterator
endend input stream iterator
iosa reference to a ios_base
errthe ios_base state
dthe duration Stores the duration pattern from the duration_unit facet in let say str. Last as if
return get(s, end, ios, err, ios, d, str.data(), str.data() + str.size());
@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>
iter_type get(iter_type s, iter_type end, std::ios_base& ios, std::ios_base::iostate& err,
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();
return get(facet, s, end, ios, err, d, str.data(), str.data() + str.size());
}
else
{
duration_units_default<CharT> facet;
std::basic_string<CharT> str = facet.get_pattern();
return get(facet, s, end, ios, err, d, str.data(), str.data() + str.size());
}
}

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().

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
template<typename Rep >
iter_type boost::chrono::duration_get< CharT, InputIterator >::get_value ( iter_type  s,
iter_type  end,
std::ios_base &  ios,
std::ios_base::iostate &  err,
process_times< Rep > &  r 
) const
inline

Member Data Documentation

template<class CharT, class InputIterator = std::istreambuf_iterator<CharT>>
std::locale::id boost::chrono::duration_get< CharT, InputIterator >::id
static

Unique identifier for this type of facet.


The documentation for this class was generated from the following file: