2 /// \file r_recur_base.h
3 /// Base class for recurring calendar event data.
7 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_RECORD_RECUR_BASE_H__
23 #define __BARRY_RECORD_RECUR_BASE_H__
35 // forward declarations
39 // NOTE: All classes here must be container-safe! Perhaps add sorting
40 // operators in the future.
43 class BXEXPORT RecurBase
49 /// Note: interval can be used on all of these recurring types to
50 /// make it happen "every other time" or more, etc.
52 enum RecurringCodeType
{
53 Day
= 1, //< eg. every day
55 MonthByDate
= 3, //< eg. every month on the 12th
57 MonthByDay
= 4, //< eg. every month on 3rd Wed
58 //< set: DayOfWeek and WeekOfMonth
59 YearByDate
= 5, //< eg. every year on March 5
60 //< set: DayOfMonth and MonthOfYear
61 YearByDay
= 6, //< eg. every year on 3rd Wed of Jan
62 //< set: DayOfWeek, WeekOfMonth, and
64 Week
= 12 //< eg. every week on Mon and Fri
70 RecurringCodeType RecurringType
;
71 unsigned short Interval
; // must be >= 1
72 time_t RecurringEndTime
; // only pertains if Recurring is true
73 // sets the date and time when
74 // recurrence of this appointment
75 // should no longer occur
76 // If a perpetual appointment, this
77 // is 0xFFFFFFFF in the low level data
78 // Instead, set the following flag.
79 bool Perpetual
; // if true, this will always recur
81 unsigned short // recurring details, depending on type
86 unsigned char WeekDays
; // bitmask, bit 0 = sunday
88 // FIXME - put these somewhere usable by both C and C++
89 #define CAL_WD_SUN 0x01
90 #define CAL_WD_MON 0x02
91 #define CAL_WD_TUE 0x04
92 #define CAL_WD_WED 0x08
93 #define CAL_WD_THU 0x10
94 #define CAL_WD_FRI 0x20
95 #define CAL_WD_SAT 0x40
98 void ParseRecurrenceData(const void *data
);
99 static unsigned char WeekDayProto2Rec(uint8_t raw_field
);
100 static uint8_t WeekDayRec2Proto(unsigned char weekdays
);
104 virtual ~RecurBase();
107 // return true if parse, false if not (for example, if type not
109 bool ParseField(uint8_t type
, const unsigned char *data
, size_t size
,
110 const IConverter
*ic
= 0);
111 void BuildRecurrenceData(time_t StartTime
, void *data
) const;
113 uint8_t RecurringFieldType() const;
117 void Dump(std::ostream
&os
) const;
120 BXEXPORT
inline std::ostream
& operator<<(std::ostream
&os
, const RecurBase
&msg
) {