Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Constructing an embedded store

Embedded stores are represented by an instance of the CEmbeddedStore class.

A CEmbeddedStore object is constructed from a host stream.

When the CEmbeddedStore object represents a new embedded store, it is constructed from an RWriteStream object; for example, a class might include the following code fragment in one of its functions:

...
    // create the stream to contain the embedded store
RStoreWriteStream childStream;
                // we need to keep track of this stream id
iEmbeddedStoreId = childStream.CreateLC(iStore);
    // construct the embedded store
CPersistentStore* embeddedStore = CEmbeddedStore::NewLC(childStream);
...

Here, the code assumes that iStore refers to the top level store and iEmbeddedStoreId is a data member to hold the ID of the hosting stream.

On successful construction, ownership of the host stream passes to the embedded store which means that the embedded store takes on the responsibility for closing the stream.

When the CEmbeddedStore object represents an existing embedded store, it is constructed from an RReadStream object; for example, a class might include the following code fragment in one of its functions:

...
RStoreReadStream childStream;
childStream.OpenL(iStore,iEmbeddedStoreId);
iEmbeddedStore = CEmbeddedStore::FromL(childStream);
...

Where:

When saving data, an application re-creates the embedded store by re-writing the complete partial object network to the embedded store, replacing any existing data.