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.
 
 
 
 

38 lines
1.2 KiB

#include <ical/Event.h>
#include <ical/Alarm.h>
namespace ical {
Event::Event(ical::ical_object* object, icalcomponent* event_component) {
parse(object, event_component);
}
void Event::parse(ical::ical_object* object, icalcomponent* event_component) {
dtstart = icalcomponent_get_dtstart(event_component);
dtend = icalcomponent_get_dtstart(event_component);
summary = std::string(icalcomponent_get_summary(event_component));
parse_alarms(event_component);
DEBUG << "\n" << print();
for(auto& a : alarms) {
DEBUG << "\n" << a.print();
}
object->events.push_back(this);
}
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 Event::print() {
std::string s = "";
s += "DTSTART: " + std::string(icaltime_as_ical_string(dtstart)) + "\n";
s += "DTEND: " + std::string(icaltime_as_ical_string(dtend)) + "\n";
s += "SUMMARY: " + summary + "\n";
return s;
}
}