Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_multi_read_8h-source.html
week 10 bug fix submission: Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>TB10.1 Example Applications: examples/SysLibs/ResourceFiles/MultiRead1/MultiRead.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<h1>examples/SysLibs/ResourceFiles/MultiRead1/MultiRead.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
<a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
<a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
<a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
<a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// Description:</span>
<a name="l00014"></a>00014 <span class="comment">// define the multiple resource file reader class</span>
<a name="l00015"></a>00015 <span class="comment">// for use in MultiRead1 and MultiRead2 examples</span>
<a name="l00016"></a>00016 <span class="comment">//</span>
<a name="l00017"></a>00017
<a name="l00018"></a>00018 <span class="preprocessor">#ifndef __MultiRead_H</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define __MultiRead_H</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a><a class="code" href="class_c_multiple_resource_file_reader.html">00021</a> <span class="keyword">class </span><a class="code" href="class_c_multiple_resource_file_reader.html">CMultipleResourceFileReader</a> : <span class="keyword">public</span> CBase
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023 <span class="keyword">public</span>:
<a name="l00024"></a>00024 <span class="comment">// construct/destruct</span>
<a name="l00025"></a>00025 <a class="code" href="class_c_multiple_resource_file_reader.html#96c46cd39acd10d82d6b0d3eaf999e1c">~CMultipleResourceFileReader</a>();
<a name="l00026"></a>00026 <span class="keyword">static</span> <a class="code" href="class_c_multiple_resource_file_reader.html">CMultipleResourceFileReader</a>* <a class="code" href="class_c_multiple_resource_file_reader.html#fa23785ff10e912a79eb1ffdc46968b3">NewLC</a>();
<a name="l00027"></a>00027 <span class="comment">// add resource file</span>
<a name="l00028"></a>00028 <span class="keywordtype">void</span> <a class="code" href="class_c_multiple_resource_file_reader.html#2494a803866875a534e294bc48be2806">AddResourceFileL</a>(<span class="keyword">const</span> TDesC& aName, TInt aVersion);
<a name="l00029"></a>00029 HBufC8* <a class="code" href="class_c_multiple_resource_file_reader.html#2795f6d33164a5556e3014ff0300c773">AllocReadLC</a>(TInt aResourceId);
<a name="l00030"></a>00030 <span class="keyword">private</span>:
<a name="l00031"></a>00031 <span class="comment">// construct/destruct</span>
<a name="l00032"></a>00032 <span class="keywordtype">void</span> ConstructL();
<a name="l00033"></a>00033 <span class="keyword">private</span>:
<a name="l00034"></a>00034 CArrayFixFlat<RResourceFile>* iResourceFiles;
<a name="l00035"></a>00035 };
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="comment">// construct/destruct</span>
<a name="l00038"></a>00038
<a name="l00039"></a><a class="code" href="class_c_multiple_resource_file_reader.html#fa23785ff10e912a79eb1ffdc46968b3">00039</a> <a class="code" href="class_c_multiple_resource_file_reader.html">CMultipleResourceFileReader</a>* <a class="code" href="class_c_multiple_resource_file_reader.html#fa23785ff10e912a79eb1ffdc46968b3">CMultipleResourceFileReader::NewLC</a>()
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041 <a class="code" href="class_c_multiple_resource_file_reader.html">CMultipleResourceFileReader</a>* <span class="keyword">self</span>=<span class="keyword">new</span> (ELeave) <a class="code" href="class_c_multiple_resource_file_reader.html">CMultipleResourceFileReader</a>;
<a name="l00042"></a>00042 CleanupStack::PushL(<span class="keyword">self</span>);
<a name="l00043"></a>00043 <span class="keyword">self</span>->ConstructL();
<a name="l00044"></a>00044 <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="keywordtype">void</span> CMultipleResourceFileReader::ConstructL()
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049 iResourceFiles=<span class="keyword">new</span> (ELeave) CArrayFixFlat<RResourceFile> (2);
<a name="l00050"></a>00050 <span class="comment">// new array of resource files</span>
<a name="l00051"></a>00051 <span class="comment">// typically two in an application, so use granularity 2</span>
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053
<a name="l00054"></a><a class="code" href="class_c_multiple_resource_file_reader.html#96c46cd39acd10d82d6b0d3eaf999e1c">00054</a> <a class="code" href="class_c_multiple_resource_file_reader.html#96c46cd39acd10d82d6b0d3eaf999e1c">CMultipleResourceFileReader::~CMultipleResourceFileReader</a>()
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056 <span class="keywordflow">if</span> (iResourceFiles)
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 <span class="keywordflow">for</span> (TInt i=0; i < iResourceFiles->Count(); i++)
<a name="l00059"></a>00059 (*iResourceFiles)[i].Close(); <span class="comment">// close each resource file</span>
<a name="l00060"></a>00060 <span class="keyword">delete</span> iResourceFiles; <span class="comment">// and destroy container</span>
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">// manipulate resource files and resources</span>
<a name="l00065"></a>00065
<a name="l00066"></a><a class="code" href="class_c_multiple_resource_file_reader.html#2494a803866875a534e294bc48be2806">00066</a> <span class="keywordtype">void</span> <a class="code" href="class_c_multiple_resource_file_reader.html#2494a803866875a534e294bc48be2806">CMultipleResourceFileReader::AddResourceFileL</a>(<span class="keyword">const</span> TDesC& aName, TInt aVersion)
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068 _LIT(KAddingResourceFile,<span class="stringliteral">"Adding resource file %S, version %d: will be file %d\n"</span>);
<a name="l00069"></a>00069 <a class="code" href="dbllist_8cpp.html#d789d40251baeb2f60e118de4856583d">console</a>->Printf(KAddingResourceFile,
<a name="l00070"></a>00070 &aName, aVersion, iResourceFiles->Count()
<a name="l00071"></a>00071 );
<a name="l00072"></a>00072 RResourceFile file;
<a name="l00073"></a>00073 file.OpenL(fsSession,aName); <span class="comment">// open resource file</span>
<a name="l00074"></a>00074 TRAPD(<a class="code" href="_camera___app_ui_8cpp.html#711e7d3cb49b7e0de7880fed269134d3">error</a>,file.ConfirmSignatureL(aVersion)); <span class="comment">// confirm its signature</span>
<a name="l00075"></a>00075 <span class="keywordflow">if</span> (<a class="code" href="_camera___app_ui_8cpp.html#711e7d3cb49b7e0de7880fed269134d3">error</a>!=KErrNone)
<a name="l00076"></a>00076 {
<a name="l00077"></a>00077 file.Close();
<a name="l00078"></a>00078 User::Leave(<a class="code" href="_camera___app_ui_8cpp.html#711e7d3cb49b7e0de7880fed269134d3">error</a>);
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080 TRAP(<a class="code" href="_camera___app_ui_8cpp.html#711e7d3cb49b7e0de7880fed269134d3">error</a>,iResourceFiles->AppendL(file))
<a name="l00081"></a>00081 <span class="keywordflow">if</span> (<a class="code" href="_camera___app_ui_8cpp.html#711e7d3cb49b7e0de7880fed269134d3">error</a>!=KErrNone)
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083 file.Close();
<a name="l00084"></a>00084 User::Leave(<a class="code" href="_camera___app_ui_8cpp.html#711e7d3cb49b7e0de7880fed269134d3">error</a>);
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 <span class="keywordflow">return</span>;
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088
<a name="l00089"></a><a class="code" href="class_c_multiple_resource_file_reader.html#2795f6d33164a5556e3014ff0300c773">00089</a> HBufC8* <a class="code" href="class_c_multiple_resource_file_reader.html#2795f6d33164a5556e3014ff0300c773">CMultipleResourceFileReader::AllocReadLC</a>(TInt aResourceId)
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091 _LIT(KReadingResource,<span class="stringliteral">"Reading resource %08X\n"</span>);
<a name="l00092"></a>00092 _LIT(KOwnedByFile,<span class="stringliteral">" Owned by file %d\n"</span>);
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <a class="code" href="dbllist_8cpp.html#d789d40251baeb2f60e118de4856583d">console</a>->Printf(KReadingResource,aResourceId);
<a name="l00095"></a>00095 <span class="keywordflow">for</span> (TInt i=0; i < iResourceFiles->Count(); i++)
<a name="l00096"></a>00096 { <span class="comment">// scan all resource files to find owner</span>
<a name="l00097"></a>00097 RResourceFile& file=(*iResourceFiles)[i]; <span class="comment">// get resource file</span>
<a name="l00098"></a>00098 <span class="keywordflow">if</span> (!file.OwnsResourceId(aResourceId))
<a name="l00099"></a>00099 <span class="keywordflow">continue</span>; <span class="comment">// continue if not owner</span>
<a name="l00100"></a>00100 <a class="code" href="dbllist_8cpp.html#d789d40251baeb2f60e118de4856583d">console</a>->Printf(KOwnedByFile,i);
<a name="l00101"></a>00101 <span class="keywordflow">return</span> file.AllocReadLC(aResourceId);
<a name="l00102"></a>00102 <span class="comment">// return resource from owning file (if present)</span>
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 User::Leave(KErrNotFound);
<a name="l00105"></a>00105 <span class="keywordflow">return</span> 0; <span class="comment">// can never be executed, but keeps compiler happy</span>
<a name="l00106"></a>00106 }
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:33:00 2010 for TB10.1 Example Applications by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>