Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template period_parser

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

Synopsis

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

template<typename date_type, typename CharT> 
class period_parser {
public:
  // types
  typedef CharT >                ;    
  typedef CharT                                     ;      
  typedef CharT >         ;
  typedef string_parse_tree< CharT >                ;
  typedef parse_tree_type::parse_match_result_type  ;  
  typedef CharT > > ;

  enum period_range_option { AS_OPEN_RANGE, AS_CLOSED_RANGE };

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

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

  // private member functions
  void (, , 
                     const ) ;

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

For a typical date_period, the contents of the input stream would be

[

where the date format is controlled by the date facet

period_parser public construct/copy/destruct

  1. ( range_opt = , 
                  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 parser options.

period_parser public member functions

  1.  () ;
  2. void ( option);
  3.  () ;
  4. void (const  separator, 
                           const  start_delim, 
                           const  open_end_delim, 
                           const  closed_end_delim);
  5. template<typename period_type, typename duration_type, typename facet_type> 
       ( sitr,  stream_end, 
                              a_ios, const , 
                             const  dur_unit, 
                             const facet_type & facet) ;
    Generic code to parse a period – no matter the period type.

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

    The steps for parsing a period are always the same:

    • consume the start delimiter

    • get start element

    • consume the separator

    • get either last or end element depending on range settings

    • consume the end delimeter depending on range settings

    Thus for a typical date period the contents of the input stream might look like this:

    [

period_parser private member functions

  1. void ( sitr,  stream_end, 
                       const  delim) ;
    throws ios_base::failure if delimiter and parsed data do not match

PrevUpHomeNext