From: Steve Brokenshire Date: Sun, 17 Jan 2016 11:05:53 +0000 (+0000) Subject: Implemented ValidObject within CalendarEventObject X-Git-Tag: release-0.02~772 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=76e7cedc1d2c3a0284e984e3a5c9ee254d36e96b;p=xestiacalendar%2F.git Implemented ValidObject within CalendarEventObject --- diff --git a/source/objects/calendarevent/CalendarEvent.cpp b/source/objects/calendarevent/CalendarEvent.cpp index 6d105b8..3b063ab 100644 --- a/source/objects/calendarevent/CalendarEvent.cpp +++ b/source/objects/calendarevent/CalendarEvent.cpp @@ -1,7 +1,120 @@ #include "CalendarEvent.h" +using namespace std; + CalendarObjectValidResult CalendarEventObject::ValidObject(){ - return CALENDAROBJECTVALID_UNITTESTFAIL; - + bool ValidBegin = false; + bool ValidEnd = false; + bool ValidDateTimeStamp = false; + bool ValidUniqueID = false; + int SeekCount = 0; + + // Look for BEGIN:VEVENT. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "BEGIN" && + ObjectData[SeekCount] == "VEVENT"){ + + if (ValidBegin == false){ + ValidBegin = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VEVENT" && + ValidBegin == false){ + + return CALENDAROBJECTVALID_INVALIDFORMAT; + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for DTSTAMP. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "DTSTAMP"){ + + if (ValidDateTimeStamp == false){ + ValidDateTimeStamp = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for UID. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "UID"){ + + if (ValidUniqueID == false){ + ValidUniqueID = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for END:VEVENT. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VEVENT"){ + + if (ValidEnd == false){ + ValidEnd = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + // Check if the VEVENT is valid. + + if (ValidBegin == true && + ValidEnd == true && + ValidDateTimeStamp == true && + ValidUniqueID == true){ + + return CALENDAROBJECTVALID_OK; + + } else { + + return CALENDAROBJECTVALID_INVALIDFORMAT; + + } + }