Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added try and catch for getting DateTimeStampTokens.
[xestiacalendar/.git] / source / objects / calendarevent / CalendarEvent.cpp
index 3d73561..b266d19 100644 (file)
@@ -1,7 +1,165 @@
 #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;
+       string PropertyName;
+       
+       // Look for BEGIN:VEVENT.
+       
+       for (vector<string>::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<string>::iterator iter = ObjectName.begin();
+               iter != ObjectName.end(); iter++){
+                       
+               try{
+                       PropertyName = ObjectName[SeekCount].substr(0,7);
+               }
+                       
+               catch(const out_of_range& oor){
+                       continue;
+               }
+               
+               if (PropertyName == "DTSTAMP"){
+                       
+                       if (ValidDateTimeStamp == false){
+                               ValidDateTimeStamp = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                               
+               }
+                       
+               SeekCount++;
+                       
+       }
+       
+       SeekCount = 0;
+       
+       // Look for UID.
+       
+       for (vector<string>::iterator iter = ObjectName.begin();
+               iter != ObjectName.end(); iter++){
+       
+               try{
+                       PropertyName = ObjectName[SeekCount].substr(0,3);
+               }
+               
+               catch(const out_of_range& oor){
+                       continue;
+               }
+                       
+               if (PropertyName == "UID"){
+                       
+                       if (ValidUniqueID == false){
+                               ValidUniqueID = true;
+                       } else {
+                               return CALENDAROBJECTVALID_INVALIDFORMAT;
+                       }
+                               
+               }
+                       
+               SeekCount++;
+                       
+       }
+       
+       SeekCount = 0;
+       
+       // Look for END:VEVENT.
+       
+       for (vector<string>::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;
+               
+       }
+       
+}
+
+void CalendarEventObject::ProcessData(){
+       
+       // Process the data.
+       
+       multimap<string,string> DataReceived;
+       
+       // Get the Date Time Stamp (DTSTAMP).
+       
+       DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
+       
+       // Process the data.
+       
+       if (DataReceived.begin() != DataReceived.end()){
+       
+               try {
+                       DateTimeStampTokens = DataReceived.begin()->first.substr(8);
+               }
+               
+               catch(const out_of_range &oor){
+                       // Do nothing as there is no data.
+               }               
+               
+               DateTimeStampData = DataReceived.begin()->second;
+               
+       }
+       
+}
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy