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.cc | |
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.cc')
-rw-r--r-- | src/entry.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/entry.cc b/src/entry.cc index 77cf144..663a40a 100644 --- a/src/entry.cc +++ b/src/entry.cc @@ -20,4 +20,31 @@ namespace entry { } throw std::invalid_argument("Invalid entry: " + std::string(data["entry"])); } + + struct entryImpl { + std::string entry; + std::string name; + std::string type; + std::string text; + }; + NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(entryImpl, entry, name, type, text); + + NLOHMANN_FRIEND_DEFS_BASE(Entry, data); + + Entry::Entry() : data(new entryImpl()) {} + + Entry::Entry(const std::string& entry, const std::string& name, const std::string& type, const std::string& text) : data(new entryImpl()) { + data->entry = entry; + data->name = name; + data->type = type; + data->text = text; + } + + std::string Entry::getName(void) const {return data->name;} + std::string Entry::getType(void) const {return data->type;} + std::string Entry::getText(void) const {return data->text;} + std::string Entry::getText(const creature::Creature& c) const { + return getName() + " (" + getType() + "): " + getText(); + } + void Entry::setText(const std::string& t) {data->text = t;} } |