Symbian3/SDK/Source/GUID-1F68D172-1090-5930-BD7B-AE7276667104.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-1F68D172-1090-5930-BD7B-AE7276667104"><title>How to create streams</title><prolog><metadata><keywords/></metadata></prolog><conbody><section><title>Write streams</title> <p>The following code fragment shows how a write stream is created. A write stream is represented by an instance of the <codeph>RStoreWriteStream</codeph> class and an object of this type can be created on the program stack.</p> <p>Use the <codeph>CreateL()</codeph> or <codeph>CreateLC()</codeph> member function of <codeph>RStoreWriteStream</codeph> to create a new stream in a store and return its stream ID.</p> <codeblock id="GUID-959ABC13-9EFE-5CD5-834E-DE744E1D506B" xml:space="preserve">...
RStoreWriteStream outstream;
TStreamId id = outstream.CreateLC(*store);
...
CleanupStack::PopAndDestroy();
...</codeblock> <p><codeph>store</codeph> is a pointer to an already opened stream store.</p> <p>Some stores allow their existing streams to be modified, for example, by overwriting or appending. To open an existing stream for overwriting, use <codeph>OpenL()</codeph> or <codeph>OpenLC()</codeph> and identify both the store and the stream:</p> <codeblock id="GUID-3815630B-ADCE-5251-8283-CF4488C9E2BF" xml:space="preserve">...
RStoreWriteStream outstream;
TStreamId id;
...
outstream.CreateLC(*store,id);
...
CleanupStack::PopAndDestroy();
...</codeblock> <p>In this code fragment, the id of the stream must be known before calling <codeph>CreateLC()</codeph>.</p> <p>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 <i>fail</i>. A direct file store is an example of a store which does <i>not</i> support the modification of existing streams. </p> </section> <section><title>Read streams</title> <p>The following code fragment shows how a read stream is created. A read stream is represented by an instance of the <codeph>RStoreReadStream</codeph> class and an object of this type can be created on the program stack.</p> <p>Use the <codeph>OpenL()</codeph> or <codeph>OpenLC()</codeph> member function of <codeph>RStoreReadStream</codeph> to open a stream for reading.</p> <codeblock id="GUID-DD8E19E5-0478-53D1-B370-9DA0E838B84F" xml:space="preserve">RStoreReadStream instream;
TStream id;
...
instream.OpenLC(*store,id);
...</codeblock> <p><codeph>store</codeph> is a pointer to an already opened stream store.</p> <p><codeph>id</codeph> identifies the stream to be opened.</p> </section> </conbody></concept>