Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class template date_generator_formatter

boost::date_time::date_generator_formatter — Formats date_generators for output.

Synopsis

template<typename date_type, typename CharT, 
         typename OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > 
class date_generator_formatter {
public:
  // types
  typedef partial_date< date_type >        partial_date_type;
  typedef nth_kday_of_month< date_type >   nth_kday_type;    
  typedef first_kday_of_month< date_type > first_kday_type;  
  typedef last_kday_of_month< date_type >  last_kday_type;   
  typedef first_kday_after< date_type >    kday_after_type;  
  typedef first_kday_before< date_type >   kday_before_type; 
  typedef CharT                            char_type;        
  typedef std::basic_string< char_type >   string_type;      
  typedef std::vector< string_type >       collection_type;  

  enum phrase_elements { first = 0, second, third, fourth, fifth, last, 
                         before, after, of, number_of_phrase_elements };

  // construct/copy/destruct
  date_generator_formatter();
  date_generator_formatter(const string_type &, const string_type &, 
                           const string_type &, const string_type &, 
                           const string_type &, const string_type &, 
                           const string_type &, const string_type &, 
                           const string_type &);

  // public member functions
  void elements(const collection_type &, phrase_elements = first) ;
  template<typename facet_type> 
    OutItrT put_partial_date(OutItrT, std::ios_base &, CharT, 
                             const partial_date_type &, const facet_type &) const;
  template<typename facet_type> 
    OutItrT put_nth_kday(OutItrT, std::ios_base &, CharT, 
                         const nth_kday_type &, const facet_type &) const;
  template<typename facet_type> 
    OutItrT put_first_kday(OutItrT, std::ios_base &, CharT, 
                           const first_kday_type &, const facet_type &) const;
  template<typename facet_type> 
    OutItrT put_last_kday(OutItrT, std::ios_base &, CharT, 
                          const last_kday_type &, const facet_type &) const;
  template<typename facet_type> 
    OutItrT put_kday_before(OutItrT, std::ios_base &, CharT, 
                            const kday_before_type &, const facet_type &) const;
  template<typename facet_type> 
    OutItrT put_kday_after(OutItrT, std::ios_base &, CharT, 
                           const kday_after_type &, const facet_type &) const;

  // private member functions
  OutItrT put_string(OutItrT, const string_type &) const;
  static const char_type first_string;
  static const char_type second_string;
  static const char_type third_string;
  static const char_type fourth_string;
  static const char_type fifth_string;
  static const char_type last_string;
  static const char_type before_string;
  static const char_type after_string;
  static const char_type of_string;
};

Description

Formatting of date_generators follows specific orders for the various types of date_generators.

  • partial_date => "dd Month"

  • nth_day_of_the_week_in_month => "nth weekday of month"

  • first_day_of_the_week_in_month => "first weekday of month"

  • last_day_of_the_week_in_month => "last weekday of month"

  • first_day_of_the_week_after => "weekday after"

  • first_day_of_the_week_before => "weekday before" While the order of the elements in these phrases cannot be changed, the elements themselves can be. Weekday and Month get their formats and names from the date_facet. The remaining elements are stored in the date_generator_formatter and can be customized upon construction or via a member function. The default elements are those shown in the examples above.

date_generator_formatter public construct/copy/destruct

  1. date_generator_formatter();
  2. date_generator_formatter(const string_type & first, 
                             const string_type & second, 
                             const string_type & third, 
                             const string_type & fourth, 
                             const string_type & fifth, const string_type & last, 
                             const string_type & before, 
                             const string_type & after, const string_type & of);

date_generator_formatter public member functions

  1. void elements(const collection_type & new_strings, 
                  phrase_elements beg_pos = first) ;

    The order of the strings in the given collection is important. They must follow:

    • first, second, third, fourth, fifth, last, before, after, of.

    It is not necessary to send in a complete set if only a few elements are to be replaced as long as the correct beg_pos is used.

    Ex: To keep the default first through fifth elements, but replace the rest with a collection of:

    • "final", "prior", "following", "in". The beg_pos of date_generator_formatter::last would be used.

  2. template<typename facet_type> 
      OutItrT put_partial_date(OutItrT next, std::ios_base & a_ios, CharT a_fill, 
                               const partial_date_type & pd, 
                               const facet_type & facet) const;
  3. template<typename facet_type> 
      OutItrT put_nth_kday(OutItrT next, std::ios_base & a_ios, CharT a_fill, 
                           const nth_kday_type & nkd, const facet_type & facet) const;
  4. template<typename facet_type> 
      OutItrT put_first_kday(OutItrT next, std::ios_base & a_ios, CharT a_fill, 
                             const first_kday_type & fkd, 
                             const facet_type & facet) const;
  5. template<typename facet_type> 
      OutItrT put_last_kday(OutItrT next, std::ios_base & a_ios, CharT a_fill, 
                            const last_kday_type & lkd, const facet_type & facet) const;
  6. template<typename facet_type> 
      OutItrT put_kday_before(OutItrT next, std::ios_base & a_ios, CharT a_fill, 
                              const kday_before_type & fkb, 
                              const facet_type & facet) const;
  7. template<typename facet_type> 
      OutItrT put_kday_after(OutItrT next, std::ios_base & a_ios, CharT a_fill, 
                             const kday_after_type & fka, 
                             const facet_type & facet) const;

date_generator_formatter private member functions

  1. OutItrT put_string(OutItrT next, const string_type & str) const;

PrevUpHomeNext