equal
deleted
inserted
replaced
|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept xml:lang="en" id="GUID-8A2029C7-1258-5B12-B217-DE3EE4340B72"><title>How to externalise and internalise</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>For a class TX defined as:</p> <codeblock id="GUID-8F730CDE-638B-5D07-B5A8-864DEE4BCB7E" xml:space="preserve">class TX |
|
13 { |
|
14 public: |
|
15 ... |
|
16 void ExternalizeL(RWriteStream& aStream) const; |
|
17 void InternalizeL(RReadStream& aStream); |
|
18 ... |
|
19 };</codeblock> <p>an instance of <codeph>TX</codeph> can be externalised to the stream <codeph>outstream</codeph>, by calling the <codeph>ExternalizeL()</codeph> member function of <codeph>TX</codeph>:</p> <codeblock id="GUID-81A69F24-8A0E-5473-89A4-899DD96DDD65" xml:space="preserve"> ... |
|
20 TX object; |
|
21 ... |
|
22 object.ExternalizeL(outstream); |
|
23 ...</codeblock> <p>An alternative, and better way, is to use the templated stream <codeph>operator<<</codeph>. The Store framework implements this by calling <codeph>TX::ExternalizeL()</codeph>. The syntax is simply:</p> <codeblock id="GUID-8ABF4FD0-9F1E-5AB9-8D88-6A9EC3700C19" xml:space="preserve"> ... |
|
24 outstream << object; // externalise object |
|
25 ...</codeblock> <p>Similarly, the <codeph>TX</codeph> object can be internalised from the stream <codeph>instream</codeph>, by calling the <codeph>InternalizeL()</codeph> member function of <codeph>TX</codeph>:</p> <codeblock id="GUID-6F2EE0E7-A9F2-5F87-AD16-AA6821C36313" xml:space="preserve"> TX object; |
|
26 ... |
|
27 object.InternalizeL(instream); |
|
28 ...</codeblock> <p>The templated stream <codeph>operator>></codeph> can also be used. The Store framework implements this by calling <codeph>TX::InternalizeL()</codeph>. The syntax is simply:</p> <codeblock id="GUID-A4B294A0-0311-5D38-805D-76CD6939D85E" xml:space="preserve">instream >> object; // internalise object</codeblock> </conbody></concept> |