Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to create streams


Write streams

The following code fragment shows how a write stream is created. A write stream is represented by an instance of the RStoreWriteStream class and an object of this type can be created on the program stack.

Use the CreateL() or CreateLC() member function of RStoreWriteStream to create a new stream in a store and return its stream ID.

...
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC(*store);
...
CleanupStack::PopAndDestroy();
...

store is a pointer to an already opened stream store.

Some stores allow their existing streams to be modified, for example, by overwriting or appending. To open an existing stream for overwriting, use OpenL() or OpenLC() and identify both the store and the stream:

...
RStoreWriteStream outstream;
TStreamId id;
...
outstream.CreateLC(*store,id);
...
CleanupStack::PopAndDestroy();
...

In this code fragment, the id of the stream must be known before calling CreateLC().

Note that not all store types support the modification of existing streams. An attempt to open an existing stream for modification for these store types will fail. A direct file store is an example of a store which does not support the modification of existing streams.

[Top]


Read streams

The following code fragment shows how a read stream is created. A read stream is represented by an instance of the RStoreReadStream class and an object of this type can be created on the program stack.

Use the OpenL() or OpenLC() member function of RStoreReadStream to open a stream for reading.

RStoreReadStream instream;
TStream id;
...
instream.OpenLC(*store,id);
...

store is a pointer to an already opened stream store.

id identifies the stream to be opened.