-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.cpp
41 lines (34 loc) · 1.12 KB
/
category.cpp
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
#include "category.hpp"
#include "invalid_json.hpp"
#include <valijson/validation_results.hpp>
using namespace std;
using namespace boost::filesystem;
using namespace rapidjson;
const string & category::get_name() const
{
return name;
}
category::category(const GenericValue<UTF8<>> &category, path round_path, const std::vector<unsigned int> &points, unsigned int col)
{
this->name = category["name"].GetString();
auto &answers = category["answers"];
auto size = answers.Capacity();
if (size != points.size()) {
valijson::ValidationResults::Error error({round_path.string(), this->name}, "\"The length of the points array and the length of the answers array have to be equal\"");
throw invalid_json(error);
}
this->answers.resize(size);
path category_path = round_path / category["path"].GetString();
for (SizeType i = 0;i < size;i++)
{
this->answers[i] = answer(answers[i], category_path, points[i], col, i);
}
}
const std::vector<answer>& category::get_answers() const
{
return answers;
}
std::vector<answer>& category::get_mutable_answers()
{
return answers;
}