-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.cpp
More file actions
62 lines (50 loc) · 1.46 KB
/
Copy pathTask.cpp
File metadata and controls
62 lines (50 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "Task.hpp"
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>
#include "CodeSnippet.hpp"
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems)
{
std::stringstream ss(s);
std::string item;
while (std::getline(ss,item, delim)) {
elems.push_back(item);
}
return elems;
}
std::vector<std::string> split(const std::string &s, char delim)
{
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}
Task::Task(std::string name, std::string description, std::string assignee, std::string dueDate)
: name(name), description(description), assignee(assignee), dueDate(dueDate)
{
int firstSquareIndex = description.find('[');
int secondSquareIndex = description.find(']');
std::string code = description.substr(firstSquareIndex + 1, secondSquareIndex - (firstSquareIndex + 1));
std::cout << code << std::endl;
char chars[] = " ]";
for (unsigned int i = 0; i < 2; ++i)
{
code.erase(std::remove(code.begin(), code.end(), chars[i]), code.end());
}
std::cout << code << std::endl;
std::vector<std::string> splitteds = split(code, ',');
CodeSnippet snippet(splitteds[0], atoi(splitteds[1].c_str()));
this->description += snippet.getLines();
}
std::string Task::getName() const {
return name;
}
std::string Task::getDescription() const {
return description;
}
std::string Task::getAssignee() const {
return assignee;
}
std::string Task::getDate() const {
return dueDate;
}