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::format_date_parser< date_type, charT > Class Template Reference

Class with generic date parsing using a format string. More...

#include <format_date_parser.hpp>

Inheritance diagram for boost::date_time::format_date_parser< date_type, charT >:

Public Types

typedef std::basic_string< charT > string_type
 
typedef
std::basic_istringstream
< charT > 
stringstream_type
 
typedef
std::istreambuf_iterator
< charT > 
stream_itr_type
 
typedef string_type::const_iterator const_itr
 
typedef date_type::year_type year_type
 
typedef date_type::month_type month_type
 
typedef date_type::day_type day_type
 
typedef date_type::duration_type duration_type
 
typedef date_type::day_of_week_type day_of_week_type
 
typedef date_type::day_of_year_type day_of_year_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 > > 
input_collection_type
 

Public Member Functions

 format_date_parser (const string_type &format_str, const input_collection_type &month_short_names, const input_collection_type &month_long_names, const input_collection_type &weekday_short_names, const input_collection_type &weekday_long_names)
 
 format_date_parser (const string_type &format_str, const std::locale &locale)
 
 format_date_parser (const format_date_parser< date_type, charT > &fdp)
 
string_type format () const
 
void format (string_type format_str)
 
void short_month_names (const input_collection_type &month_names)
 
void long_month_names (const input_collection_type &month_names)
 
void short_weekday_names (const input_collection_type &weekday_names)
 
void long_weekday_names (const input_collection_type &weekday_names)
 
date_type parse_date (const string_type &value, const string_type &format_str, const special_values_parser< date_type, charT > &sv_parser) const
 
date_type parse_date (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, const special_values_parser< date_type, charT > &sv_parser) const
 
date_type parse_date (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, string_type format_str, const special_values_parser< date_type, charT > &sv_parser) const
 Of all the objects that the format_date_parser can parse, only a date can be a special value. More...
 
month_type parse_month (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, string_type format_str) const
 Throws bad_month if unable to parse. More...
 
month_type parse_month (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, string_type format_str, match_results &mr) const
 Throws bad_month if unable to parse. More...
 
day_type parse_var_day_of_month (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end) const
 Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse. More...
 
day_type parse_day_of_month (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end) const
 Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse. More...
 
day_of_week_type parse_weekday (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, string_type format_str) const
 
day_of_week_type parse_weekday (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, string_type format_str, match_results &mr) const
 
year_type parse_year (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, string_type format_str) const
 throws bad_year if unable to parse More...
 
year_type parse_year (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, string_type format_str, match_results &mr) const
 throws bad_year if unable to parse More...
 

Detailed Description

template<class date_type, typename charT>
class boost::date_time::format_date_parser< date_type, charT >

Class with generic date parsing using a format string.

The following is the set of recognized format specifiers

  • a - Short weekday name
  • A - Long weekday name
  • b - Abbreviated month name
  • B - Full month name
  • d - Day of the month as decimal 01 to 31
  • j - Day of year as decimal from 001 to 366
  • m - Month name as a decimal 01 to 12
  • U - Week number 00 to 53 with first Sunday as the first day of week 1?
  • w - Weekday as decimal number 0 to 6 where Sunday == 0
  • W - Week number 00 to 53 where Monday is first day of week 1
  • x - facet default date representation
  • y - Year without the century - eg: 04 for 2004
  • Y - Year with century

The weekday specifiers (a and A) do not add to the date construction, but they provide a way to skip over the weekday names for formats that provide them.

todo – Another interesting feature that this approach could provide is an option to fill in any missing fields with the current values from the clock. So if you have m-d the parser would detect the missing year value and fill it in using the clock.

todo – What to do with the x. x in the classic facet is just bad...

Member Typedef Documentation

