time_iterator.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef DATE_TIME_TIME_ITERATOR_HPP___
  2. #define DATE_TIME_TIME_ITERATOR_HPP___
  3. /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
  4. * Use, modification and distribution is subject to the
  5. * Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  7. * Author: Jeff Garland, Bart Garst
  8. * $Date$
  9. */
  10. namespace boost {
  11. namespace date_time {
  12. //! Simple time iterator skeleton class
  13. template<class time_type>
  14. class time_itr {
  15. public:
  16. typedef typename time_type::time_duration_type time_duration_type;
  17. time_itr(time_type t, time_duration_type d) : current_(t), offset_(d) {}
  18. time_itr& operator++()
  19. {
  20. current_ = current_ + offset_;
  21. return *this;
  22. }
  23. time_itr& operator--()
  24. {
  25. current_ = current_ - offset_;
  26. return *this;
  27. }
  28. const time_type& operator*() const {return current_;}
  29. const time_type* operator->() const {return &current_;}
  30. bool operator< (const time_type& t) const {return current_ < t;}
  31. bool operator<= (const time_type& t) const {return current_ <= t;}
  32. bool operator!= (const time_type& t) const {return current_ != t;}
  33. bool operator== (const time_type& t) const {return current_ == t;}
  34. bool operator> (const time_type& t) const {return current_ > t;}
  35. bool operator>= (const time_type& t) const {return current_ >= t;}
  36. private:
  37. time_type current_;
  38. time_duration_type offset_;
  39. };
  40. } }//namespace date_time
  41. #endif