#ifndef GETTERS_CPP #define GETTERS_CPP #include #include "dataStructures.hpp" std::string stringToTaskTitle(const std::string s) { size_t firstCharacter = s.find(CHARACTER_BETWEEN_SECTIONTS); return s.substr(0, firstCharacter); } std::string stringToTime(const std::string s) { size_t firstCharacter = s.find(CHARACTER_BETWEEN_SECTIONTS); return s.substr(firstCharacter + SPACE_BETWEEN_TASK_PARTS, TIME_LENGTH); } std::string stringToStringDate(const std::string s) { size_t firstCharacter = s.find(CHARACTER_BETWEEN_SECTIONTS); return s.substr(firstCharacter + SPACE_BETWEEN_TASK_PARTS, DATE_LENGTH); } Date stringToRealDate(const std::string s) { Date newDate; newDate.day = std::stoi(s.substr(0, DAY_LENGTH)); newDate.month = std::stoi(s.substr(MONTH_START, MONTH_LENGTH)); newDate.year = std::stoi(s.substr(YEAR_START, YEAR_LENGTH)); return newDate; } int stringToWhenRepeat(const std::string s) { size_t firstCharacter = s.find(CHARACTER_BETWEEN_SECTIONTS); size_t secondCharacter = s.find(CHARACTER_BETWEEN_SECTIONTS, firstCharacter + SPACE_BETWEEN_TASK_PARTS); return std::stoi(s.substr(secondCharacter + SPACE_BETWEEN_TASK_PARTS, WHEN_REPEAT_LENGTH)); } Task stringToTask(const std::string s, int ¤tTaskNumber) { Task outputTask; outputTask.title = stringToTaskTitle(s); //dividedTasks.at(i).time = stringToTime(s); outputTask.date = stringToStringDate(s); outputTask.realDate = stringToRealDate(outputTask.date); outputTask.whenRepeat = stringToWhenRepeat(s); outputTask.number = currentTaskNumber; currentTaskNumber++; return outputTask; } std::vector getDividedTasks(const std::vector fileLines) { std::vector dividedTasks(fileLines.size()); int currentTaskNumber = 0; for(unsigned int i = 0; i < fileLines.size(); i++) { std::string currentLine = fileLines.at(i); dividedTasks.at(i) = stringToTask(currentLine, currentTaskNumber); } return dividedTasks; } /* std::vector