summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/extensible.h2
-rw-r--r--src/base.cpp12
2 files changed, 14 insertions, 0 deletions
diff --git a/include/extensible.h b/include/extensible.h
index 11d6acbc9..5ac4fa9da 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -201,6 +201,7 @@ class CoreExport LocalStringExt : public SimpleExtItem<std::string>
LocalStringExt(const std::string& key, ExtensibleType exttype, Module* owner);
virtual ~LocalStringExt();
std::string serialize(SerializeFormat format, const Extensible* container, void* item) const;
+ void unserialize(SerializeFormat format, Extensible* container, const std::string& value);
};
class CoreExport LocalIntExt : public LocalExtItem
@@ -209,6 +210,7 @@ class CoreExport LocalIntExt : public LocalExtItem
LocalIntExt(const std::string& key, ExtensibleType exttype, Module* owner);
virtual ~LocalIntExt();
std::string serialize(SerializeFormat format, const Extensible* container, void* item) const;
+ void unserialize(SerializeFormat format, Extensible* container, const std::string& value);
intptr_t get(const Extensible* container) const;
intptr_t set(Extensible* container, intptr_t value);
void unset(Extensible* container) { set(container, 0); }
diff --git a/src/base.cpp b/src/base.cpp
index b007a1098..496b23ef5 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -243,6 +243,12 @@ std::string LocalStringExt::serialize(SerializeFormat format, const Extensible*
return "";
}
+void LocalStringExt::unserialize(SerializeFormat format, Extensible* container, const std::string& value)
+{
+ if (format != FORMAT_NETWORK)
+ set(container, value);
+}
+
LocalIntExt::LocalIntExt(const std::string& Key, ExtensibleType exttype, Module* mod)
: LocalExtItem(Key, exttype, mod)
{
@@ -259,6 +265,12 @@ std::string LocalIntExt::serialize(SerializeFormat format, const Extensible* con
return ConvToStr(reinterpret_cast<intptr_t>(item));
}
+void LocalIntExt::unserialize(SerializeFormat format, Extensible* container, const std::string& value)
+{
+ if (format != FORMAT_NETWORK)
+ set(container, ConvToInt(value));
+}
+
intptr_t LocalIntExt::get(const Extensible* container) const
{
return reinterpret_cast<intptr_t>(get_raw(container));