1 #include "CalendarEvent.h"
5 CalendarObjectValidResult CalendarEventObject::ValidObject(){
7 bool ValidBegin = false;
9 bool ValidDateTimeStamp = false;
10 bool ValidUniqueID = false;
11 bool ValidDateTimeStart = false;
15 // Look for BEGIN:VEVENT.
17 for (vector<string>::iterator iter = ObjectName.begin();
18 iter != ObjectName.end(); iter++){
20 if (ObjectName[SeekCount] == "BEGIN" &&
21 ObjectData[SeekCount] == "VEVENT"){
23 if (ValidBegin == false){
26 return CALENDAROBJECTVALID_INVALIDFORMAT;
31 if (ObjectName[SeekCount] == "END" &&
32 ObjectData[SeekCount] == "VEVENT" &&
35 return CALENDAROBJECTVALID_INVALIDFORMAT;
47 for (vector<string>::iterator iter = ObjectName.begin();
48 iter != ObjectName.end(); iter++){
51 PropertyName = ObjectName[SeekCount].substr(0,7);
54 catch(const out_of_range& oor){
58 if (PropertyName == "DTSTAMP"){
60 if (ValidDateTimeStamp == false){
61 ValidDateTimeStamp = true;
63 return CALENDAROBJECTVALID_INVALIDFORMAT;
76 for (vector<string>::iterator iter = ObjectName.begin();
77 iter != ObjectName.end(); iter++){
80 PropertyName = ObjectName[SeekCount].substr(0,3);
83 catch(const out_of_range& oor){
87 if (PropertyName == "UID"){
89 if (ValidUniqueID == false){
92 return CALENDAROBJECTVALID_INVALIDFORMAT;
103 // Look for DTSTART if nothing is set for METHOD..
105 if (MethodData.size() == 0){
107 for (vector<string>::iterator iter = ObjectName.begin();
108 iter != ObjectName.end(); iter++){
111 PropertyName = ObjectName[SeekCount].substr(0,7);
114 catch(const out_of_range& oor){
118 if (PropertyName == "DTSTART"){
120 if (ValidDateTimeStart == false){
121 ValidDateTimeStart = true;
123 return CALENDAROBJECTVALID_INVALIDFORMAT;
133 ValidDateTimeStart = true;
138 // Look for END:VEVENT.
140 for (vector<string>::iterator iter = ObjectName.begin();
141 iter != ObjectName.end(); iter++){
143 if (ObjectName[SeekCount] == "END" &&
144 ObjectData[SeekCount] == "VEVENT"){
146 if (ValidEnd == false){
149 return CALENDAROBJECTVALID_INVALIDFORMAT;
158 // Check if the VEVENT is valid.
160 if (ValidBegin == true &&
162 ValidDateTimeStamp == true &&
163 ValidDateTimeStart == true &&
164 ValidUniqueID == true){
166 return CALENDAROBJECTVALID_OK;
170 return CALENDAROBJECTVALID_INVALIDFORMAT;
176 void CalendarEventObject::ProcessData(){
180 multimap<string,string> DataReceived;
182 // Get the Date Time Stamp (DTSTAMP).
184 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
186 // Process the data from DTSTAMP.
188 if (DataReceived.begin() != DataReceived.end()){
191 DateTimeStampTokens = DataReceived.begin()->first.substr(8);
194 catch(const out_of_range &oor){
195 // Do nothing as there is no data.
198 DateTimeStampData = DataReceived.begin()->second;
202 // Get the Unique ID (UID).
204 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
206 // Process the data from UID.
208 if (DataReceived.begin() != DataReceived.end()){
211 UniqueIDTokens = DataReceived.begin()->first.substr(4);
214 catch(const out_of_range &oor){
215 // Do nothing as there is no data.
218 UniqueID = DataReceived.begin()->second;