1 #include "CalendarEvent.h"
5 CalendarObjectValidResult CalendarEventObject::ValidObject(){
7 bool ValidBegin = false;
9 bool ValidDateTimeStamp = false;
10 bool ValidUniqueID = false;
14 // Look for BEGIN:VEVENT.
16 for (vector<string>::iterator iter = ObjectName.begin();
17 iter != ObjectName.end(); iter++){
19 if (ObjectName[SeekCount] == "BEGIN" &&
20 ObjectData[SeekCount] == "VEVENT"){
22 if (ValidBegin == false){
25 return CALENDAROBJECTVALID_INVALIDFORMAT;
30 if (ObjectName[SeekCount] == "END" &&
31 ObjectData[SeekCount] == "VEVENT" &&
34 return CALENDAROBJECTVALID_INVALIDFORMAT;
46 for (vector<string>::iterator iter = ObjectName.begin();
47 iter != ObjectName.end(); iter++){
50 PropertyName = ObjectName[SeekCount].substr(0,7);
53 catch(const out_of_range& oor){
57 if (PropertyName == "DTSTAMP"){
59 if (ValidDateTimeStamp == false){
60 ValidDateTimeStamp = true;
62 return CALENDAROBJECTVALID_INVALIDFORMAT;
75 for (vector<string>::iterator iter = ObjectName.begin();
76 iter != ObjectName.end(); iter++){
79 PropertyName = ObjectName[SeekCount].substr(0,3);
82 catch(const out_of_range& oor){
86 if (PropertyName == "UID"){
88 if (ValidUniqueID == false){
91 return CALENDAROBJECTVALID_INVALIDFORMAT;
102 // Look for END:VEVENT.
104 for (vector<string>::iterator iter = ObjectName.begin();
105 iter != ObjectName.end(); iter++){
107 if (ObjectName[SeekCount] == "END" &&
108 ObjectData[SeekCount] == "VEVENT"){
110 if (ValidEnd == false){
113 return CALENDAROBJECTVALID_INVALIDFORMAT;
122 // Check if the VEVENT is valid.
124 if (ValidBegin == true &&
126 ValidDateTimeStamp == true &&
127 ValidUniqueID == true){
129 return CALENDAROBJECTVALID_OK;
133 return CALENDAROBJECTVALID_INVALIDFORMAT;
139 void CalendarEventObject::ProcessData(){
143 multimap<string,string> DataReceived;
145 // Get the Date Time Stamp (DTSTAMP).
147 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
149 // Process the data from DTSTAMP.
151 if (DataReceived.begin() != DataReceived.end()){
154 DateTimeStampTokens = DataReceived.begin()->first.substr(8);
157 catch(const out_of_range &oor){
158 // Do nothing as there is no data.
161 DateTimeStampData = DataReceived.begin()->second;
165 // Get the Unique ID (UID).
167 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
169 // Process the data from DTSTAMP.
171 if (DataReceived.begin() != DataReceived.end()){
174 UniqueIDTokens = DataReceived.begin()->first.substr(4);
177 catch(const out_of_range &oor){
178 // Do nothing as there is no data.
181 UniqueID = DataReceived.begin()->second;