How to commit streams

Once data has been externalised to a stream, an application must commit a stream before disposing of the write stream object.

This is done by calling CommitL() on the write stream object. The function itself is a member of the write stream interface class, RWriteStream.

The following example code fragment shows this:

...
TSimple thesimple;
...
...              // Construct a TSimple object
...
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC(*store);
                 // Externalize the TSimple object
outstream  << thesimple;
                 // Commit changes to the stream
outstream.CommitL();
                 // Cleanup the stream object
CleanupStack::PopAndDestroy();
...

store is a pointer to an already opened stream store.

As a simple rule, CreateL() or CreateLC() is matched by a call to CommitL(). More generally, any change to a stream, either the creation of a new one or a change to an existing one, should be matched by a call to CommitL().