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

Not a facet, but a class used to specify and control period formats. More...

#include <period_formatter.hpp>

Inheritance diagram for boost::date_time::period_formatter< CharT, OutItrT >:

Public Types

enum  range_display_options {
  AS_OPEN_RANGE,
  AS_CLOSED_RANGE
}
 
typedef std::basic_string< CharT > string_type
 
typedef CharT char_type
 
typedef std::basic_string
< char_type >::const_iterator 
const_itr_type
 
typedef std::vector
< std::basic_string< CharT > > 
collection_type
 

Public Member Functions

 period_formatter (range_display_options range_option_in=AS_CLOSED_RANGE, const char_type *const period_separator=default_period_separator, const char_type *const period_start_delimeter=default_period_start_delimeter, const char_type *const period_open_range_end_delimeter=default_period_open_range_end_delimeter, const char_type *const period_closed_range_end_delimeter=default_period_closed_range_end_delimeter)
 Constructor that sets up period formatter options – default should suffice most cases. More...
 
OutItrT put_period_separator (OutItrT &oitr) const
 Puts the characters between period elements into stream – default is /. More...
 
OutItrT put_period_start_delimeter (OutItrT &oitr) const
 Puts the period start characters into stream – default is [. More...
 
OutItrT put_period_end_delimeter (OutItrT &oitr) const
 Puts the period end characters into stream as controled by open/closed range setting. More...
 
range_display_options range_option () const
 
void range_option (range_display_options option) const
 Reset the range_option control. More...
 
void delimiter_strings (const string_type &, const string_type &, const string_type &, const string_type &)
 
template<class period_type , class facet_type >
OutItrT put_period (OutItrT next, std::ios_base &a_ios, char_type a_fill, const period_type &p, const facet_type &facet) const
 Generic code to output a period – no matter the period type. More...
 

Static Public Attributes

static const char_type default_period_separator [2] = {'/'}
 
static const char_type default_period_start_delimeter [2] = {'['}
 
static const char_type default_period_open_range_end_delimeter [2] = {')'}
 
static const char_type default_period_closed_range_end_delimeter [2] = {']'}
 

Detailed Description

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
class boost::date_time::period_formatter< CharT, OutItrT >

Not a facet, but a class used to specify and control period formats.

Provides settings for the following:

  • period_separator – default '/'
  • period_open_start_delimeter – default '['
  • period_open_range_end_delimeter – default ')'
  • period_closed_range_end_delimeter – default ']'
  • display_as_open_range, display_as_closed_range – default closed_range

Thus the default formatting for a period is as follows:

[period.start()/period.last()]

So for a typical date_period this would be

[2004-Jan-04/2004-Feb-01]

where the date formatting is controlled by the date facet

Member Typedef Documentation

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
typedef CharT boost::date_time::period_formatter< CharT, OutItrT >::char_type
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
typedef std::vector<std::basic_string<CharT> > boost::date_time::period_formatter< CharT, OutItrT >::collection_type
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
typedef std::basic_string<char_type>::const_iterator boost::date_time::period_formatter< CharT, OutItrT >::const_itr_type
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
typedef std::basic_string<CharT> boost::date_time::period_formatter< CharT, OutItrT >::string_type

Member Enumeration Documentation

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
enum boost::date_time::period_formatter::range_display_options
Enumerator
AS_OPEN_RANGE 
AS_CLOSED_RANGE 

Constructor & Destructor Documentation

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
boost::date_time::period_formatter< CharT, OutItrT >::period_formatter ( range_display_options  range_option_in = AS_CLOSED_RANGE,
const char_type *const  period_separator = default_period_separator,
const char_type *const  period_start_delimeter = default_period_start_delimeter,
const char_type *const  period_open_range_end_delimeter = default_period_open_range_end_delimeter,
const char_type *const  period_closed_range_end_delimeter = default_period_closed_range_end_delimeter 
)
inline

Constructor that sets up period formatter options – default should suffice most cases.

Member Function Documentation

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
void boost::date_time::period_formatter< CharT, OutItrT >::delimiter_strings ( const string_type ,
const string_type ,
const string_type ,
const string_type  
)
inline
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
template<class period_type , class facet_type >
OutItrT boost::date_time::period_formatter< CharT, OutItrT >::put_period ( OutItrT  next,
std::ios_base &  a_ios,
char_type  a_fill,
const period_type &  p,
const facet_type &  facet 
) const
inline

Generic code to output a period – no matter the period type.

This generic code will output any period using a facet to to output the 'elements'. For example, in the case of a date_period the elements will be instances of a date which will be formatted according the to setup in the passed facet parameter.

The steps for formatting a period are always the same:

  • put the start delimiter
  • put start element
  • put the separator
  • put either last or end element depending on range settings
  • put end delimeter depending on range settings

Thus for a typical date period the result might look like this:

[March 01, 2004/June 07, 2004] <-- closed range
[March 01, 2004/June 08, 2004) <-- open range

Referenced by boost::date_time::date_facet< time_type::date_type, CharT, OutItrT >::put(), and boost::date_time::time_facet< time_type, CharT, OutItrT >::put().

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
OutItrT boost::date_time::period_formatter< CharT, OutItrT >::put_period_end_delimeter ( OutItrT &  oitr) const
inline

Puts the period end characters into stream as controled by open/closed range setting.

Referenced by boost::date_time::period_formatter< CharT >::put_period().

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
OutItrT boost::date_time::period_formatter< CharT, OutItrT >::put_period_separator ( OutItrT &  oitr) const
inline

Puts the characters between period elements into stream – default is /.

Referenced by boost::date_time::period_formatter< CharT >::put_period().

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
OutItrT boost::date_time::period_formatter< CharT, OutItrT >::put_period_start_delimeter ( OutItrT &  oitr) const
inline

Puts the period start characters into stream – default is [.

Referenced by boost::date_time::period_formatter< CharT >::put_period().

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
range_display_options boost::date_time::period_formatter< CharT, OutItrT >::range_option ( ) const
inline
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
void boost::date_time::period_formatter< CharT, OutItrT >::range_option ( range_display_options  option) const
inline

Reset the range_option control.

Member Data Documentation

template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
const period_formatter< CharT, OutItrT >::char_type boost::date_time::period_formatter< CharT, OutItrT >::default_period_closed_range_end_delimeter = {']'}
static
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
const period_formatter< CharT, OutItrT >::char_type boost::date_time::period_formatter< CharT, OutItrT >::default_period_open_range_end_delimeter = {')'}
static
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
const period_formatter< CharT, OutItrT >::char_type boost::date_time::period_formatter< CharT, OutItrT >::default_period_separator = {'/'}
static
template<class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> >>
const period_formatter< CharT, OutItrT >::char_type boost::date_time::period_formatter< CharT, OutItrT >::default_period_start_delimeter = {'['}
static

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