TimeSpec.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2012  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020    ---------------------------------------------------------------------------
00021 */
00022 
00023 #ifndef __ccxx_TimeSpec_hxx
00024 #define __ccxx_TimeSpec_hxx
00025 
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/BitSet.h++>
00028 #include <commonc++/DateTime.h++>
00029 #include <commonc++/String.h++>
00030 
00031 namespace ccxx {
00032 
00063 class COMMONCPP_API TimeSpec
00064 {
00065   public:
00066 
00068   TimeSpec() throw();
00069 
00071   TimeSpec(const DateTime& time) throw();
00072 
00076   TimeSpec(uint_t hour, uint_t minute) throw();
00077 
00081   TimeSpec(uint_t hour, uint_t minute, uint_t month, uint_t day) throw();
00082 
00084   TimeSpec(const String& spec);
00085 
00087   virtual ~TimeSpec() throw();
00088 
00090   void setSpec(const String& spec);
00091 
00097   TimeSpec& setMonth(uint_t month) throw();
00098 
00105   TimeSpec& setMonths(uint_t month1, uint_t month2) throw();
00106 
00112   TimeSpec& clearMonth(uint_t month) throw();
00113 
00120   TimeSpec& clearMonths(uint_t month1, uint_t month2) throw();
00121 
00123   TimeSpec& setAllMonths() throw();
00124 
00126   TimeSpec& clearAllMonths() throw();
00127 
00133   TimeSpec& setDay(uint_t day) throw();
00134 
00141   TimeSpec& setDays(uint_t day1, uint_t day2) throw();
00142 
00148   TimeSpec& clearDay(uint_t day) throw();
00149 
00156   TimeSpec& clearDays(uint_t day1, uint_t day2) throw();
00157 
00159   TimeSpec& setAllDays() throw();
00160 
00162   TimeSpec& clearAllDays() throw();
00163 
00171   TimeSpec& setDayOfWeek(uint_t dow) throw();
00172 
00183   TimeSpec& setDaysOfWeek(uint_t dow1, uint_t dow2) throw();
00184 
00192   TimeSpec& clearDayOfWeek(uint_t dow) throw();
00193 
00204   TimeSpec& clearDaysOfWeek(uint_t dow1, uint_t dow2) throw();
00205 
00207   TimeSpec& setAllDaysOfWeek() throw();
00208 
00210   TimeSpec& clearAllDaysOfWeek() throw();
00211 
00217   TimeSpec& setHour(uint_t hour) throw();
00218 
00225   TimeSpec& setHours(uint_t hour1, uint_t hour2) throw();
00226 
00232   TimeSpec& clearHour(uint_t hour) throw();
00233 
00240   TimeSpec& clearHours(uint_t hour1, uint_t hour2) throw();
00241 
00243   TimeSpec& setAllHours() throw();
00244 
00246   TimeSpec& clearAllHours() throw();
00247 
00253   TimeSpec& setMinute(uint_t minute) throw();
00254 
00261   TimeSpec& setMinutes(uint_t minute1, uint_t minute2) throw();
00262 
00268   TimeSpec& clearMinute(uint_t minute) throw();
00269 
00276   TimeSpec& clearMinutes(uint_t minute1, uint_t minute2) throw();
00277 
00279   TimeSpec& setAllMinutes() throw();
00280 
00282   TimeSpec& clearAllMinutes() throw();
00283 
00289   bool matches(time_s_t time) const throw();
00290 
00296   bool matches(time_ms_t time) const throw();
00297 
00307   bool matches(uint_t month, uint_t day, uint_t weekday, uint_t hour,
00308                uint_t minute) const throw();
00309 
00311   String toString() const;
00312 
00313   private:
00314 
00315   void _parseValues(String str, uint_t base, BitSet& set) throw();
00316   void _set(BitSet& bset, uint_t base, uint_t pos, bool set) throw();
00317   void _setRange(BitSet& bset, uint_t base, uint_t min, uint_t max,
00318                  bool set) throw();
00319   void _format(const BitSet& set, uint_t base, String& s) const;
00320 
00321   BitSet _months;
00322   BitSet _days;
00323   BitSet _dow;
00324   BitSet _hours;
00325   BitSet _minutes;
00326 };
00327 
00328 }; // namespace ccxx
00329 
00330 #endif // __ccxx_TimeSpec_hxx
00331 
00332 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3