forked from University/epr24pr5-ojanssen2
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#include "std_lib_inc.h"
|
|
#include "FormatError.h"
|
|
#include "Util.h"
|
|
#ifndef TASK_H
|
|
#define TASK_H
|
|
|
|
using err::FormatError;
|
|
using util::Util;
|
|
|
|
namespace models {
|
|
class Task {
|
|
private:
|
|
int id;
|
|
string name;
|
|
string description;
|
|
vector<int> children;
|
|
public:
|
|
Task(const int& id, const string& name, const string& description, const vector<int>& children);
|
|
|
|
Task();
|
|
|
|
ostream& write(ostream& stream);
|
|
istream& read(istream&);
|
|
|
|
int get_id() const;
|
|
string get_name() const;
|
|
string get_description() const;
|
|
vector<int> get_children() const;
|
|
|
|
|
|
friend ostream& operator<<(ostream& os, const Task& t);
|
|
friend istream& operator>>(istream& is, Task& t);
|
|
};
|
|
|
|
inline ostream& operator<<(ostream& os, const Task& t) {
|
|
os << t.get_id() << " " << t.get_name() << " " << t.get_description();
|
|
return os;
|
|
}
|
|
inline istream& operator>>(istream& is, Task& t) {
|
|
int id;
|
|
is >> id;
|
|
if (!is)
|
|
throw FormatError("Id NaN.");
|
|
|
|
string name = Util::read_string_between_percent(is);
|
|
string description = Util::read_string_between_percent(is);
|
|
vector<int> children = Util::read_numbers(is);
|
|
|
|
t = {id, name, description, children};
|
|
return is;
|
|
}
|
|
}
|
|
|
|
#endif // TASK_H
|
|
|