aboutsummaryrefslogtreecommitdiff
path: root/src/extensible.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2019-08-13 18:06:19 +0100
committerGravatar Sadie Powell2019-08-13 18:12:59 +0100
commit07ed06ebe56acbbd34b12ea0111b8fdcbf82a633 (patch)
tree9e5a53e1b65d7f7e606da3da648ff16df82ae34d /src/extensible.cpp
parentMove the Module parameter of ExtensionItem et al to the start. (diff)
Rewrite and merge LocalStringExt, StringExtItem.
Diffstat (limited to 'src/extensible.cpp')
-rw-r--r--src/extensible.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/extensible.cpp b/src/extensible.cpp
new file mode 100644
index 000000000..7cf0006f4
--- /dev/null
+++ b/src/extensible.cpp
@@ -0,0 +1,51 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "inspircd.h"
+
+
+StringExtItem::StringExtItem(Module* owner, const std::string& key, ExtensibleType exttype, bool sync)
+ : SimpleExtItem(owner, key, exttype)
+ , synced(sync)
+{
+}
+
+void StringExtItem::FromInternal(Extensible* container, const std::string& value)
+{
+ if (value.empty())
+ unset(container);
+ else
+ set(container, value);
+}
+
+void StringExtItem::FromNetwork(Extensible* container, const std::string& value)
+{
+ if (synced)
+ FromInternal(container, value);
+}
+
+std::string StringExtItem::ToInternal(const Extensible* container, void* item) const
+{
+ return item ? *static_cast<std::string*>(item) : std::string();
+}
+
+std::string StringExtItem::ToNetwork(const Extensible* container, void* item) const
+{
+ return synced ? ToInternal(container, item) : std::string();
+}