diff options
Diffstat (limited to 'src/entry.h')
-rw-r--r-- | src/entry.h | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/entry.h b/src/entry.h index 9e00798..abfe831 100644 --- a/src/entry.h +++ b/src/entry.h @@ -8,34 +8,26 @@ namespace creature { } namespace entry { + struct entryImpl; + class Entry { public: - Entry() {} + Entry(); // Also can be created programmatically - Entry(const std::string& entry, const std::string& name, const std::string& type, const std::string& text) : entry(entry), name(name), type(type), text(text) {} + Entry(const std::string& entry, const std::string& name, const std::string& type, const std::string& text); static std::shared_ptr<Entry> create(const nlohmann::json& data); virtual ~Entry() {} - std::string getName(void) const {return name;} - std::string getType(void) const {return type;} - virtual std::string getText(void) const {return text;} - void setText(std::string t) {text = t;} + std::string getName(void) const; + std::string getType(void) const; + virtual std::string getText(void) const; + virtual std::string getText(const creature::Creature& c) const; + void setText(const std::string& t); virtual void init(void) {} - virtual nlohmann::json serialize(void) const { - nlohmann::json ret; - to_json(ret, *this); - return ret; - } - virtual std::string getText(const creature::Creature& c) const { - return getName() + " (" + getType() + "): " + getText(); - } - - NLOHMANN_DEFINE_TYPE_INTRUSIVE(Entry, entry, name, type, text); + + NLOHMANN_FRIEND_DECLARES(Entry); private: - std::string entry; - std::string name; - std::string type; - std::string text; + std::shared_ptr<entryImpl> data; }; } |