|
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 id="GUID-EB6A14CF-05DA-5EAD-AB68-F6511907DF05" xml:lang="en"><title>Use |
|
13 of the Externalize class</title><shortdesc>Describes how to use the Externalize class.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>The implementation of the family of operators <xref href="GUID-50F3A8F9-DA0A-3377-A75C-282F1E920E2D.dita"><apiname>operator<<()</apiname></xref> calls |
|
15 the internal Symbian platform function <codeph>DoExternalizeL()</codeph>. |
|
16 There are two variants of this function distinguished by the value of the |
|
17 third parameter as either <xref href="GUID-43ED0606-199C-3C1A-B7E1-5EDB1DED469B.dita#GUID-43ED0606-199C-3C1A-B7E1-5EDB1DED469B/GUID-9D890F4B-3F84-3261-8C4C-275031651229"><apiname>Externalize::Member</apiname></xref> or <xref href="GUID-43ED0606-199C-3C1A-B7E1-5EDB1DED469B.dita#GUID-43ED0606-199C-3C1A-B7E1-5EDB1DED469B/GUID-886A0861-06AA-3346-B458-C97F332DDD21"><apiname>Externalize::Function</apiname></xref>.</p> |
|
18 <p>The family of operators <xref href="GUID-50F3A8F9-DA0A-3377-A75C-282F1E920E2D.dita"><apiname>operator<<()</apiname></xref> are implemented |
|
19 as follows:</p> |
|
20 <codeblock id="GUID-472120FA-4058-5316-96D4-9A594D39A359" xml:space="preserve">template <class T> |
|
21 inline RWriteStream& operator<<(RWriteStream& aStream,const T& anObject) |
|
22 { |
|
23 DoExternalizeL(anObject,aStream,Externalization(&anObject)); |
|
24 return aStream; |
|
25 }</codeblock> |
|
26 <p>The two variants of <codeph>DoExternalizeL()</codeph> are defined and implemented |
|
27 as:</p> |
|
28 <codeblock id="GUID-7FE54FB6-BDE8-5BD2-85BD-802BFB7430A8" xml:space="preserve">template <class T> |
|
29 inline void DoExternalizeL(const T& anObject,RWriteStream& aStream,Externalize::Member) |
|
30 {anObject.ExternalizeL(aStream);}</codeblock> |
|
31 <codeblock id="GUID-FDD7942E-EBAD-5AF0-A731-FF210B44E91B" xml:space="preserve">template <class T> |
|
32 inline void DoExternalizeL(const T& anObject,RWriteStream& aStream,Externalize::Function) |
|
33 {ExternalizeL(anObject,aStream);}</codeblock> |
|
34 <p>The variant called depends on the value returned from a call to the internal |
|
35 selector function, <codeph>Externalization()</codeph>. This selector function |
|
36 returns either <codeph>Externalize::Function</codeph> or <codeph>Externalize::Member</codeph>, |
|
37 depending on the type of <codeph>anObject</codeph>.</p> |
|
38 <p>The internal selector function <codeph>Externalization()</codeph> is a |
|
39 convenience mechanism that allows the <xref href="GUID-50F3A8F9-DA0A-3377-A75C-282F1E920E2D.dita"><apiname>operator<<()</apiname></xref> to |
|
40 call either the <codeph>ExternalizeL()</codeph> member function of a templated |
|
41 class or an <codeph>ExternalizeL()</codeph> templated global function.</p> |
|
42 <p>The store framework defines and implements a default selector function, |
|
43 prototyped as:</p> |
|
44 <codeblock id="GUID-E233C9ED-7ABC-554C-BB83-D6A00F4BE485" xml:space="preserve">Externalize::Member Externalization(const TAny*)</codeblock> |
|
45 <p>By default, a call to <codeph>Externalization()</codeph> passing a parameter |
|
46 of general class type, is resolved at compile time into a call to this variant, |
|
47 and the return type is <xref href="GUID-43ED0606-199C-3C1A-B7E1-5EDB1DED469B.dita#GUID-43ED0606-199C-3C1A-B7E1-5EDB1DED469B/GUID-9D890F4B-3F84-3261-8C4C-275031651229"><apiname>Externalize::Member</apiname></xref>. The store framework |
|
48 also defines and implements a number of other variants that take more specific |
|
49 argument types; for example, as part of its implementation of <xref href="GUID-50F3A8F9-DA0A-3377-A75C-282F1E920E2D.dita"><apiname>operator<<()</apiname></xref> for |
|
50 descriptors, the framework defines and implements:</p> |
|
51 <codeblock id="GUID-BE0D631B-7CC6-5D9D-A49C-A18B209295C6" xml:space="preserve">Externalize::Function Externalization(const TDesC8*)</codeblock> |
|
52 </conbody></concept> |