summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/StreamI.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-08-31 13:10:26 +0000
committerMark Spruiell <mes@zeroc.com>2004-08-31 13:10:26 +0000
commit1b9072c62553bb7974a1518bc14bd5b1376001ed (patch)
treebe4733dea3441c3d0424e28eb7a2ec235fcaa8d2 /cpp/src/Ice/StreamI.cpp
parentminor edits (diff)
downloadice-1b9072c62553bb7974a1518bc14bd5b1376001ed.tar.bz2
ice-1b9072c62553bb7974a1518bc14bd5b1376001ed.tar.xz
ice-1b9072c62553bb7974a1518bc14bd5b1376001ed.zip
adding public streaming API
Diffstat (limited to 'cpp/src/Ice/StreamI.cpp')
-rw-r--r--cpp/src/Ice/StreamI.cpp445
1 files changed, 445 insertions, 0 deletions
diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp
new file mode 100644
index 00000000000..e6e3bf00250
--- /dev/null
+++ b/cpp/src/Ice/StreamI.cpp
@@ -0,0 +1,445 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Ice/StreamI.h>
+
+using namespace std;
+using namespace Ice;
+
+//
+// BasicInputStream
+//
+IceInternal::BasicInputStream::BasicInputStream(IceInternal::Instance* instance, InputStream* in) :
+ BasicStream(instance), _in(in)
+{
+}
+
+//
+// BasicOutputStream
+//
+IceInternal::BasicOutputStream::BasicOutputStream(IceInternal::Instance* instance, OutputStream* out) :
+ BasicStream(instance), _out(out)
+{
+}
+
+//
+// InputStreamI
+//
+Ice::InputStreamI::InputStreamI(const IceInternal::InstancePtr& instance, const vector<Byte>& data) :
+ _is(instance.get(), this), _readObjects(false)
+{
+ _is.b = data;
+ _is.i = _is.b.begin();
+}
+
+Ice::InputStreamI::~InputStreamI()
+{
+}
+
+void
+Ice::InputStreamI::sliceObjects(bool b)
+{
+ _is.sliceObjects(b);
+}
+
+bool
+Ice::InputStreamI::readBool()
+{
+ bool v;
+ _is.read(v);
+ return v;
+}
+
+vector<bool>
+Ice::InputStreamI::readBoolSeq()
+{
+ vector<bool> v;
+ _is.read(v);
+ return v;
+}
+
+Byte
+Ice::InputStreamI::readByte()
+{
+ Byte v;
+ _is.read(v);
+ return v;
+}
+
+vector<Byte>
+Ice::InputStreamI::readByteSeq()
+{
+ vector<Byte> v;
+ _is.read(v);
+ return v;
+}
+
+Short
+Ice::InputStreamI::readShort()
+{
+ Short v;
+ _is.read(v);
+ return v;
+}
+
+vector<Short>
+Ice::InputStreamI::readShortSeq()
+{
+ vector<Short> v;
+ _is.read(v);
+ return v;
+}
+
+Int
+Ice::InputStreamI::readInt()
+{
+ Int v;
+ _is.read(v);
+ return v;
+}
+
+vector<Int>
+Ice::InputStreamI::readIntSeq()
+{
+ vector<Int> v;
+ _is.read(v);
+ return v;
+}
+
+Long
+Ice::InputStreamI::readLong()
+{
+ Long v;
+ _is.read(v);
+ return v;
+}
+
+vector<Long>
+Ice::InputStreamI::readLongSeq()
+{
+ vector<Long> v;
+ _is.read(v);
+ return v;
+}
+
+Float
+Ice::InputStreamI::readFloat()
+{
+ Float v;
+ _is.read(v);
+ return v;
+}
+
+vector<Float>
+Ice::InputStreamI::readFloatSeq()
+{
+ vector<Float> v;
+ _is.read(v);
+ return v;
+}
+
+Double
+Ice::InputStreamI::readDouble()
+{
+ Double v;
+ _is.read(v);
+ return v;
+}
+
+vector<Double>
+Ice::InputStreamI::readDoubleSeq()
+{
+ vector<Double> v;
+ _is.read(v);
+ return v;
+}
+
+string
+Ice::InputStreamI::readString()
+{
+ string v;
+ _is.read(v);
+ return v;
+}
+
+vector<string>
+Ice::InputStreamI::readStringSeq()
+{
+ vector<string> v;
+ _is.read(v);
+ return v;
+}
+
+Int
+Ice::InputStreamI::readSize()
+{
+ Int sz;
+ _is.readSize(sz);
+ return sz;
+}
+
+ObjectPrx
+Ice::InputStreamI::readProxy()
+{
+ Ice::ObjectPrx v;
+ _is.read(v);
+ return v;
+}
+
+static void
+patchObject(void* addr, ObjectPtr& v)
+{
+ ReadObjectCallback* cb = static_cast<ReadObjectCallback*>(addr);
+ assert(cb);
+ cb->invoke(v);
+}
+
+void
+Ice::InputStreamI::readObject(const ReadObjectCallbackPtr& cb)
+{
+ _readObjects = true;
+ _callbacks.push_back(cb); // Keep reference to callback.
+ _is.read(patchObject, cb.get());
+}
+
+string
+Ice::InputStreamI::readTypeId()
+{
+ string id;
+ _is.readTypeId(id);
+ return id;
+}
+
+void
+Ice::InputStreamI::throwException()
+{
+ _is.throwException();
+}
+
+void
+Ice::InputStreamI::startSlice()
+{
+ _is.startReadSlice();
+}
+
+void
+Ice::InputStreamI::endSlice()
+{
+ _is.endReadSlice();
+}
+
+void
+Ice::InputStreamI::skipSlice()
+{
+ _is.skipSlice();
+}
+
+void
+Ice::InputStreamI::finished()
+{
+ if(_readObjects)
+ {
+ _is.readPendingObjects();
+ }
+}
+
+//
+// OutputStreamI
+//
+Ice::OutputStreamI::OutputStreamI(const IceInternal::InstancePtr& instance) :
+ _os(instance.get(), this), _writeObjects(false)
+{
+}
+
+Ice::OutputStreamI::~OutputStreamI()
+{
+}
+
+void
+Ice::OutputStreamI::writeBool(bool v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeBoolSeq(const vector<bool>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeByte(Byte v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeByteSeq(const vector<Byte>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeShort(Short v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeShortSeq(const vector<Short>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeInt(Int v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeIntSeq(const vector<Int>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeLong(Long v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeLongSeq(const vector<Long>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeFloat(Float v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeFloatSeq(const vector<Float>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeDouble(Double v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeDoubleSeq(const vector<Double>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeString(const string& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeStringSeq(const vector<string>& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeSize(Int sz)
+{
+ _os.writeSize(sz);
+}
+
+void
+Ice::OutputStreamI::writeProxy(const ObjectPrx& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeObject(const ObjectPtr& v)
+{
+ _writeObjects = true;
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::writeTypeId(const string& id)
+{
+ _os.writeTypeId(id);
+}
+
+void
+Ice::OutputStreamI::writeException(const UserException& v)
+{
+ _os.write(v);
+}
+
+void
+Ice::OutputStreamI::startSlice()
+{
+ _os.startWriteSlice();
+}
+
+void
+Ice::OutputStreamI::endSlice()
+{
+ _os.endWriteSlice();
+}
+
+void
+Ice::OutputStreamI::finished(vector<Byte>& bytes)
+{
+ if(_writeObjects)
+ {
+ _os.writePendingObjects();
+ }
+ bytes.swap(_os.b);
+}
+
+//
+// ObjectReader
+//
+void
+Ice::ObjectReader::__write(::IceInternal::BasicStream*) const
+{
+ assert(false);
+}
+
+void
+Ice::ObjectReader::__read(::IceInternal::BasicStream* is, bool rid)
+{
+ IceInternal::BasicInputStream* bis = dynamic_cast<IceInternal::BasicInputStream*>(is);
+ assert(bis);
+ read(bis->_in, rid);
+}
+
+//
+// ObjectWriter
+//
+void
+Ice::ObjectWriter::__write(::IceInternal::BasicStream* os) const
+{
+ IceInternal::BasicOutputStream* bos = dynamic_cast<IceInternal::BasicOutputStream*>(os);
+ assert(bos);
+ write(bos->_out);
+}
+
+void
+Ice::ObjectWriter::__read(::IceInternal::BasicStream*, bool)
+{
+ assert(false);
+}