diff options
author | Peter Powell <petpow@saberuk.com> | 2019-08-07 19:37:27 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-08-07 19:37:27 +0100 |
commit | 714284aa306f2912eaca0c28d779d227db62a96b (patch) | |
tree | a559faf3cfb5b986255ad8b40adf8af1a3866654 /src/coremods | |
parent | 85182d727c0d549b9cf6659ad36dec70fcf02278 (diff) |
Convert all core ExtensionItem code away from {un,}serialize.
Diffstat (limited to 'src/coremods')
-rw-r--r-- | src/coremods/core_channel/invite.cpp | 4 | ||||
-rw-r--r-- | src/coremods/core_channel/invite.h | 38 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src/coremods/core_channel/invite.cpp b/src/coremods/core_channel/invite.cpp index 51fb638f8..d96045fc4 100644 --- a/src/coremods/core_channel/invite.cpp +++ b/src/coremods/core_channel/invite.cpp @@ -179,12 +179,12 @@ Invite::Invite::~Invite() ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Invite::~ %p", (void*) this); } -void Invite::Invite::Serialize(SerializeFormat format, bool show_chans, std::string& out) +void Invite::Invite::Serialize(bool human, bool show_chans, std::string& out) { if (show_chans) out.append(this->chan->name); else - out.append((format == FORMAT_USER) ? user->nick : user->uuid); + out.append(human ? user->nick : user->uuid); out.push_back(' '); if (expiretimer) diff --git a/src/coremods/core_channel/invite.h b/src/coremods/core_channel/invite.h index 19e3861f8..357acd846 100644 --- a/src/coremods/core_channel/invite.h +++ b/src/coremods/core_channel/invite.h @@ -45,6 +45,21 @@ extern void UnserializeInvite(LocalUser* user, const std::string& value); template<typename T, ExtensionItem::ExtensibleType ExtType> class Invite::ExtItem : public ExtensionItem { + private: + static std::string ToString(void* item, bool human) + { + std::string ret; + Store<T>* store = static_cast<Store<T>*>(item); + for (typename insp::intrusive_list<Invite, T>::iterator i = store->invites.begin(); i != store->invites.end(); ++i) + { + Invite* inv = *i; + inv->Serialize(human, (ExtType == ExtensionItem::EXT_USER), ret); + } + if (!ret.empty()) + ret.erase(ret.length()-1); + return ret; + } + public: ExtItem(Module* owner, const char* extname) : ExtensionItem(extname, ExtType, owner) @@ -83,26 +98,19 @@ class Invite::ExtItem : public ExtensionItem delete store; } - std::string serialize(SerializeFormat format, const Extensible* container, void* item) const CXX11_OVERRIDE + std::string ToHuman(const Extensible* container, void* item) const CXX11_OVERRIDE { - if (format == FORMAT_NETWORK) - return std::string(); + return ToString(item, true); + } - std::string ret; - Store<T>* store = static_cast<Store<T>*>(item); - for (typename insp::intrusive_list<Invite, T>::iterator i = store->invites.begin(); i != store->invites.end(); ++i) - { - Invite* inv = *i; - inv->Serialize(format, (ExtType == ExtensionItem::EXT_USER), ret); - } - if (!ret.empty()) - ret.erase(ret.length()-1); - return ret; + std::string ToInternal(const Extensible* container, void* item) const CXX11_OVERRIDE + { + return ToString(item, false); } - void unserialize(SerializeFormat format, Extensible* container, const std::string& value) CXX11_OVERRIDE + void FromInternal(Extensible* container, const std::string& value) CXX11_OVERRIDE { - if ((ExtType != ExtensionItem::EXT_CHANNEL) && (format != FORMAT_NETWORK)) + if (ExtType != ExtensionItem::EXT_CHANNEL) UnserializeInvite(static_cast<LocalUser*>(container), value); } }; |