An InputStream is created using the following function:
{zcode:cs}
namespace Ice
{
public sealed class Util
{
public static InputStream createInputStream(
Communicator communicator,
byte[] bytes);
}
}
{zcode} |
The InputStream interface is shown below.
{zcode:cs}
namespace Ice
{
public interface InputStream
{
Communicator communicator();
void sliceObjects(bool slice);
bool readBool();
bool[] readBoolSeq();
byte readByte();
byte[] readByteSeq();
short readShort();
short[] readShortSeq();
int readInt();
int[] readIntSeq();
long readLong();
long[] readLongSeq();
float readFloat();
float[] readFloatSeq();
double readDouble();
double[] readDoubleSeq();
string readString();
string[] readStringSeq();
int readSize();
int readAndCheckSeqSize(int minSize);
ObjectPrx readProxy();
void readObject(ReadObjectCallback cb);
string readTypeId();
void throwException();
void startSlice();
void endSlice();
void skipSlice();
void startEncapsulation();
void endEncapsulation();
void skipEncapsulation();
int getEncapsulationSize();
void readPendingObjects();
object readSerializable();
void rewind();
void destroy();
}
}
{zcode} |
Member functions are provided for extracting all of the primitive types, as well as sequences of primitive types; these are self-explanatory. The remaining member functions have the following semantics:
void sliceObjects(boolean slice)NoObjectFactoryException is raised. The default behavior is to allow slicing.int readSize()int readAndCheckSeqSize(int minWireSize)readSize, this function reads a size and returns it, but also verifies that there is enough data remaining in the unmarshaling buffer to successfully unmarshal the elements of the sequence. The minWireSize parameter indicates the smallest possible on-the-wire representation of a single sequence element. If the unmarshaling buffer contains insufficient data to unmarshal the sequence, the function throws UnmarshalOutOfBoundsException.Ice.ObjectPrx readProxy()ObjectPrx. The Slice compiler optionally generates helper functions to extract proxies of user-defined types.void readObject(ReadObjectCallback cb)readObject function accepts a callback object of type ReadObjectCallback, whose definition is shown below:
{zcode:cs}
namespace Ice
{
public interface ReadObjectCallback
{
void invoke(Ice.Object obj);
}
}
{zcode} |
invoke member function is called. The application must call readPendingObjects to ensure that all instances are properly extracted. Note that applications rarely need to invoke this member function directly; the helper functions generated by the Slice compiler are easier to use.string readTypeId()void throwException()UnmarshalOutOfBoundsException is thrown.void startSlice()void endSlice() void skipSlice()void startEncapsulation()void endEncapsulation()void skipEncapsulation()int getEncapsulationSize()void readPendingObjects()readObject).object readSerializable()void rewind()void destroy()Here is a simple example that demonstrates how to extract a boolean and a sequence of strings from a stream:
{zcode:cs}
byte[] data = ...
Ice.InputStream inStream =
Ice.Util.createInputStream(communicator, data);
try {
bool b = inStream.readBool();
string[] seq = inStream.readStringSeq();
} finally {
inStream.destroy();
}
{zcode} |