Symbian3/SDK/Source/GUID-95448841-5E5B-54C4-85A7-DCE6D078E036.dita
changeset 0 89d6a7a84779
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-95448841-5E5B-54C4-85A7-DCE6D078E036.dita	Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
+<!-- This component and the accompanying materials are made available under the terms of the License 
+"Eclipse Public License v1.0" which accompanies this distribution, 
+and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
+<!-- Initial Contributors:
+    Nokia Corporation - initial contribution.
+Contributors: 
+-->
+<!DOCTYPE concept
+  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
+<concept xml:lang="en" id="GUID-95448841-5E5B-54C4-85A7-DCE6D078E036"><title>Constructing an embedded store</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Embedded stores are represented by an instance of the <codeph>CEmbeddedStore</codeph> class.</p> <p>A <codeph>CEmbeddedStore</codeph> object is constructed from a host stream. </p> <p>When the <codeph>CEmbeddedStore</codeph> object represents a new embedded store, it is constructed from an <codeph>RWriteStream</codeph> object; for example, a class might include the following code fragment in one of its functions:</p> <codeblock id="GUID-47D69E5D-909D-5EA3-96CD-3FB6ED5E77CB" xml:space="preserve">...
+    // 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);
+...</codeblock> <p>Here, the code assumes that <codeph>iStore</codeph> refers to the top level store and <codeph>iEmbeddedStoreId</codeph> is a data member to hold the ID of the hosting stream.</p> <p>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.</p> <p>When the <codeph>CEmbeddedStore</codeph> object represents an existing embedded store, it is constructed from an <codeph>RReadStream</codeph> object; for example, a class might include the following code fragment in one of its functions:</p> <codeblock id="GUID-A796CC6C-69C9-5F22-B7A1-30815086EAA3" xml:space="preserve">...
+RStoreReadStream childStream;
+childStream.OpenL(iStore,iEmbeddedStoreId);
+iEmbeddedStore = CEmbeddedStore::FromL(childStream);
+...</codeblock> <p>Where:</p> <ul><li id="GUID-7A3338F6-252E-5D47-9D22-CDD505222958"><p><codeph>iStore</codeph> refers to the top level store</p> </li> <li id="GUID-162A3315-AA91-55CD-B07A-2F02EDBCC5ED"><p><codeph>iEmbeddedStoreId</codeph> is a data member that holds the ID of the hosting stream</p> </li> <li id="GUID-8AE6849E-0BA8-5CB4-8F3F-B33CC4FEED4E"><p><codeph>iEmbeddedStore</codeph> holds a reference to the embedded store object.</p> </li> </ul> <p>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.</p> </conbody></concept>
\ No newline at end of file