39 lines
677 B
C++
39 lines
677 B
C++
#include "repo.h"
|
|
#include <string>
|
|
#include <fstream>
|
|
|
|
Repo::Repo()
|
|
{
|
|
this->readFromFile();
|
|
}
|
|
|
|
Repo::~Repo()
|
|
{
|
|
|
|
}
|
|
|
|
void Repo::addTask(Task task)
|
|
{
|
|
this->tasks.push_back(task);
|
|
}
|
|
|
|
std::vector<Task> Repo::getTasks()
|
|
{
|
|
return this->tasks;
|
|
}
|
|
|
|
void Repo::readFromFile()
|
|
{
|
|
std::ifstream file("tasks.txt");
|
|
std::string line;
|
|
while (std::getline(file, line)) {
|
|
std::string description = line.substr(0, line.find("|"));
|
|
line.erase(0, line.find("|") + 1);
|
|
int duration = std::stoi(line.substr(0, line.find("|")));
|
|
line.erase(0, line.find("|") + 1);
|
|
std::string date = line.substr(0, line.find("|"));
|
|
Task task(description, duration, date);
|
|
this->addTask(task);
|
|
}
|
|
}
|