You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
1.5 KiB

#include <ical/Event.h>
#include <ical/Alarm.h>
namespace ical {
Event::Event(icalcomponent* event_component) {
parse(event_component);
}
void Event::parse(icalcomponent* event_component) {
uid = icalcomponent_get_uid(event_component);
dtstart = icalcomponent_get_dtstart(event_component);
dtend = icalcomponent_get_dtend(event_component);
summary = std::string(icalcomponent_get_summary(event_component));
parse_alarms(event_component);
}
void Event::parse_alarms(icalcomponent* event_component) {
icalcomponent* c;
for(c = icalcomponent_get_first_component(event_component, ICAL_VALARM_COMPONENT);
c != 0;
c = icalcomponent_get_next_component(event_component, ICAL_VALARM_COMPONENT))
{
alarms.push_back(Alarm(c));
}
}
std::string get_uid() const {
return uid;
}
std::string get_summary() const {
return summary;
}
icaltimetype get_dtstart() const {
return dtstart;
}
icaltimetype get_dtend() const {
return dtend;
}
std::vector<Alarm> get_alarms() const {
return alarms;
}
std::string Event::print() const {
std::string s = "";
s += "UID: " + uid + "\n";
s += "DTSTART: " + std::string(icaltime_as_ical_string(dtstart)) + "\n";
s += "DTEND: " + std::string(icaltime_as_ical_string(dtend)) + "\n";
s += "SUMMARY: " + summary + "\n";
s += "ALARMS:\n";
for(auto const& a : alarms) {
s += a.print();
}
return s;
}
}