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;
105 for (vector<string>::iterator iter = ObjectName.begin();
106 iter != ObjectName.end(); iter++){
109 PropertyName = ObjectName[SeekCount].substr(0,7);
112 catch(const out_of_range& oor){
116 if (PropertyName == "DTSTART"){
118 if (ValidDateTimeStart == false){
119 ValidDateTimeStart = true;
121 return CALENDAROBJECTVALID_INVALIDFORMAT;
132 // Look for END:VEVENT.
134 for (vector<string>::iterator iter = ObjectName.begin();
135 iter != ObjectName.end(); iter++){
137 if (ObjectName[SeekCount] == "END" &&
138 ObjectData[SeekCount] == "VEVENT"){
140 if (ValidEnd == false){
143 return CALENDAROBJECTVALID_INVALIDFORMAT;
152 // Check if the VEVENT is valid.
154 if (ValidBegin == true &&
156 ValidDateTimeStamp == true &&
157 ValidDateTimeStart == true &&
158 ValidUniqueID == true){
160 return CALENDAROBJECTVALID_OK;
164 return CALENDAROBJECTVALID_INVALIDFORMAT;
170 void CalendarEventObject::ProcessData(){
174 multimap<string,string> DataReceived;
176 // Get the Date Time Stamp (DTSTAMP).
178 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
180 // Process the data from DTSTAMP.
182 if (DataReceived.begin() != DataReceived.end()){
185 DateTimeStampTokens = DataReceived.begin()->first.substr(8);
188 catch(const out_of_range &oor){
189 // Do nothing as there is no data.
192 DateTimeStampData = DataReceived.begin()->second;
196 // Get the Unique ID (UID).
198 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
200 // Process the data from DTSTAMP.
202 if (DataReceived.begin() != DataReceived.end()){
205 UniqueIDTokens = DataReceived.begin()->first.substr(4);
208 catch(const out_of_range &oor){
209 // Do nothing as there is no data.
212 UniqueID = DataReceived.begin()->second;