Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template period_formatter

boost::date_time::period_formatter — Not a facet, but a class used to specify and control period formats.

Synopsis

// In header: <boost/date_time/period_formatter.hpp>

template<typename CharT, 
         typename OutItrT = CharT, CharT> > > 
class period_formatter {
public:
  // types
  typedef CharT >                     ;    
  typedef CharT                                          ;      
  typedef  ; 
  typedef CharT > >      ;

  enum range_display_options { AS_OPEN_RANGE, AS_CLOSED_RANGE };

  // construct/copy/destruct
  ( = , const const = , 
                   const const = , const const = , 
                   const const = );

  // public member functions
  OutItrT (OutItrT &) ;
  OutItrT (OutItrT &) ;
  OutItrT (OutItrT &) ;
   () ;
  void () ;
  void (const , const , 
                         const , const );
  template<typename period_type, typename facet_type> 
    OutItrT (OutItrT, , , 
                       const , const facet_type &) ;

  // public data members
  static const  default_period_separator;
  static const  default_period_start_delimeter;
  static const  default_period_open_range_end_delimeter;
  static const  default_period_closed_range_end_delimeter;
};

Description

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:

[

So for a typical date_period this would be

[

where the date formatting is controlled by the date facet

period_formatter public construct/copy/destruct

  1. ( range_option_in = , 
                     const const period_separator = , 
                     const const period_start_delimeter = , 
                     const const period_open_range_end_delimeter = , 
                     const const period_closed_range_end_delimeter = );
    Constructor that sets up period formatter options – default should suffice most cases.

period_formatter public member functions

  1. OutItrT (OutItrT & oitr) ;
    Puts the characters between period elements into stream – default is /.
  2. OutItrT (OutItrT & oitr) ;
    Puts the period start characters into stream – default is [.
  3. OutItrT (OutItrT & oitr) ;
    Puts the period end characters into stream as controled by open/closed range setting.
  4.  () ;
  5. void ( option) ;
    Reset the range_option control.
  6. void (const  separator, 
                           const  start_delim, 
                           const  open_end_delim, 
                           const  closed_end_delim);
    Change the delimiter strings.
  7. template<typename period_type, typename facet_type> 
      OutItrT (OutItrT next,  a_ios,  a_fill, 
                         const  p, const facet_type & facet) ;
    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:

    [


PrevUpHomeNext