The basic protocol for storing is the StoreL() function and should be prototyped as:
TStreamId StoreL(CStreamStore& aStore) const;
The function takes a reference to the store in which the stream is to be stored and returns the stream ID through which the object can be restored.
In some cases, the design of a class may be such that it maintains a pointer or reference to the store. In this event, the CStreamStore argument would be redundant.
To store an object that does not contain any other objects:
construct a write stream object, i.e. an instance of RStoreWriteStream
externalise the object
return the ID of the stream
The following code fragment shows the canonical form for some general class CClassA:
TStreamId CClassA::StoreL(CStreamStore& aStore) const { RStoreWriteStream stream; TStreamId id=stream.CreateLC(aStore); ExternalizeL(stream); stream.CommitL(); CleanupStack::PopAndDestroy(); return id; }
The basic protocol for restoring is the <code>RestoreL()</code> function and should be prototyped as:
void RestoreL(CStreamStore& aStore,TStreamId anId);
The function takes a reference to the store in which the stream is stored and the ID that identifies that stream is stored.
To restore an object that does not contain any other objects:
construct a read stream object, i.e. an instance of
RStoreReadStreaminternalise the object.
The following code fragment shows an example for some general class
CClassAvoid CClassA::RestoreL(CStreamStore& aStore, TStreamId anId) { RStoreReadStream stream; stream.OpenLC(aStore,anId); InternalizeL(stream); CleanupStack::PopAndDestroy(); }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.