From: Steve Brokenshire Date: Sat, 11 Jun 2016 10:00:07 +0000 (+0100) Subject: Added COMMENT property for saving data from a CalendarTimezoneObject. X-Git-Tag: release-0.02~129 X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=commitdiff_plain;h=93adeb6d3a5856fac60bbd3165949378e2916947 Added COMMENT property for saving data from a CalendarTimezoneObject. Added the code and unit tests for the COMMENT property in both STANDARD and DAYLIGHT timezone types. --- diff --git a/source/objects/calendartimezone/CalendarTimezone-Save.cpp b/source/objects/calendartimezone/CalendarTimezone-Save.cpp index 127ac00..2dc194e 100644 --- a/source/objects/calendartimezone/CalendarTimezone-Save.cpp +++ b/source/objects/calendartimezone/CalendarTimezone-Save.cpp @@ -213,6 +213,52 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ DataLineProcessed.clear(); } + + // Process the COMMENT value. + + if (TimezoneStandardCollection[TimezoneStandardSeek].CommentList.size() > 0){ + + for (int CommentListSeek = 0; CommentListSeek < TimezoneStandardCollection[TimezoneStandardSeek].CommentList.size(); + CommentListSeek++){ + + DataLine += "COMMENT"; + + if (TimezoneStandardCollection[TimezoneStandardSeek].CommentListAltRep[CommentListSeek].size() > 0){ + + DataLine += ";ALTREP=\""; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].CommentListAltRep[CommentListSeek]; + DataLine += "\""; + + } + + if (TimezoneStandardCollection[TimezoneStandardSeek].CommentListLanguage[CommentListSeek].size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].CommentListLanguage[CommentListSeek]; + + } + + if (TimezoneStandardCollection[TimezoneStandardSeek].CommentListTokens[CommentListSeek].size() > 0){ + + DataLine += ";"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].CommentListTokens[CommentListSeek]; + + } + + DataLine += ":"; + DataLine += TimezoneStandardCollection[TimezoneStandardSeek].CommentList[CommentListSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } *SaveData += "END:STANDARD\n"; @@ -340,6 +386,52 @@ void CalendarTimezoneObject::SaveObjectData(string *SaveData){ DataLineProcessed.clear(); } + + // Process the COMMENT value. + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].CommentList.size() > 0){ + + for (int CommentListSeek = 0; CommentListSeek < TimezoneDaylightCollection[TimezoneDaylightSeek].CommentList.size(); + CommentListSeek++){ + + DataLine += "COMMENT"; + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].CommentListAltRep[CommentListSeek].size() > 0){ + + DataLine += ";ALTREP=\""; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].CommentListAltRep[CommentListSeek]; + DataLine += "\""; + + } + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].CommentListLanguage[CommentListSeek].size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].CommentListLanguage[CommentListSeek]; + + } + + if (TimezoneDaylightCollection[TimezoneDaylightSeek].CommentListTokens[CommentListSeek].size() > 0){ + + DataLine += ";"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].CommentListTokens[CommentListSeek]; + + } + + DataLine += ":"; + DataLine += TimezoneDaylightCollection[TimezoneDaylightSeek].CommentList[CommentListSeek]; + 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 cf2266d..abeb5b9 100644 --- a/source/tests/xestiacalendar_icaltimezonesave.h +++ b/source/tests/xestiacalendar_icaltimezonesave.h @@ -79,6 +79,7 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "TZOFFSETFROM;LETS=GO:-0500\n" "TZOFFSETTO;EXAMPLE=DATA:-0400\n" "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n" + "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n" "END:STANDARD\n" "BEGIN:DAYLIGHT\n" "DTSTART:20160204T020000\n" @@ -95,6 +96,7 @@ TEST(iCalendarSaveTimezone, SaveTimezoneTests){ "TZOFFSETFROM;LETS=GO:-0500\n" "TZOFFSETTO;EXAMPLE=DATA:-0400\n" "RRULE;YAK=YES:FREQ=DAILY;COUNT=10\n" + "COMMENT;ALTREP=\"null:nodata\";LANGUAGE=kw;YO=YOYOS:Example timezone comment.\n" "END:DAYLIGHT\n" "END:VTIMEZONE\n" "END:VCALENDAR";