This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtypes.h
executable file
·107 lines (88 loc) · 2.25 KB
/
types.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef _TYPES_H
#define _TYPES_H
#include <string>
#include <list>
#include "date.h"
using namespace std;
struct DeleteItem {
template <typename T>
void operator()(T *ptr) { delete ptr; }
};
// Custom data types
typedef enum { VCALENDAR, VEVENT, VALARM } Component;
typedef enum { DISPLAY=0, PROCEDURE, AUDIO, EMAIL } AlarmAction;
struct Recurrence {
Recurrence(): Freq(YEAR), Interval(0), Count(0) {}
operator string() const;
bool IsEmpty() const { return (Interval == 0); }
void Clear() { Interval = 0; }
TimeUnit Freq;
unsigned short Interval, Count;
Date Until;
};
struct AlarmTrigger {
AlarmTrigger(): Before(true), Value(0), Unit(MINUTE) {}
AlarmTrigger &operator =(const string &Text);
operator string() const;
bool Before;
unsigned short Value;
TimeUnit Unit;
};
struct Alarm {
Alarm(): Active(false), Action(DISPLAY) {}
operator string() const;
void Clear() {
Description.clear();
}
bool Active;
AlarmAction Action;
AlarmTrigger Trigger;
string Description;
};
struct Event {
Event(): Alarms(new list<Alarm>), RecurrenceNo(0), BaseEvent(this) {}
Event(const Event &Base):
UID(Base.UID),
Summary(Base.Summary),
Description(Base.Description),
Categories(Base.Categories),
DtStamp(Base.DtStamp),
DtStart(Base.DtStart),
DtEnd(Base.DtEnd),
RRule(Base.RRule),
Alarms(Base.Alarms),
RecurrenceNo(Base.RecurrenceNo)
{
BaseEvent = Base.BaseEvent == (Event *)&Base ? (Event *)&Base : Base.BaseEvent;
}
~Event() {
if (BaseEvent == this)
delete Alarms;
}
operator string() const;
bool HasAlarm(const Date &From, const Date &To);
string UID, Summary, Description, Categories;
Date DtStamp, DtStart, DtEnd;
Recurrence RRule;
list<Alarm> *Alarms;
unsigned short RecurrenceNo;
Event *BaseEvent;
};
struct EventsCriteria {
EventsCriteria(): AllEvents(false), IncludeRecurrent(true) {}
Date From, To;
bool AllEvents, IncludeRecurrent;
};
inline ostream &operator <<(ostream &stream, const Recurrence &RRule) {
stream << RRule.operator string();
return stream;
}
inline ostream &operator <<(ostream &stream, const Alarm &Alarm) {
stream << Alarm.operator string();
return stream;
}
inline ostream &operator <<(ostream &stream, const Event &Event) {
stream << Event.operator string();
return stream;
}
#endif // _TYPES_H