diff options
author | Your Name <you@example.com> | 2021-05-20 17:00:53 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-05-20 17:00:53 -0400 |
commit | b27700a7e0b281ece3dea23060c17e0cae28715d (patch) | |
tree | ef13e98281dd0183c4fb1e32cdf371ea1f6c1794 /src/entry.h | |
parent | be88609c825e18201f240415fe74a31c1a789484 (diff) | |
download | dmtool-b27700a7e0b281ece3dea23060c17e0cae28715d.tar.gz dmtool-b27700a7e0b281ece3dea23060c17e0cae28715d.tar.bz2 dmtool-b27700a7e0b281ece3dea23060c17e0cae28715d.zip |
Reduced exposure of implementation details
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; }; } |