+// CalendarDataStorage.cpp - CalendarDataStorage class
+//
+// (c) 2016-2017 Xestia Software Development.
+//
+// This file is part of Xestia Calendar.
+//
+// Xestia Calendar is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Calendar is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
+
#include "CalendarDataStorage.h"
#define CDS_RANDOMPOW 24
-#include <iostream>
-
using namespace std;
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
// Start Date.
- if (eventData.DateTimeStartData.size() < 16){
+ if (eventData.dateTimeStartData.size() < 16){
addResult.addEventResult = CDSENTRY_INVALIDFILE;
return addResult;
}
- eventString = eventData.DateTimeStartData.substr(0,4);
+ eventString = eventData.dateTimeStartData.substr(0,4);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(4,2);
+ eventString = eventData.dateTimeStartData.substr(4,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(6,2);
+ eventString = eventData.dateTimeStartData.substr(6,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(9,2);
+ eventString = eventData.dateTimeStartData.substr(9,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(11,2);
+ eventString = eventData.dateTimeStartData.substr(11,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(13,2);
+ eventString = eventData.dateTimeStartData.substr(13,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
int eventEndSecond = 0;
int eventEndDuration = 0;
- if (eventData.DateTimeEndData != ""){
+ if (eventData.dateTimeEndData != ""){
- if (eventData.DateTimeEndData.size() < 16){
+ if (eventData.dateTimeEndData.size() < 16){
addResult.addEventResult = CDSENTRY_INVALIDFILE;
return addResult;
}
- eventString = eventData.DateTimeEndData.substr(0,4);
+ eventString = eventData.dateTimeEndData.substr(0,4);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(4,2);
+ eventString = eventData.dateTimeEndData.substr(4,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(6,2);
+ eventString = eventData.dateTimeEndData.substr(6,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(9,2);
+ eventString = eventData.dateTimeEndData.substr(9,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(11,2);
+ eventString = eventData.dateTimeEndData.substr(11,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(13,2);
+ eventString = eventData.dateTimeEndData.substr(13,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DurationData;
+ eventString = eventData.durationData;
// Process the duration data.
// Get the duration (if DTEND hasn't been specified).
- if (eventData.DurationData.size() > 0){
+ if (eventData.durationData.size() > 0){
bool FoundP = false;
bool FoundW = false;
bool DateTimeMode = false;
- std::string::iterator eventDataChar = eventData.DurationData.begin();
+ std::string::iterator eventDataChar = eventData.durationData.begin();
std::string currentValue = "";
if (*eventDataChar != 'P'){
- eventDataChar = eventData.DurationData.end();
+ eventDataChar = eventData.durationData.end();
}
- for(eventDataChar; eventDataChar != eventData.DurationData.end(); eventDataChar++){
+ for(eventDataChar; eventDataChar != eventData.durationData.end(); eventDataChar++){
// Check if value is a digit.
// Process Entry Name.
- resultCode = sqlite3_bind_text(statementHandle, 2, eventData.SummaryData.c_str(), -1, SQLITE_STATIC);
+ resultCode = sqlite3_bind_text(statementHandle, 2, eventData.summaryData.c_str(), -1, SQLITE_STATIC);
if (resultCode != 0){
addResult.addEventResult = CDSENTRY_FAILED;
string eventDescription;
try {
- eventDescription = eventData.DescriptionList.at(0);
+ eventDescription = eventData.descriptionList.at(0);
}
catch (out_of_range &err){
// Start Date.
- if (eventData.DateTimeStartData.size() < 16){
+ if (eventData.dateTimeStartData.size() < 16){
editResult.editEventResult = CDSENTRY_INVALIDFILE;
return editResult;
}
- eventString = eventData.DateTimeStartData.substr(0,4);
+ eventString = eventData.dateTimeStartData.substr(0,4);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(4,2);
+ eventString = eventData.dateTimeStartData.substr(4,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(6,2);
+ eventString = eventData.dateTimeStartData.substr(6,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(9,2);
+ eventString = eventData.dateTimeStartData.substr(9,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(11,2);
+ eventString = eventData.dateTimeStartData.substr(11,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeStartData.substr(13,2);
+ eventString = eventData.dateTimeStartData.substr(13,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
int eventEndSecond = 0;
int eventEndDuration = 0;
- if (eventData.DateTimeEndData != ""){
+ if (eventData.dateTimeEndData != ""){
- if (eventData.DateTimeEndData.size() < 16){
+ if (eventData.dateTimeEndData.size() < 16){
editResult.editEventResult = CDSENTRY_INVALIDFILE;
return editResult;
}
- eventString = eventData.DateTimeEndData.substr(0,4);
+ eventString = eventData.dateTimeEndData.substr(0,4);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(4,2);
+ eventString = eventData.dateTimeEndData.substr(4,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(6,2);
+ eventString = eventData.dateTimeEndData.substr(6,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(9,2);
+ eventString = eventData.dateTimeEndData.substr(9,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(11,2);
+ eventString = eventData.dateTimeEndData.substr(11,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DateTimeEndData.substr(13,2);
+ eventString = eventData.dateTimeEndData.substr(13,2);
if (all_of(eventString.begin(), eventString.end(), ::isdigit)){
}
- eventString = eventData.DurationData;
+ eventString = eventData.durationData;
// Process the duration data.
// Get the duration (if DTEND hasn't been specified).
- if (eventData.DurationData.size() > 0){
+ if (eventData.durationData.size() > 0){
bool FoundP = false;
bool FoundW = false;
bool DateTimeMode = false;
- std::string::iterator eventDataChar = eventData.DurationData.begin();
+ std::string::iterator eventDataChar = eventData.durationData.begin();
std::string currentValue = "";
if (*eventDataChar != 'P'){
- eventDataChar = eventData.DurationData.end();
+ eventDataChar = eventData.durationData.end();
}
- for(eventDataChar; eventDataChar != eventData.DurationData.end(); eventDataChar++){
+ for(eventDataChar; eventDataChar != eventData.durationData.end(); eventDataChar++){
// Check if value is a digit.
// Process Entry Name.
- resultCode = sqlite3_bind_text(statementHandle, 2, eventData.SummaryData.c_str(), -1, SQLITE_STATIC);
+ resultCode = sqlite3_bind_text(statementHandle, 2, eventData.summaryData.c_str(), -1, SQLITE_STATIC);
if (resultCode != 0){
editResult.editEventResult = CDSENTRY_FAILED;
string eventDescription;
try {
- eventDescription = eventData.DescriptionList.at(0);
+ eventDescription = eventData.descriptionList.at(0);
}
catch (out_of_range &err){