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_parser< date_type, CharT > Class Template Reference

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

#include <period_parser.hpp>

Inheritance diagram for boost::date_time::period_parser< date_type, CharT >:

Public Types

enum  period_range_option {
  AS_OPEN_RANGE,
  AS_CLOSED_RANGE
}
 
typedef std::basic_string< CharT > string_type
 
typedef CharT char_type
 
typedef
std::istreambuf_iterator
< CharT > 
stream_itr_type
 
typedef string_parse_tree< CharT > parse_tree_type
 
typedef
parse_tree_type::parse_match_result_type 
match_results
 
typedef std::vector
< std::basic_string< CharT > > 
collection_type
 

Public Member Functions

 period_parser (period_range_option range_opt=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 parser options. More...
 
 period_parser (const period_parser< date_type, CharT > &p_parser)
 
period_range_option range_option () const
 
void range_option (period_range_option option)
 
collection_type delimiter_strings () const
 
void delimiter_strings (const string_type &separator, const string_type &start_delim, const string_type &open_end_delim, const string_type &closed_end_delim)
 
template<class period_type , class duration_type , class facet_type >
period_type get_period (stream_itr_type &sitr, stream_itr_type &stream_end, std::ios_base &a_ios, const period_type &, const duration_type &dur_unit, const facet_type &facet) const
 Generic code to parse 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 date_type, typename CharT>
class boost::date_time::period_parser< date_type, CharT >

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

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

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

where the date format is controlled by the date facet

Member Typedef Documentation

template<class date_type, typename CharT>
typedef CharT boost::date_time::period_parser< date_type, CharT >::char_type
template<class date_type, typename CharT>
typedef std::vector<std::basic_string<CharT> > boost::date_time::period_parser< date_type, CharT >::collection_type
template<class date_type, typename CharT>
typedef parse_tree_type::parse_match_result_type boost::date_time::period_parser< date_type, CharT >::match_results
template<class date_type, typename CharT>
typedef string_parse_tree<CharT> boost::date_time::period_parser< date_type, CharT >::parse_tree_type
template<class date_type, typename CharT>
typedef std::istreambuf_iterator<CharT> boost::date_time::period_parser< date_type, CharT >::stream_itr_type
template<class date_type, typename CharT>
typedef std::basic_string<CharT> boost::date_time::period_parser< date_type, CharT >::string_type

Member Enumeration Documentation

template<class date_type, typename CharT>
enum boost::date_time::period_parser::period_range_option
Enumerator
AS_OPEN_RANGE 
AS_CLOSED_RANGE 

Constructor & Destructor Documentation

template<class date_type, typename CharT>
boost::date_time::period_parser< date_type, CharT >::period_parser ( period_range_option  range_opt = 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 parser options.

template<class date_type, typename CharT>
boost::date_time::period_parser< date_type, CharT >::period_parser ( const period_parser< date_type, CharT > &  p_parser)
inline

Member Function Documentation

template<class date_type, typename CharT>
collection_type boost::date_time::period_parser< date_type, CharT >::delimiter_strings ( ) const
inline
template<class date_type, typename CharT>
void boost::date_time::period_parser< date_type, CharT >::delimiter_strings ( const string_type separator,
const string_type start_delim,
const string_type open_end_delim,
const string_type closed_end_delim 
)
inline
template<class date_type, typename CharT>
template<class period_type , class duration_type , class facet_type >
period_type boost::date_time::period_parser< date_type, CharT >::get_period ( stream_itr_type sitr,
stream_itr_type stream_end,
std::ios_base &  a_ios,
const period_type &  ,
const duration_type &  dur_unit,
const facet_type &  facet 
) const
inline

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:

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

Referenced by boost::date_time::date_input_facet< time_type::date_type, CharT, InItrT >::get(), and boost::date_time::time_input_facet< time_type, CharT, InItrT >::get().

template<class date_type, typename CharT>
period_range_option boost::date_time::period_parser< date_type, CharT >::range_option ( ) const
inline
template<class date_type, typename CharT>
void boost::date_time::period_parser< date_type, CharT >::range_option ( period_range_option  option)
inline

Member Data Documentation

template<class date_type, typename CharT>
const period_parser< date_type, char_type >::char_type boost::date_time::period_parser< date_type, char_type >::default_period_closed_range_end_delimeter = {']'}
static
template<class date_type, typename CharT>
const period_parser< date_type, char_type >::char_type boost::date_time::period_parser< date_type, char_type >::default_period_open_range_end_delimeter = {')'}
static
template<class date_type, typename CharT>
const period_parser< date_type, char_type >::char_type boost::date_time::period_parser< date_type, char_type >::default_period_separator = {'/'}
static
template<class date_type, typename CharT>
const period_parser< date_type, char_type >::char_type boost::date_time::period_parser< date_type, char_type >::default_period_start_delimeter = {'['}
static

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