From b27700a7e0b281ece3dea23060c17e0cae28715d Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 20 May 2021 17:00:53 -0400 Subject: Reduced exposure of implementation details --- src/entry.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/entry.cc') 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;} } -- cgit v1.2.3