template<class date_type, typename charT>
typedef string_type::const_iterator boost::date_time::format_date_parser< date_type, charT >::const_itr
template<class date_type, typename charT>
typedef date_type::day_of_week_type boost::date_time::format_date_parser< date_type, charT >::day_of_week_type
template<class date_type, typename charT>
typedef date_type::day_of_year_type boost::date_time::format_date_parser< date_type, charT >::day_of_year_type
template<class date_type, typename charT>
typedef date_type::day_type boost::date_time::format_date_parser< date_type, charT >::day_type
template<class date_type, typename charT>
typedef date_type::duration_type boost::date_time::format_date_parser< date_type, charT >::duration_type
template<class date_type, typename charT>
typedef std::vector<std::basic_string<charT> > boost::date_time::format_date_parser< date_type, charT >::input_collection_type
template<class date_type, typename charT>
typedef parse_tree_type::parse_match_result_type boost::date_time::format_date_parser< date_type, charT >::match_results
template<class date_type, typename charT>
typedef date_type::month_type boost::date_time::format_date_parser< date_type, charT >::month_type
template<class date_type, typename charT>
typedef string_parse_tree<charT> boost::date_time::format_date_parser< date_type, charT >::parse_tree_type
template<class date_type, typename charT>
typedef std::istreambuf_iterator<charT> boost::date_time::format_date_parser< date_type, charT >::stream_itr_type
template<class date_type, typename charT>
typedef std::basic_string<charT> boost::date_time::format_date_parser< date_type, charT >::string_type
template<class date_type, typename charT>
typedef std::basic_istringstream<charT> boost::date_time::format_date_parser< date_type, charT >::stringstream_type
template<class date_type, typename charT>
typedef date_type::year_type boost::date_time::format_date_parser< date_type, charT >::year_type

Constructor & Destructor Documentation

template<class date_type, typename charT>
boost::date_time::format_date_parser< date_type, charT >::format_date_parser ( const string_type format_str,
const input_collection_type month_short_names,
const input_collection_type month_long_names,
const input_collection_type weekday_short_names,
const input_collection_type weekday_long_names 
)
inline
template<class date_type, typename charT>
boost::date_time::format_date_parser< date_type, charT >::format_date_parser ( const string_type format_str,
const std::locale &  locale 
)
inline
template<class date_type, typename charT>
boost::date_time::format_date_parser< date_type, charT >::format_date_parser ( const format_date_parser< date_type, charT > &  fdp)
inline

Member Function Documentation

template<class date_type, typename charT>
string_type boost::date_time::format_date_parser< date_type, charT >::format ( ) const
inline
template<class date_type, typename charT>
void boost::date_time::format_date_parser< date_type, charT >::format ( string_type  format_str)
inline
template<class date_type, typename charT>
void boost::date_time::format_date_parser< date_type, charT >::long_month_names ( const input_collection_type month_names)
inline
template<class date_type, typename charT>
void boost::date_time::format_date_parser< date_type, charT >::long_weekday_names ( const input_collection_type weekday_names)
inline
template<class date_type, typename charT>
date_type boost::date_time::format_date_parser< date_type, charT >::parse_date ( const string_type value,
const string_type format_str,
const special_values_parser< date_type, charT > &  sv_parser 
) const
inline
template<class date_type, typename charT>
date_type boost::date_time::format_date_parser< date_type, charT >::parse_date ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
const special_values_parser< date_type, charT > &  sv_parser 
) const
inline
template<class date_type, typename charT>
date_type boost::date_time::format_date_parser< date_type, charT >::parse_date ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
string_type  format_str,
const special_values_parser< date_type, charT > &  sv_parser 
) const
inline

Of all the objects that the format_date_parser can parse, only a date can be a special value.

Therefore, only parse_date checks for special_values.

template<class date_type, typename charT>
day_type boost::date_time::format_date_parser< date_type, charT >::parse_day_of_month ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end 
) const
inline

Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse.

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

template<class date_type, typename charT>
month_type boost::date_time::format_date_parser< date_type, charT >::parse_month ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
string_type  format_str 
) const
inline
template<class date_type, typename charT>
month_type boost::date_time::format_date_parser< date_type, charT >::parse_month ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
string_type  format_str,
match_results mr 
) const
inline

Throws bad_month if unable to parse.

template<class date_type, typename charT>
day_type boost::date_time::format_date_parser< date_type, charT >::parse_var_day_of_month ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end 
) const
inline

Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse.

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

template<class date_type, typename charT>
day_of_week_type boost::date_time::format_date_parser< date_type, charT >::parse_weekday ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
string_type  format_str 
) const
inline
template<class date_type, typename charT>
day_of_week_type boost::date_time::format_date_parser< date_type, charT >::parse_weekday ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
string_type  format_str,
match_results mr 
) const
inline
template<class date_type, typename charT>
year_type boost::date_time::format_date_parser< date_type, charT >::parse_year ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
string_type  format_str 
) const
inline
template<class date_type, typename charT>
year_type boost::date_time::format_date_parser< date_type, charT >::parse_year ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
string_type  format_str,
match_results mr 
) const
inline

throws bad_year if unable to parse

template<class date_type, typename charT>
void boost::date_time::format_date_parser< date_type, charT >::short_month_names ( const input_collection_type month_names)
inline
template<class date_type, typename charT>
void boost::date_time::format_date_parser< date_type, charT >::short_weekday_names ( const input_collection_type weekday_names)
inline

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