From 07ed06ebe56acbbd34b12ea0111b8fdcbf82a633 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 13 Aug 2019 18:06:19 +0100 Subject: Rewrite and merge LocalStringExt, StringExtItem. --- include/extensible.h | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/extensible.h b/include/extensible.h index fad0c8903..3759b13b9 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -220,13 +220,36 @@ class SimpleExtItem : public ExtensionItem } }; -class CoreExport LocalStringExt : public SimpleExtItem +/** Encapsulates an ExtensionItem which has a string value. */ +class CoreExport StringExtItem : public SimpleExtItem { + protected: + /** Whether to sync this StringExtItem across the network. */ + bool synced; + public: - LocalStringExt(Module* owner, const std::string& key, ExtensibleType exttype); - virtual ~LocalStringExt(); - std::string ToInternal(const Extensible* container, void* item) const override; + /** Initializes an instance of the StringExtItem class. + * @param owner The module which created this StringExtItem. + * @param key The name of the extension item (e.g. ssl_cert). + * @param exttype The type of Extensible that this IntExtItem applies to. + * @param sync Whether this StringExtItem should be broadcast to other servers. + */ + StringExtItem(Module* owner, const std::string& key, ExtensibleType exttype, bool sync = false); + + /** Destroys an instance of the StringExtItem class. */ + virtual ~StringExtItem() = default; + + /** @copydoc ExtensionItem::FromInternal */ void FromInternal(Extensible* container, const std::string& value) override; + + /** @copydoc ExtensionItem::FromNetwork */ + void FromNetwork(Extensible* container, const std::string& value) override; + + /** @copydoc ExtensionItem::ToInternal */ + std::string ToInternal(const Extensible* container, void* item) const override; + + /** @copydoc ExtensionItem::ToNetwork */ + std::string ToNetwork(const Extensible* container, void* item) const override; }; class CoreExport LocalIntExt : public ExtensionItem @@ -241,16 +264,3 @@ class CoreExport LocalIntExt : public ExtensionItem void unset(Extensible* container) { set(container, 0); } void Delete(Extensible* container, void* item) override; }; - -class CoreExport StringExtItem : public ExtensionItem -{ - public: - StringExtItem(Module* owner, const std::string& key, ExtensibleType exttype); - virtual ~StringExtItem(); - std::string* get(const Extensible* container) const; - std::string ToNetwork(const Extensible* container, void* item) const override; - void FromNetwork(Extensible* container, const std::string& value) override; - void set(Extensible* container, const std::string& value); - void unset(Extensible* container); - void Delete(Extensible* container, void* item) override; -}; -- cgit v1.3.1-10-gc9f91