reSIProcate/stack  9694
DateCategory.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_DATE_CATEGORY_HXX)
00002 #define RESIP_DATE_CATEGORY_HXX 
00003 
00004 #include <iosfwd>
00005 #include "rutil/Data.hxx"
00006 #include "resip/stack/ParserCategory.hxx"
00007 
00008 namespace resip
00009 {
00010 
00011 //====================
00012 // DateCategory:
00013 //====================
00014 
00015 enum DayOfWeek { 
00016    Sun = 0,
00017    Mon,
00018    Tue,
00019    Wed,
00020    Thu,
00021    Fri,
00022    Sat
00023 };
00024 
00025 extern Data DayOfWeekData[];
00026 extern Data MonthData[];
00027 
00028 enum Month {
00029    Jan = 0,
00030    Feb,
00031    Mar,
00032    Apr,
00033    May,
00034    Jun,
00035    Jul,
00036    Aug,
00037    Sep,
00038    Oct,
00039    Nov,
00040    Dec
00041 };
00042 
00047 class DateCategory : public ParserCategory
00048 {
00049    public:
00050       enum {commaHandling = NoCommaTokenizing};
00051 
00052       DateCategory();
00053       DateCategory(time_t datetime);
00054       DateCategory(const HeaderFieldValue& hfv, 
00055                      Headers::Type type,
00056                      PoolBase* pool=0);
00057       DateCategory(const DateCategory& orig,
00058                      PoolBase* pool=0);
00059       DateCategory& operator=(const DateCategory&);
00060 
00061       virtual bool setDatetime(time_t datetime);
00062 
00063       virtual void parse(ParseBuffer& pb);
00064       virtual ParserCategory* clone() const;
00065       virtual ParserCategory* clone(void* location) const;
00066       virtual ParserCategory* clone(PoolBase* pool) const;
00067 
00068       virtual EncodeStream& encodeParsed(EncodeStream& str) const;
00069       
00070       static DayOfWeek DayOfWeekFromData(const Data&);
00071       static Month MonthFromData(const Data&);
00072 
00073       const DayOfWeek& dayOfWeek() const;
00074       int& dayOfMonth();
00075       int dayOfMonth() const;
00076       Month& month();
00077       Month month() const;
00078       int& year();
00079       int year() const;
00080       int& hour();
00081       int hour() const;
00082       int& minute();
00083       int minute() const;
00084       int& second();
00085       int second() const;
00086 
00087    private:
00088       enum DayOfWeek mDayOfWeek;
00089       int mDayOfMonth;
00090       enum Month mMonth;
00091       int mYear;
00092       int mHour;
00093       int mMin;
00094       int mSec;
00095 };
00096  
00097 }
00098 
00099 #endif
00100 
00101 /* ====================================================================
00102  * The Vovida Software License, Version 1.0 
00103  * 
00104  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00105  * 
00106  * Redistribution and use in source and binary forms, with or without
00107  * modification, are permitted provided that the following conditions
00108  * are met:
00109  * 
00110  * 1. Redistributions of source code must retain the above copyright
00111  *    notice, this list of conditions and the following disclaimer.
00112  * 
00113  * 2. Redistributions in binary form must reproduce the above copyright
00114  *    notice, this list of conditions and the following disclaimer in
00115  *    the documentation and/or other materials provided with the
00116  *    distribution.
00117  * 
00118  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00119  *    and "Vovida Open Communication Application Library (VOCAL)" must
00120  *    not be used to endorse or promote products derived from this
00121  *    software without prior written permission. For written
00122  *    permission, please contact vocal@vovida.org.
00123  *
00124  * 4. Products derived from this software may not be called "VOCAL", nor
00125  *    may "VOCAL" appear in their name, without prior written
00126  *    permission of Vovida Networks, Inc.
00127  * 
00128  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00129  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00130  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00131  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00132  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00133  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00134  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00135  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00136  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00137  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00138  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00139  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00140  * DAMAGE.
00141  * 
00142  * ====================================================================
00143  * 
00144  * This software consists of voluntary contributions made by Vovida
00145  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00146  * Inc.  For more information on Vovida Networks, Inc., please see
00147  * <http://www.vovida.org/>.
00148  *
00149  */