From 4e0fe0815e5733fab35e33cabd4f9ef10c997969 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 31 Jan 2016 14:08:44 +0000 Subject: [PATCH] Setup the initial version of CalendarJournalObject. --- .../calendarjournal/CalendarJournal.cpp | 148 ++++++++++++++++++ .../objects/calendarjournal/CalendarJournal.h | 16 ++ 2 files changed, 164 insertions(+) create mode 100644 source/objects/calendarjournal/CalendarJournal.cpp create mode 100644 source/objects/calendarjournal/CalendarJournal.h diff --git a/source/objects/calendarjournal/CalendarJournal.cpp b/source/objects/calendarjournal/CalendarJournal.cpp new file mode 100644 index 0000000..f3c66c7 --- /dev/null +++ b/source/objects/calendarjournal/CalendarJournal.cpp @@ -0,0 +1,148 @@ +#include "CalendarJournal.h" + +using namespace std; + +CalendarObjectValidResult CalendarJournalObject::ValidObject(){ + + bool ValidBegin = false; + bool ValidEnd = false; + bool ValidDateTimeStamp = false; + bool ValidUniqueID = false; + int SeekCount = 0; + string PropertyName; + + // Look for BEGIN:VJOURNAL. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "BEGIN" && + ObjectData[SeekCount] == "VJOURNAL"){ + + if (ValidBegin == false){ + ValidBegin = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VJOURNAL" && + ValidBegin == false){ + + return CALENDAROBJECTVALID_INVALIDFORMAT; + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for DTSTAMP. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + try{ + PropertyName = ObjectName[SeekCount].substr(0,7); + } + + catch(const out_of_range& oor){ + continue; + } + + if (PropertyName == "DTSTAMP"){ + + if (ValidDateTimeStamp == false){ + ValidDateTimeStamp = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for UID. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + try{ + PropertyName = ObjectName[SeekCount].substr(0,3); + } + + catch(const out_of_range& oor){ + continue; + } + + if (PropertyName == "UID"){ + + if (ValidUniqueID == false){ + ValidUniqueID = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + SeekCount = 0; + + // Look for END:VJOURNAL. + + for (vector::iterator iter = ObjectName.begin(); + iter != ObjectName.end(); iter++){ + + if (ObjectName[SeekCount] == "END" && + ObjectData[SeekCount] == "VJOURNAL"){ + + if (ValidEnd == false){ + ValidEnd = true; + } else { + return CALENDAROBJECTVALID_INVALIDFORMAT; + } + + } + + SeekCount++; + + } + + // Check if the VJOURNAL is valid. + + if (ValidBegin == true && + ValidEnd == true && + ValidDateTimeStamp == true && + ValidUniqueID == true){ + + return CALENDAROBJECTVALID_OK; + + } else { + + return CALENDAROBJECTVALID_INVALIDFORMAT; + + } + +} + +void CalendarJournalObject::ProcessData(){ + + // Process the data. + + multimap DataReceived; + map PropertyData; + string *PropertyNameData = nullptr; + int ObjectSeekCount = 0; + +} \ No newline at end of file diff --git a/source/objects/calendarjournal/CalendarJournal.h b/source/objects/calendarjournal/CalendarJournal.h new file mode 100644 index 0000000..d192dfa --- /dev/null +++ b/source/objects/calendarjournal/CalendarJournal.h @@ -0,0 +1,16 @@ +#ifndef __OBJECTS_CALENDARJOURNAL_CALENDARJOURNAL_H__ +#define __OBJECTS_CALENDARJOURNAL_CALENDARJOURNAL_H__ + +#include "../calendarobject/CalendarObject.h" + +class CalendarJournalObject: public CalendarObject{ + + CalendarObjectValidResult ValidObject(); + + private: + + void ProcessData(); + +}; + +#endif \ No newline at end of file -- 2.39.5