Native Streams

A special class of native objects are native streams. These are subclasses of class NativeStream, declared in NativeStream.h. Once created, instances of native streams are accessed by module io.

When subclassing NativeStream, you must implement the following abstract virtual functions:

If the above methods ever return ETrue, the following method must also be overridden: In addition, the class can override the virtual functions SeekL(), Close(), SizeL(), AvailL(), HandleError().

Here is a sample implementation of a native stream subclass reading from and writing to a socket:

class MyStream : public NativeStream {
  RSocket *socket; // owned by this class
  TSockXfrLength xfrLength;

  ~MyStream() {
    // garbage collecting the stream should also delete the socket
    delete socket;
  }


© 2004-2010 airbit AG, CH-8008 Zürich
Document AB-M-NMI-869