![]() |
Home | Libraries | People | FAQ | More |
namespace boost { namespace chrono { template <class CharT> class duration_punct; template <class CharT, class Traits> std::basic_ostream<CharT, Traits>& duration_short(std::basic_ostream<CharT, Traits>& os); template <class CharT, class Traits> std::basic_ostream<CharT, Traits>& duration_long(std::basic_ostream<CharT, Traits>& os); template <class CharT, class Traits, class Rep, class Period> std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d); template <class CharT, class Traits, class Rep, class Period> std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d) template <class CharT, class Traits, class Clock, class Duration> std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const time_point<Clock, Duration>& tp); template <class CharT, class Traits, class Clock, class Duration> std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& is, time_point<Clock, Duration>& tp); } }
The duration
unit names can be customized
through the facet: duration_punct
. duration
unit names come in
two varieties: long and short. The default constructed duration_punct
provides names
in the long format. These names are English descriptions. Other languages
are supported by constructing a duration_punct
with the proper
spellings for "hours", "minutes" and "seconds",
and their abbreviations (for the short format).
template <class CharT> class duration_punct : public std::locale::facet { public: typedef std::basic_string<CharT> string_type; enum {use_long, use_short}; static std::locale::id id; explicit duration_punct(int use = use_long); duration_punct(int use, const string_type& long_seconds, const string_type& long_minutes, const string_type& long_hours, const string_type& short_seconds, const string_type& short_minutes, const string_type& short_hours); duration_punct(int use, const duration_punct& d); template <class Period> string_type short_name() const; template <class Period> string_type long_name() const; template <class Period> string_type name() const; bool is_short_name() const; bool is_long_name() const; };
The short or long format can be easily chosen by streaming a duration_short
or duration_long
manipulator respectively.
template <class CharT, class Traits> std::basic_ostream<CharT, Traits>& duration_short(std::basic_ostream<CharT, Traits>& os);
Effects: Set the duration_punct
facet to stream
duration
s and time_point
s as abbreviations.
Returns: the output stream
template <class CharT, class Traits> std::basic_ostream<CharT, Traits>& duration_long(std::basic_ostream<CharT, Traits>& os);
Effects: Set the duration_punct
facet to stream
durations and time_points as long text.
Returns: the output stream
Any duration
can be streamed out
to a basic_ostream
. The
run-time value of the duration
is formatted according
to the rules and current format settings for duration
::rep
. This is followed by a single space
and then the compile-time unit name of the duration
. This unit name is
built on the string returned from ratio_string<>
and the data used to construct
the duration_punct
which was inserted
into the stream's locale. If a duration_punct
has not been
inserted into the stream's locale, a default constructed duration_punct
will be added
to the stream's locale.
A time_point
is formatted by outputting
its internal duration
followed by a string
that describes the time_point
::clock
epoch. This string will vary
for each distinct clock, and for each implementation of the supplied
clocks.
template <class CharT, class Traits, class Rep, class Period> std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d);
Effects: outputs the duration
as an abbreviated or
long text format depending on the state of the duration_punct
facet.
Returns: the output stream
template <class CharT, class Traits, class Rep, class Period> std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
Effects: reads a duration
from the input stream.
If a format error is found, the input stream state will be set to failbit
.
Returns: the input stream
template <class CharT, class Traits, class Clock, class Duration> std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const time_point<Clock, Duration>& tp);
Effects: outputs the time_point
as an abbreviated
or long text format depending on the state of the duration_punct
facet.
Returns: the output stream
template <class CharT, class Traits, class Clock, class Duration> std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& is, time_point<Clock, Duration>& tp);
Effects: reads a time_point
from the input stream.
If a format error is found, the input stream state will be set to failbit
.
Returns: the input stream