blob: a415947bd9593dd16535155ae553430144559526 (
plain)
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
|
#pragma once
#include "json.hpp"
#include "jsonable.h"
#include <memory>
namespace item {
class Item : public Jsonable {
public:
static std::shared_ptr<Item> create(const nlohmann::json& data);
virtual ~Item() {}
std::string getName(void) const {return name;}
std::string getType(void) const {return type;}
virtual std::string getText(void) const {return text;}
virtual nlohmann::json toJson(void) const {
return nlohmann::json({
{"name", name},
{"type", type},
{"text", text}
});
}
protected:
Item(const nlohmann::json& data) : name(data["name"]), type(data["type"]), text(data["text"]) {};
private:
const std::string name;
const std::string type;
const std::string text;
};
}
|