1 #include "CalendarTask.h"
5 CalendarObjectValidResult CalendarTaskObject::ValidObject(){
7 bool ValidBegin = false;
9 bool ValidDateTimeStamp = false;
10 bool ValidUniqueID = false;
14 // Look for BEGIN:VTODO.
16 for (vector<string>::iterator iter = ObjectName.begin();
17 iter != ObjectName.end(); iter++){
19 if (ObjectName[SeekCount] == "BEGIN" &&
20 ObjectData[SeekCount] == "VTODO"){
22 if (ValidBegin == false){
25 return CALENDAROBJECTVALID_INVALIDFORMAT;
30 if (ObjectName[SeekCount] == "END" &&
31 ObjectData[SeekCount] == "VTODO" &&
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:VTODO.
104 for (vector<string>::iterator iter = ObjectName.begin();
105 iter != ObjectName.end(); iter++){
107 if (ObjectName[SeekCount] == "END" &&
108 ObjectData[SeekCount] == "VTODO"){
110 if (ValidEnd == false){
113 return CALENDAROBJECTVALID_INVALIDFORMAT;
122 // Check if the VTODO is valid.
124 if (ValidBegin == true &&
126 ValidDateTimeStamp == true &&
127 ValidUniqueID == true){
129 return CALENDAROBJECTVALID_OK;
133 return CALENDAROBJECTVALID_INVALIDFORMAT;
139 void CalendarTaskObject::ProcessData(){
143 multimap<string,string> DataReceived;
144 map<string,string> PropertyData;
145 string *PropertyNameData = nullptr;
146 int ObjectSeekCount = 0;
148 // Get the Date Time Stamp (DTSTAMP).
150 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DTSTAMP");
152 // Process the data from DTSTAMP.
154 if (DataReceived.begin() != DataReceived.end()){
157 DateTimeStampTokens = DataReceived.begin()->first.substr(8);
160 catch(const out_of_range &oor){
161 // Do nothing as there is no data.
164 DateTimeStampData = DataReceived.begin()->second;
168 // Get the Unique ID (UID).
170 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "UID");
172 // Process the data from UID.
174 if (DataReceived.begin() != DataReceived.end()){
177 UniqueIDTokens = DataReceived.begin()->first.substr(4);
180 catch(const out_of_range &oor){
181 // Do nothing as there is no data.
184 UniqueID = DataReceived.begin()->second;
188 // Process the data from CLASS.
190 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CLASS");
192 if (DataReceived.begin() != DataReceived.end()){
195 ClassDataTokens = DataReceived.begin()->first.substr(6);
198 catch(const out_of_range &oor){
199 // Do nothing as there is no data.
202 ClassData = DataReceived.begin()->second;
206 // Process the data from COMPLETED.
208 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "COMPLETED");
210 if (DataReceived.begin() != DataReceived.end()){
213 CompletedDataTokens = DataReceived.begin()->first.substr(10);
216 catch(const out_of_range &oor){
217 // Do nothing as there is no data.
220 CompletedData = DataReceived.begin()->second;
224 // Process the data from CREATED.
226 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "CREATED");
228 if (DataReceived.begin() != DataReceived.end()){
231 DateTimeCreatedTokens = DataReceived.begin()->first.substr(8);
234 catch(const out_of_range &oor){
235 // Do nothing as there is no data.
238 DateTimeCreatedData = DataReceived.begin()->second;
242 // Process the data from DESCRIPTION.
244 DataReceived = ProcessTextVectors(&ObjectName, &ObjectData, false, "DESCRIPTION");
246 if (DataReceived.begin() != DataReceived.end()){
248 bool TokenData = false;
249 string PropertyTokens;
251 PropertyNameData = (string*)&DataReceived.begin()->first;
253 PropertyData = SplitValues(*PropertyNameData);
255 for(map<string,string>::iterator iter = PropertyData.begin();
256 iter != PropertyData.end(); iter++){
258 if (iter->first == "ALTREP"){
260 DescriptionListAltRep.clear();
261 DescriptionListAltRep.push_back(iter->second);
263 } else if (iter->first == "LANGUAGE"){
265 DescriptionListLanguage.clear();
266 DescriptionListLanguage.push_back(iter->second);
270 if (TokenData == false){
273 PropertyTokens += ";";
276 PropertyTokens += iter->first;
277 PropertyTokens += "=";
278 PropertyTokens += iter->second;
284 if (PropertyTokens.size() > 0){
285 DescriptionListTokens.clear();
286 DescriptionListTokens.push_back(PropertyTokens);
289 DescriptionList.clear();
290 DescriptionList.push_back(DataReceived.begin()->second);