Ticket #7234: warnings.patch
File warnings.patch, 32.6 KB (added by , 10 years ago) |
---|
-
time_duration.hpp
2 2 #define DATE_TIME_TIME_DURATION_HPP___ 3 3 4 4 /* Copyright (c) 2002,2003 CrystalClear Software, Inc. 5 * Use, modification and distribution is subject to the 5 * Use, modification and distribution is subject to the 6 6 * Boost Software License, Version 1.0. (See accompanying 7 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 8 8 * Author: Jeff Garland, Bart Garst … … 179 179 return duration_type(ticks_); 180 180 } 181 181 //! Division operations on a duration with an integer. 182 duration_type operator/=(int divisor) 182 duration_type operator/=(int divisor) 183 183 { 184 184 ticks_ = ticks_ / divisor; 185 185 return duration_type(ticks_); … … 251 251 } 252 252 253 253 protected: 254 explicit time_duration(impl_type in) : ticks_(in) {} ;254 explicit time_duration(impl_type in) : ticks_(in) {} 255 255 impl_type ticks_; 256 256 }; 257 257 -
dst_rules.hpp
371 371 return is_not_in_dst; 372 372 } 373 373 374 static bool is_dst_boundary_day(date_type d)374 static bool is_dst_boundary_day(date_type ) 375 375 { 376 376 return false; 377 377 } -
period_formatter.hpp
114 114 { 115 115 m_range_option = option; 116 116 } 117 void delimiter_strings(const string_type& separator,118 const string_type& start_delim,119 const string_type& open_end_delim,120 const string_type& closed_end_delim)117 void delimiter_strings(const string_type& , 118 const string_type& , 119 const string_type& , 120 const string_type& ) 121 121 { 122 122 m_period_separator; 123 123 m_period_start_delimeter; -
date_generators.hpp
2 2 #define DATE_TIME_DATE_GENERATORS_HPP__ 3 3 4 4 /* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. 5 * Use, modification and distribution is subject to the 5 * Use, modification and distribution is subject to the 6 6 * Boost Software License, Version 1.0. (See accompanying 7 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 8 * Author: Jeff Garland, Bart Garst 8 * Author: Jeff Garland, Bart Garst 9 9 * $Date$ 10 10 */ 11 11 … … 34 34 public: 35 35 typedef typename date_type::calendar_type calendar_type; 36 36 typedef typename calendar_type::year_type year_type; 37 year_based_generator() {} ;38 virtual ~year_based_generator() {} ;37 year_based_generator() {} 38 virtual ~year_based_generator() {} 39 39 virtual date_type get_date(year_type y) const = 0; 40 40 //! Returns a string for use in a POSIX time_zone string 41 41 virtual std::string to_string() const =0; 42 42 }; 43 43 44 44 //! Generates a date by applying the year to the given month and day. 45 45 /*! 46 Example usage: 46 Example usage: 47 47 @code 48 48 partial_date pd(1, Jan); 49 49 partial_date pd2(70); … … 123 123 //months are equal 124 124 return (day_ < rhs.day_); 125 125 } 126 126 127 127 // added for streaming purposes 128 month_type month() const 128 month_type month() const 129 129 { 130 130 return month_; 131 131 } … … 135 135 } 136 136 137 137 //! Returns string suitable for use in POSIX time zone string 138 /*! Returns string formatted with up to 3 digits: 139 * Jan-01 == "0" 138 /*! Returns string formatted with up to 3 digits: 139 * Jan-01 == "0" 140 140 * Feb-29 == "58" 141 141 * Dec-31 == "365" */ 142 142 virtual std::string to_string() const 143 143 { 144 144 std::ostringstream ss; 145 145 date_type d(2004, month_, day_); 146 unsigned short c = d.day_of_year(); 146 unsigned short c = d.day_of_year(); 147 147 c--; // numbered 0-365 while day_of_year is 1 based... 148 148 ss << c; 149 149 return ss.str(); … … 161 161 /*! Based on the idea in Cal. Calc. for finding holidays that are 162 162 * the 'first Monday of September'. When instantiated with 163 163 * 'fifth' kday of month, the result will be the last kday of month 164 * which can be the fourth or fifth depending on the structure of 164 * which can be the fourth or fifth depending on the structure of 165 165 * the month. 166 166 * 167 167 * The algorithm here basically guesses for the first … … 169 169 * type. That is, if the first of the month is a Tuesday 170 170 * and it needs Wenesday then we simply increment by a day 171 171 * and then we can add the length of a week until we get 172 * to the 'nth kday'. There are probably more efficient 173 * algorithms based on using a mod 7, but this one works 172 * to the 'nth kday'. There are probably more efficient 173 * algorithms based on using a mod 7, but this one works 174 174 * reasonably well for basic applications. 175 175 * \ingroup date_alg 176 176 */ … … 233 233 virtual std::string to_string() const 234 234 { 235 235 std::ostringstream ss; 236 ss << 'M' 236 ss << 'M' 237 237 << static_cast<int>(month_) << '.' 238 238 << static_cast<int>(wn_) << '.' 239 239 << static_cast<int>(dow_); … … 244 244 week_num wn_; 245 245 day_of_week_type dow_; 246 246 }; 247 247 248 248 //! Useful generator functor for finding holidays and daylight savings 249 249 /*! Similar to nth_kday_of_month, but requires less paramters 250 250 * \ingroup date_alg … … 290 290 virtual std::string to_string() const 291 291 { 292 292 std::ostringstream ss; 293 ss << 'M' 293 ss << 'M' 294 294 << static_cast<int>(month_) << '.' 295 295 << 1 << '.' 296 296 << static_cast<int>(dow_); … … 300 300 month_type month_; 301 301 day_of_week_type dow_; 302 302 }; 303 304 305 303 304 305 306 306 //! Calculate something like Last Sunday of January 307 307 /*! Useful generator functor for finding holidays and daylight savings 308 308 * Get the last day of the month and then calculate the difference … … 351 351 virtual std::string to_string() const 352 352 { 353 353 std::ostringstream ss; 354 ss << 'M' 354 ss << 'M' 355 355 << static_cast<int>(month_) << '.' 356 356 << 5 << '.' 357 357 << static_cast<int>(dow_); … … 361 361 month_type month_; 362 362 day_of_week_type dow_; 363 363 }; 364 365 364 365 366 366 //! Calculate something like "First Sunday after Jan 1,2002 367 367 /*! Date generator that takes a date and finds kday after 368 368 *@code … … 400 400 private: 401 401 day_of_week_type dow_; 402 402 }; 403 403 404 404 //! Calculate something like "First Sunday before Jan 1,2002 405 405 /*! Date generator that takes a date and finds kday after 406 406 *@code … … 438 438 private: 439 439 day_of_week_type dow_; 440 440 }; 441 441 442 442 //! Calculates the number of days until the next weekday 443 443 /*! Calculates the number of days until the next weekday. 444 * If the date given falls on a Sunday and the given weekday 444 * If the date given falls on a Sunday and the given weekday 445 445 * is Tuesday the result will be 2 days */ 446 446 template<typename date_type, class weekday_type> 447 447 inline … … 458 458 459 459 //! Calculates the number of days since the previous weekday 460 460 /*! Calculates the number of days since the previous weekday 461 * If the date given falls on a Sunday and the given weekday 462 * is Tuesday the result will be 5 days. The answer will be a positive 461 * If the date given falls on a Sunday and the given weekday 462 * is Tuesday the result will be 5 days. The answer will be a positive 463 463 * number because Tuesday is 5 days before Sunday, not -5 days before. */ 464 464 template<typename date_type, class weekday_type> 465 465 inline … … 477 477 } 478 478 479 479 //! Generates a date object representing the date of the following weekday from the given date 480 /*! Generates a date object representing the date of the following 481 * weekday from the given date. If the date given is 2004-May-9 482 * (a Sunday) and the given weekday is Tuesday then the resulting date 480 /*! Generates a date object representing the date of the following 481 * weekday from the given date. If the date given is 2004-May-9 482 * (a Sunday) and the given weekday is Tuesday then the resulting date 483 483 * will be 2004-May-11. */ 484 484 template<class date_type, class weekday_type> 485 485 inline … … 489 489 } 490 490 491 491 //! Generates a date object representing the date of the previous weekday from the given date 492 /*! Generates a date object representing the date of the previous 493 * weekday from the given date. If the date given is 2004-May-9 494 * (a Sunday) and the given weekday is Tuesday then the resulting date 492 /*! Generates a date object representing the date of the previous 493 * weekday from the given date. If the date given is 2004-May-9 494 * (a Sunday) and the given weekday is Tuesday then the resulting date 495 495 * will be 2004-May-4. */ 496 496 template<class date_type, class weekday_type> 497 497 inline -
date.hpp
191 191 dates. It is not exposed to users since that would require class 192 192 users to understand the inner workings of the date class. 193 193 */ 194 explicit date(date_int_type days) : days_(days) {} ;195 explicit date(date_rep_type days) : days_(days.as_number()) {} ;194 explicit date(date_int_type days) : days_(days) {} 195 explicit date(date_rep_type days) : days_(days.as_number()) {} 196 196 date_int_type days_; 197 197 198 198 }; -
local_time/posix_time_zone.hpp
115 115 calc_rules(dst_begin, dst_end); 116 116 } 117 117 } 118 virtual ~posix_time_zone_base() {} ;118 virtual ~posix_time_zone_base() {} 119 119 //!String for the zone when not in daylight savings (eg: EST) 120 120 virtual string_type std_zone_abbrev()const 121 121 { -
local_time/custom_time_zone.hpp
2 2 #define LOCAL_TIME_CUSTOM_TIME_ZONE_HPP__ 3 3 4 4 /* Copyright (c) 2003-2005 CrystalClear Software, Inc. 5 * Subject to the Boost Software License, Version 1.0. 5 * Subject to the Boost Software License, Version 1.0. 6 6 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 7 * Author: Jeff Garland, Bart Garst 8 8 * $Date$ … … 34 34 typedef typename base_type::stringstream_type stringstream_type; 35 35 typedef date_time::time_zone_names_base<CharT> time_zone_names; 36 36 typedef CharT char_type; 37 38 custom_time_zone_base(const time_zone_names& zone_names, 37 38 custom_time_zone_base(const time_zone_names& zone_names, 39 39 const time_duration_type& utc_offset, 40 40 const dst_adjustment_offsets& dst_shift, 41 41 boost::shared_ptr<dst_calc_rule> calc_rule) : … … 43 43 base_utc_offset_(utc_offset), 44 44 dst_offsets_(dst_shift), 45 45 dst_calc_rules_(calc_rule) 46 {} ;47 virtual ~custom_time_zone_base() {} ;46 {} 47 virtual ~custom_time_zone_base() {} 48 48 virtual string_type dst_zone_abbrev() const 49 49 { 50 50 return zone_names_.dst_zone_abbrev(); -
local_time/local_date_time.hpp
208 208 } 209 209 210 210 //! Simple destructor, releases time zone if last referrer 211 ~local_date_time_base() {} ;211 ~local_date_time_base() {} 212 212 213 213 //! Copy constructor 214 214 local_date_time_base(const local_date_time_base& rhs) : -
time_zone_base.hpp
2 2 #define _DATE_TIME_TIME_ZONE_BASE__ 3 3 4 4 /* Copyright (c) 2003-2005 CrystalClear Software, Inc. 5 * Subject to the Boost Software License, Version 1.0. 5 * Subject to the Boost Software License, Version 1.0. 6 6 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 7 * Author: Jeff Garland, Bart Garst 8 8 * $Date$ … … 26 26 * would be to convert from POSIX timezone strings. Regardless of 27 27 * the construction technique, this is the interface that these 28 28 * time zone types must provide. 29 * 29 * 30 30 * Note that this class is intended to be used as a shared 31 * resource (hence the derivation from boost::counted_base. 31 * resource (hence the derivation from boost::counted_base. 32 32 */ 33 33 template<typename time_type, typename CharT> 34 34 class time_zone_base { … … 39 39 typedef typename time_type::date_type::year_type year_type; 40 40 typedef typename time_type::time_duration_type time_duration_type; 41 41 42 time_zone_base() {} ;43 virtual ~time_zone_base() {} ;42 time_zone_base() {} 43 virtual ~time_zone_base() {} 44 44 //!String for the timezone when in daylight savings (eg: EDT) 45 45 virtual string_type dst_zone_abbrev() const=0; 46 46 //!String for the zone when not in daylight savings (eg: EST) … … 61 61 virtual time_duration_type dst_offset() const=0; 62 62 //! Returns a POSIX time_zone string for this object 63 63 virtual string_type to_posix_string() const =0; 64 64 65 65 private: 66 66 67 67 }; 68 68 69 69 … … 82 82 dst_start_offset_(dst_start_offset), 83 83 dst_end_offset_(dst_end_offset) 84 84 {} 85 85 86 86 //! Amount DST adjusts the clock eg: plus one hour 87 87 time_duration_type dst_adjust_; 88 88 //! Time past midnight on start transition day that dst starts -
date_iterator.hpp
2 2 #define DATE_ITERATOR_HPP___ 3 3 4 4 /* Copyright (c) 2002,2003 CrystalClear Software, Inc. 5 * Use, modification and distribution is subject to the 5 * Use, modification and distribution is subject to the 6 6 * Boost Software License, Version 1.0. (See accompanying 7 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 8 8 * Author: Jeff Garland, Bart Garst … … 32 32 template<class date_type> 33 33 class date_itr_base { 34 34 // works, but benefit unclear at the moment 35 // class date_itr_base : public std::iterator<std::input_iterator_tag, 35 // class date_itr_base : public std::iterator<std::input_iterator_tag, 36 36 // date_type, void, void, void>{ 37 37 public: 38 38 typedef typename date_type::duration_type duration_type; … … 40 40 typedef std::input_iterator_tag iterator_category; 41 41 42 42 date_itr_base(date_type d) : current_(d) {} 43 virtual ~date_itr_base() {} ;44 date_itr_base& operator++() 43 virtual ~date_itr_base() {} 44 date_itr_base& operator++() 45 45 { 46 46 current_ = current_ + get_offset(current_); 47 47 return *this; 48 48 } 49 date_itr_base& operator--() 49 date_itr_base& operator--() 50 50 { 51 51 current_ = current_ + get_neg_offset(current_); 52 52 return *this; 53 53 } 54 54 virtual duration_type get_offset(const date_type& current) const=0; 55 55 virtual duration_type get_neg_offset(const date_type& current) const=0; 56 date_type operator*() {return current_;} ;57 date_type* operator->() {return ¤t_;} ;56 date_type operator*() {return current_;} 57 date_type* operator->() {return ¤t_;} 58 58 bool operator< (const date_type& d) {return current_ < d;} 59 59 bool operator<= (const date_type& d) {return current_ <= d;} 60 60 bool operator> (const date_type& d) {return current_ > d;} 61 61 bool operator>= (const date_type& d) {return current_ >= d;} 62 62 bool operator== (const date_type& d) {return current_ == d;} 63 bool operator!= (const date_type& d) {return current_ != d;} 63 bool operator!= (const date_type& d) {return current_ != d;} 64 64 private: 65 65 date_type current_; 66 66 }; 67 67 68 68 //! Overrides the base date iterator providing hook for functors 69 69 /* 70 70 * <b>offset_functor</b> … … 77 77 class date_itr : public date_itr_base<date_type> { 78 78 public: 79 79 typedef typename date_type::duration_type duration_type; 80 date_itr(date_type d, int factor=1) : 81 date_itr_base<date_type>(d), 82 of_(factor) 80 date_itr(date_type d, int factor=1) : 81 date_itr_base<date_type>(d), 82 of_(factor) 83 83 {} 84 84 private: 85 85 virtual duration_type get_offset(const date_type& current) const … … 92 92 } 93 93 offset_functor of_; 94 94 }; 95 96 95 97 96 97 98 98 } } //namespace date_time 99 99 100 100 -
date_names_put.hpp
2 2 #define DATE_TIME_DATE_NAMES_PUT_HPP___ 3 3 4 4 /* Copyright (c) 2002-2005 CrystalClear Software, Inc. 5 * Use, modification and distribution is subject to the 5 * Use, modification and distribution is subject to the 6 6 * Boost Software License, Version 1.0. (See accompanying 7 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 8 * Author: Jeff Garland, Bart Garst 8 * Author: Jeff Garland, Bart Garst 9 9 * $Date$ 10 10 */ 11 11 … … 27 27 //! Output facet base class for gregorian dates. 28 28 /*! This class is a base class for date facets used to localize the 29 29 * names of months and the names of days in the week. 30 * 30 * 31 31 * Requirements of Config 32 * - define an enumeration month_enum that enumerates the months. 32 * - define an enumeration month_enum that enumerates the months. 33 33 * The enumeration should be '1' based eg: Jan==1 34 34 * - define as_short_string and as_long_string 35 35 * 36 36 * (see langer & kreft p334). 37 * 37 * 38 38 */ 39 39 template<class Config, 40 class charT = char, 40 class charT = char, 41 41 class OutputIterator = std::ostreambuf_iterator<charT> > 42 42 class date_names_put : public std::locale::facet 43 43 { 44 44 public: 45 date_names_put() {} ;45 date_names_put() {} 46 46 typedef OutputIterator iter_type; 47 47 typedef typename Config::month_type month_type; 48 48 typedef typename Config::month_enum month_enum; … … 118 118 put_string(oitr, gm.as_short_string(c)); 119 119 } 120 120 //! Default facet implementation uses month_type defaults 121 virtual void do_put_month_long(iter_type& oitr, 121 virtual void do_put_month_long(iter_type& oitr, 122 122 month_enum moy) const 123 123 { 124 124 month_type gm(moy); … … 160 160 string_type s(separator); //put in '-' 161 161 put_string(oitr, s); 162 162 } 163 //! Default for date order 163 //! Default for date order 164 164 virtual ymd_order_spec do_date_order() const 165 165 { 166 166 return ymd_order_iso; … … 186 186 } 187 187 } 188 188 }; 189 189 190 190 template<class Config, class charT, class OutputIterator> 191 const typename date_names_put<Config, charT, OutputIterator>::char_type 192 date_names_put<Config, charT, OutputIterator>::default_special_value_names[3][17] = { 191 const typename date_names_put<Config, charT, OutputIterator>::char_type 192 date_names_put<Config, charT, OutputIterator>::default_special_value_names[3][17] = { 193 193 {'n','o','t','-','a','-','d','a','t','e','-','t','i','m','e'}, 194 194 {'-','i','n','f','i','n','i','t','y'}, 195 195 {'+','i','n','f','i','n','i','t','y'} }; 196 196 197 197 template<class Config, class charT, class OutputIterator> 198 const typename date_names_put<Config, charT, OutputIterator>::char_type 199 date_names_put<Config, charT, OutputIterator>::separator[2] = 198 const typename date_names_put<Config, charT, OutputIterator>::char_type 199 date_names_put<Config, charT, OutputIterator>::separator[2] = 200 200 {'-', '\0'} ; 201 202 201 203 //! Generate storage location for a std::locale::id 202 203 //! Generate storage location for a std::locale::id 204 204 template<class Config, class charT, class OutputIterator> 205 205 std::locale::id date_names_put<Config, charT, OutputIterator>::id; 206 206 207 207 //! A date name output facet that takes an array of char* to define strings 208 208 template<class Config, 209 class charT = char, 209 class charT = char, 210 210 class OutputIterator = std::ostreambuf_iterator<charT> > 211 211 class all_date_names_put : public date_names_put<Config, charT, OutputIterator> 212 212 { … … 230 230 separator_char_[0] = separator_char; 231 231 separator_char_[1] = '\0'; 232 232 233 } ;233 } 234 234 typedef OutputIterator iter_type; 235 235 typedef typename Config::month_enum month_enum; 236 236 typedef typename Config::weekday_enum weekday_enum; 237 237 typedef typename Config::special_value_enum special_value_enum; 238 238 239 const charT* const* get_short_month_names() const 239 const charT* const* get_short_month_names() const 240 240 { 241 241 return month_short_names_; 242 242 } 243 const charT* const* get_long_month_names() const 243 const charT* const* get_long_month_names() const 244 244 { 245 245 return month_long_names_; 246 246 } 247 const charT* const* get_special_value_names() const 247 const charT* const* get_special_value_names() const 248 248 { 249 249 return special_value_names_; 250 250 } 251 const charT* const* get_short_weekday_names()const 251 const charT* const* get_short_weekday_names()const 252 252 { 253 253 return weekday_short_names_; 254 254 } 255 const charT* const* get_long_weekday_names()const 255 const charT* const* get_long_weekday_names()const 256 256 { 257 257 return weekday_long_names_; 258 258 } … … 263 263 { 264 264 this->put_string(oitr, month_short_names_[moy-1]); 265 265 } 266 //! Long month names 266 //! Long month names 267 267 virtual void do_put_month_long(iter_type& oitr, month_enum moy) const 268 268 { 269 269 this->put_string(oitr, month_long_names_[moy-1]); … … 310 310 const charT* const* weekday_long_names_; 311 311 charT separator_char_[2]; 312 312 ymd_order_spec order_spec_; 313 month_format_spec month_format_spec_; 313 month_format_spec month_format_spec_; 314 314 }; 315 315 316 316 } } //namespace boost::date_time -
dst_transition_generators.hpp
18 18 { 19 19 public: 20 20 typedef typename date_type::year_type year_type; 21 virtual ~dst_day_calc_rule() {} ;21 virtual ~dst_day_calc_rule() {} 22 22 virtual date_type start_day(year_type y) const=0; 23 23 virtual std::string start_rule_as_string() const=0; 24 24 virtual date_type end_day(year_type y) const=0; -
wrapping_int.hpp
2 2 #define _DATE_TIME_WRAPPING_INT_HPP__ 3 3 4 4 /* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. 5 * Use, modification and distribution is subject to the 5 * Use, modification and distribution is subject to the 6 6 * Boost Software License, Version 1.0. (See accompanying 7 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 8 8 * Author: Jeff Garland, Bart Garst … … 16 16 //! A wrapping integer used to support time durations (WARNING: only instantiate with a signed type) 17 17 /*! In composite date and time types this type is used to 18 18 * wrap at the day boundary. 19 * Ex: 20 * A wrapping_int<short, 10> will roll over after nine, and 19 * Ex: 20 * A wrapping_int<short, 10> will roll over after nine, and 21 21 * roll under below zero. This gives a range of [0,9] 22 22 * 23 * NOTE: it is strongly recommended that wrapping_int2 be used 24 * instead of wrapping_int as wrapping_int is to be depricated 23 * NOTE: it is strongly recommended that wrapping_int2 be used 24 * instead of wrapping_int as wrapping_int is to be depricated 25 25 * at some point soon. 26 26 * 27 * Also Note that warnings will occur if instantiated with an 27 * Also Note that warnings will occur if instantiated with an 28 28 * unsigned type. Only a signed type should be used! 29 29 */ 30 30 template<typename int_type_, int_type_ wrap_val> … … 34 34 //typedef overflow_type_ overflow_type; 35 35 static int_type wrap_value() {return wrap_val;} 36 36 //!Add, return true if wrapped 37 wrapping_int(int_type v) : value_(v) {} ;37 wrapping_int(int_type v) : value_(v) {} 38 38 //! Explicit converion method 39 39 int_type as_int() const {return value_;} 40 40 operator int_type() const {return value_;} 41 41 //!Add, return number of wraps performed 42 /*! The sign of the returned value will indicate which direction the 42 /*! The sign of the returned value will indicate which direction the 43 43 * wraps went. Ex: add a negative number and wrapping under could occur, 44 * this would be indicated by a negative return value. If wrapping over 44 * this would be indicated by a negative return value. If wrapping over 45 45 * took place, a positive value would be returned */ 46 46 template< typename IntT > 47 IntT add(IntT v) 47 IntT add(IntT v) 48 48 { 49 49 int_type remainder = static_cast<int_type>(v % (wrap_val)); 50 50 IntT overflow = static_cast<IntT>(v / (wrap_val)); … … 53 53 } 54 54 //! Subtract will return '+d' if wrapping under took place ('d' is the number of wraps) 55 55 /*! The sign of the returned value will indicate which direction the 56 * wraps went (positive indicates wrap under, negative indicates wrap over). 57 * Ex: subtract a negative number and wrapping over could 58 * occur, this would be indicated by a negative return value. If 56 * wraps went (positive indicates wrap under, negative indicates wrap over). 57 * Ex: subtract a negative number and wrapping over could 58 * occur, this would be indicated by a negative return value. If 59 59 * wrapping under took place, a positive value would be returned. */ 60 60 template< typename IntT > 61 IntT subtract(IntT v) 61 IntT subtract(IntT v) 62 62 { 63 63 int_type remainder = static_cast<int_type>(v % (wrap_val)); 64 64 IntT underflow = static_cast<IntT>(-(v / (wrap_val))); … … 71 71 template< typename IntT > 72 72 IntT calculate_wrap(IntT wrap) 73 73 { 74 if ((value_) >= wrap_val) 74 if ((value_) >= wrap_val) 75 75 { 76 76 ++wrap; 77 77 value_ -= (wrap_val); 78 78 } 79 else if(value_ < 0) 79 else if(value_ < 0) 80 80 { 81 81 --wrap; 82 82 value_ += (wrap_val); 83 83 } 84 84 return wrap; 85 85 } 86 86 87 87 }; 88 88 89 89 … … 113 113 int_type as_int() const {return value_;} 114 114 operator int_type() const {return value_;} 115 115 //!Add, return number of wraps performed 116 /*! The sign of the returned value will indicate which direction the 116 /*! The sign of the returned value will indicate which direction the 117 117 * wraps went. Ex: add a negative number and wrapping under could occur, 118 * this would be indicated by a negative return value. If wrapping over 118 * this would be indicated by a negative return value. If wrapping over 119 119 * took place, a positive value would be returned */ 120 120 template< typename IntT > 121 IntT add(IntT v) 121 IntT add(IntT v) 122 122 { 123 123 int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1)); 124 124 IntT overflow = static_cast<IntT>(v / (wrap_max - wrap_min + 1)); … … 127 127 } 128 128 //! Subtract will return '-d' if wrapping under took place ('d' is the number of wraps) 129 129 /*! The sign of the returned value will indicate which direction the 130 * wraps went. Ex: subtract a negative number and wrapping over could 131 * occur, this would be indicated by a positive return value. If 130 * wraps went. Ex: subtract a negative number and wrapping over could 131 * occur, this would be indicated by a positive return value. If 132 132 * wrapping under took place, a negative value would be returned */ 133 133 template< typename IntT > 134 IntT subtract(IntT v) 134 IntT subtract(IntT v) 135 135 { 136 136 int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1)); 137 137 IntT underflow = static_cast<IntT>(-(v / (wrap_max - wrap_min + 1))); 138 138 value_ = static_cast<int_type>(value_ - remainder); 139 139 return calculate_wrap(underflow); 140 140 } 141 141 142 142 private: 143 143 int_type value_; 144 144 145 145 template< typename IntT > 146 146 IntT calculate_wrap(IntT wrap) 147 147 { 148 if ((value_) > wrap_max) 148 if ((value_) > wrap_max) 149 149 { 150 150 ++wrap; 151 151 value_ -= (wrap_max - wrap_min + 1); 152 152 } 153 else if((value_) < wrap_min) 153 else if((value_) < wrap_min) 154 154 { 155 155 --wrap; 156 156 value_ += (wrap_max - wrap_min + 1); -
time_iterator.hpp
2 2 #define DATE_TIME_TIME_ITERATOR_HPP___ 3 3 4 4 /* Copyright (c) 2002,2003 CrystalClear Software, Inc. 5 * Use, modification and distribution is subject to the 5 * Use, modification and distribution is subject to the 6 6 * Boost Software License, Version 1.0. (See accompanying 7 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 8 8 * Author: Jeff Garland, Bart Garst … … 12 12 13 13 namespace boost { 14 14 namespace date_time { 15 16 15 16 17 17 //! Simple time iterator skeleton class 18 18 template<class time_type> 19 19 class time_itr { 20 20 public: 21 21 typedef typename time_type::time_duration_type time_duration_type; 22 time_itr(time_type t, time_duration_type d) : current_(t), offset_(d) {} ;23 time_itr& operator++() 22 time_itr(time_type t, time_duration_type d) : current_(t), offset_(d) {} 23 time_itr& operator++() 24 24 { 25 25 current_ = current_ + offset_; 26 26 return *this; 27 27 } 28 time_itr& operator--() 28 time_itr& operator--() 29 29 { 30 30 current_ = current_ - offset_; 31 31 return *this; 32 32 } 33 time_type operator*() {return current_;} ;34 time_type* operator->() {return ¤t_;} ;35 bool operator< (const time_type& t) {return current_ < t;} ;36 bool operator<= (const time_type& t) {return current_ <= t;} ;37 bool operator!= (const time_type& t) {return current_ != t;} ;38 bool operator== (const time_type& t) {return current_ == t;} ;39 bool operator> (const time_type& t) {return current_ > t;} ;40 bool operator>= (const time_type& t) {return current_ >= t;} ;41 33 time_type operator*() {return current_;} 34 time_type* operator->() {return ¤t_;} 35 bool operator< (const time_type& t) {return current_ < t;} 36 bool operator<= (const time_type& t) {return current_ <= t;} 37 bool operator!= (const time_type& t) {return current_ != t;} 38 bool operator== (const time_type& t) {return current_ == t;} 39 bool operator> (const time_type& t) {return current_ > t;} 40 bool operator>= (const time_type& t) {return current_ >= t;} 41 42 42 private: 43 43 time_type current_; 44 44 time_duration_type offset_; 45 45 }; 46 47 46 48 47 48 49 49 } }//namespace date_time 50 50 51 51 -
date_duration.hpp
2 2 #define DATE_TIME_DATE_DURATION__ 3 3 4 4 /* Copyright (c) 2002,2003 CrystalClear Software, Inc. 5 * Use, modification and distribution is subject to the 5 * Use, modification and distribution is subject to the 6 6 * Boost Software License, Version 1.0. (See accompanying 7 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 8 8 * Author: Jeff Garland, Bart Garst … … 26 26 , boost::subtractable1< date_duration< duration_rep_traits > 27 27 , boost::dividable2< date_duration< duration_rep_traits >, int 28 28 > > > > > 29 { 29 { 30 30 public: 31 31 typedef typename duration_rep_traits::int_type duration_rep_type; 32 32 typedef typename duration_rep_traits::impl_type duration_rep; 33 33 34 34 //! Construct from a day count 35 explicit date_duration(duration_rep day_count) : days_(day_count) {} ;36 35 explicit date_duration(duration_rep day_count) : days_(day_count) {} 36 37 37 /*! construct from special_values - only works when 38 38 * instantiated with duration_traits_adapted */ 39 39 date_duration(special_values sv) : … … 125 125 { 126 126 typedef long int_type; 127 127 typedef long impl_type; 128 static int_type as_number(impl_type i) { return i; } ;128 static int_type as_number(impl_type i) { return i; } 129 129 }; 130 130 131 131 /*! Struct for instantiating date_duration <b>WITH</b> special values … … 135 135 { 136 136 typedef long int_type; 137 137 typedef boost::date_time::int_adapter<long> impl_type; 138 static int_type as_number(impl_type i) { return i.as_number(); } ;138 static int_type as_number(impl_type i) { return i.as_number(); } 139 139 }; 140 141 140 141 142 142 } } //namspace date_time 143 143 144 144