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.

37 lines
1.1 KiB

  1. #include <ical/Event.h>
  2. #include <ical/Alarm.h>
  3. namespace ical {
  4. Event::Event(icalcomponent* event_component) {
  5. parse(event_component);
  6. }
  7. void Event::parse(icalcomponent* event_component) {
  8. dtstart = icalcomponent_get_dtstart(event_component);
  9. dtend = icalcomponent_get_dtstart(event_component);
  10. summary = std::string(icalcomponent_get_summary(event_component));
  11. parse_alarms(event_component);
  12. }
  13. void Event::parse_alarms(icalcomponent* event_component) {
  14. icalcomponent* c;
  15. for(c = icalcomponent_get_first_component(event_component, ICAL_VALARM_COMPONENT);
  16. c != 0;
  17. c = icalcomponent_get_next_component(event_component, ICAL_VALARM_COMPONENT))
  18. {
  19. alarms.push_back(Alarm(c));
  20. }
  21. }
  22. std::string Event::print() const {
  23. std::string s = "";
  24. s += "DTSTART: " + std::string(icaltime_as_ical_string(dtstart)) + "\n";
  25. s += "DTEND: " + std::string(icaltime_as_ical_string(dtend)) + "\n";
  26. s += "SUMMARY: " + summary + "\n";
  27. s += "ALARMS:\n";
  28. for(auto const& a : alarms) {
  29. s += a.print();
  30. }
  31. return s;
  32. }
  33. }