summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/Object.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2002-01-23 16:22:43 +0000
committerMatthew Newhook <matthew@zeroc.com>2002-01-23 16:22:43 +0000
commit48b22912b2d0b30ed6a4bf3b175801c57f12525b (patch)
tree0ce25e038871c5f8607794af01b16aa2095175bf /cpp/src/Ice/Object.cpp
parentfixes (diff)
downloadice-48b22912b2d0b30ed6a4bf3b175801c57f12525b.tar.bz2
ice-48b22912b2d0b30ed6a4bf3b175801c57f12525b.tar.xz
ice-48b22912b2d0b30ed6a4bf3b175801c57f12525b.zip
Initial commit of generic marshaling.
Diffstat (limited to 'cpp/src/Ice/Object.cpp')
-rw-r--r--cpp/src/Ice/Object.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index 81d065d7348..e54df1a47fb 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -11,6 +11,7 @@
#include <Ice/Object.h>
#include <Ice/Incoming.h>
#include <Ice/Current.h>
+#include <Ice/Stream.h>
using namespace std;
using namespace Ice;
@@ -161,12 +162,68 @@ Ice::Object::__read(::IceInternal::BasicStream* __is)
{
pair<string, ObjectPtr> v;
__is->read(v.first);
- __is->read("", v.second);
+ __is->read("", 0, v.second);
_activeFacetMapHint = _activeFacetMap.insert(_activeFacetMapHint, v);
}
}
void
+Ice::Object::__marshal(const ::Ice::StreamPtr& __os) const
+{
+ IceUtil::Mutex::Lock sync(_activeFacetMapMutex);
+
+ __os->startWriteDictionary("ice:facets", _activeFacetMap.size());
+ for (map<string, ObjectPtr>::const_iterator p = _activeFacetMap.begin(); p != _activeFacetMap.end(); ++p)
+ {
+ __os->startWriteDictionaryElement();
+ __os->writeString("key", p->first);
+ __os->writeObject("value", p->second);
+ __os->endWriteDictionaryElement();
+ }
+ __os->endWriteDictionary();
+}
+
+
+void
+Ice::Object::__unmarshal(const ::Ice::StreamPtr& __is)
+{
+ IceUtil::Mutex::Lock sync(_activeFacetMapMutex);
+
+ static const string facetsName = "facets"; // Not ice:facets since xerces eats namespaces
+ static const string keyName = "key";
+ static const string valueName = "value";
+
+ Int sz;
+ __is->startReadDictionary(facetsName, sz);
+
+ _activeFacetMap.clear();
+ _activeFacetMapHint = _activeFacetMap.end();
+
+ while (sz-- > 0)
+ {
+ __is->startReadDictionaryElement();
+ pair<string, ObjectPtr> v;
+ __is->readString(keyName, v.first);
+ __is->readObject(valueName, "", 0, v.second);
+ _activeFacetMapHint = _activeFacetMap.insert(_activeFacetMapHint, v);
+ __is->endReadDictionaryElement();
+ }
+ __is->endReadDictionary();
+}
+
+void
+Ice::Object::ice_marshal(const string& name, const ::Ice::StreamPtr& stream)
+{
+ stream->writeObject(name, this);
+}
+
+void
+Ice::Object::ice_unmarshal(const string& name, const ::Ice::StreamPtr& stream, ObjectPtr& value)
+{
+ stream->readObject(name, "", 0, value);
+}
+
+void
Ice::Object::ice_addFacet(const ObjectPtr& facet, const string& name)
{
IceUtil::Mutex::Lock sync(_activeFacetMapMutex);