1 #include "CalendarJournal.h"
5 CalendarObjectValidResult CalendarJournalObject::ValidObject(){
7 bool ValidBegin = false;
9 bool ValidDateTimeStamp = false;
10 bool ValidUniqueID = false;
14 // Look for BEGIN:VJOURNAL.
16 for (vector<string>::iterator iter = ObjectName.begin();
17 iter != ObjectName.end(); iter++){
19 if (ObjectName[SeekCount] == "BEGIN" &&
20 ObjectData[SeekCount] == "VJOURNAL"){
22 if (ValidBegin == false){
25 return CALENDAROBJECTVALID_INVALIDFORMAT;
30 if (ObjectName[SeekCount] == "END" &&
31 ObjectData[SeekCount] == "VJOURNAL" &&
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:VJOURNAL.
104 for (vector<string>::iterator iter = ObjectName.begin();
105 iter != ObjectName.end(); iter++){
107 if (ObjectName[SeekCount] == "END" &&
108 ObjectData[SeekCount] == "VJOURNAL"){
110 if (ValidEnd == false){
113 return CALENDAROBJECTVALID_INVALIDFORMAT;
122 // Check if the VJOURNAL is valid.
124 if (ValidBegin == true &&
126 ValidDateTimeStamp == true &&
127 ValidUniqueID == true){
129 return CALENDAROBJECTVALID_OK;
133 return CALENDAROBJECTVALID_INVALIDFORMAT;
139 void CalendarJournalObject::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;