From 6e0d4f73ebe90d00fded6a8bcf5525a5fd7ae373 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 12 Jun 2016 01:00:48 +0100 Subject: [PATCH] Added X-Token property for saving data from a CalendarTimezoneObject. Added the code and unit tests for the X-Token property in both STANDARD and DAYLIGHT timezone types. --- .../CalendarTimezone-Save.cpp | 46 +++++++++++++++++++ .../tests/xestiacalendar_icaltimezonesave.h | 18 ++++++++ 2 files changed, 64 insertions(+) diff --git a/source/objects/calendartimezone/CalendarTimezone-Save.cpp b/source/objects/calendartimezone/CalendarTimezone-Save.cpp index 82b2d65..bf25e6d 100644 --- a/source/objects/calendartimezone/CalendarTimezone-Save.cpp +++ b/source/objects/calendartimezone/CalendarTimezone-Save.cpp @@ -342,7 +342,30 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ } } + + // Process data from X-* + + if (TimezoneStandardCollection[TimezoneStandardSeek].XTokensData.size() > 0){ + + for (int TimezoneXTokenSeek = 0; TimezoneXTokenSeek < TimezoneStandardCollection[TimezoneStandardSeek].XTokensData.size(); + TimezoneXTokenSeek++){ + + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].XTokensDataTokens[TimezoneXTokenSeek]; + DataLine += ":"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].XTokensData[TimezoneXTokenSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + } + *SaveData += "END:STANDARD\n"; } @@ -598,6 +621,29 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ } } + + // Process data from X-* + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].XTokensData.size() > 0){ + + for (int TimezoneXTokenSeek = 0; TimezoneXTokenSeek < TimezoneDaylightCollection[TimezoneDaylightSeek].XTokensData.size(); + TimezoneXTokenSeek++){ + + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].XTokensDataTokens[TimezoneXTokenSeek]; + DataLine += ":"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].XTokensData[TimezoneXTokenSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } *SaveData += "END:DAYLIGHT\n"; diff --git a/source/tests/xestiacalendar_icaltimezonesave.h b/source/tests/xestiacalendar_icaltimezonesave.h index 678ea60..9799558 100644 --- a/source/tests/xestiacalendar_icaltimezonesave.h +++ b/source/tests/xestiacalendar_icaltimezonesave.h @@ -83,6 +83,15 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n" " 305\n" "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n" + "X-MOO:Meep\n" + "X-MOO:Moop\n" + "X-MOO;MEEP=YIKES:Zaap\n" + "X-ITEM:Fork\n" + "X-ITEM:Spoon\n" + "X-ITEM;DIRTY=NO:Knife\n" + "X-NOPE:1\n" + "X-NOPE:2\n" + "X-NOPE;LONG=YES:3\n" "END:STANDARD\n" "BEGIN:DAYLIGHT\n" "DTSTART:20160204T020000\n" @@ -103,6 +112,15 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "RDATE;VALUE=DATE;TZID=Europe/Truro;BEEP=BOOP:20160205,20160207,20160216,20160\n" " 305\n" "TZNAME;LANGUAGE=en;NOPE=YES:Example Timezone Name 1\n" + "X-MOO:Meep\n" + "X-MOO:Moop\n" + "X-MOO;MEEP=YIKES:Zaap\n" + "X-ITEM:Fork\n" + "X-ITEM:Spoon\n" + "X-ITEM;DIRTY=NO:Knife\n" + "X-NOPE:1\n" + "X-NOPE:2\n" + "X-NOPE;LONG=YES:3\n" "END:DAYLIGHT\n" "END:VTIMEZONE\n" "END:VCALENDAR"; -- 2.39.2