secureswitools/swisistools/source/rscparser/barsc2.h
branchRCL_3
changeset 65 7333d7932ef7
equal deleted inserted replaced
62:5cc91383ab1e 65:7333d7932ef7
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 /** 
       
    16 * @file barsc2.h
       
    17 *
       
    18 * @internalComponent
       
    19 * @released
       
    20 */
       
    21 #ifndef __BARSC2_H__
       
    22 #define __BARSC2_H__
       
    23 
       
    24 #include <string>
       
    25 #include "barscimpl.h"
       
    26 
       
    27 class RResourceFileImpl;
       
    28 
       
    29 /**
       
    30 This class accesses a resource file and reads the resource data into a buffer.
       
    31 Interpretation of the data is achieved using the RResourceReader class.
       
    32 */
       
    33 class CResourceFile 
       
    34 	{
       
    35 public:
       
    36 	/**
       
    37 	Initializes in place the implementation object and 
       
    38 	opens the resource file for reading.
       
    39 	@param aName Resource file name
       
    40 	@param aFileOffset Resource file offset
       
    41 	@param aFileSize Resource file size	
       
    42 	*/
       
    43 	CResourceFile(const std::string& aName, TUint32 aFileOffset, TInt aFileSize);
       
    44 	
       
    45 	/**
       
    46 	Cleanup the allocated memory
       
    47 	*/
       
    48 	~CResourceFile();
       
    49 	
       
    50 	/** 
       
    51 	Reads a resource into a heap and returns the correspoding pointer to it.
       
    52 	
       
    53 	Ownership of the allocated heap is passed to the caller who must destroy 
       
    54 	it when it is no longer needed.
       
    55 
       
    56 	The search for the resource uses the following algorithm:
       
    57 
       
    58 	@param aResourceId The numeric id of the resource to be read.
       
    59 	@return Pointer to the allocated heap memory containing the resource.
       
    60 	*/
       
    61 	Ptr8* AllocReadL(const TInt& aResourceId);
       
    62 
       
    63 	/** Initialises the offset value from the first resource.
       
    64 
       
    65 	The function assumes that the first resource in the file consists of
       
    66 	two 32-bit integers. The first integer contains the version number and
       
    67 	the second is a self-referencing link whose value is the offset for
       
    68 	the resources in the file, plus 1.This function must be called before
       
    69 	calling Offset(), AllocReadL(), AllocReadLC() or ReadL().
       
    70 
       
    71 	@param aSignature This argument value is not used by the function.
       
    72 	@leave The function leaves if this resource id is not in this
       
    73 	resource file or the file is corrupted. */
       
    74 	void ConfirmSignatureL();
       
    75 	
       
    76 	/** 
       
    77 	Tests whether the resource file owns the specified resource id.
       
    78 	@param aResourceId The resource id to test.
       
    79 	@return True, if the resource file owns the id, false otherwise.
       
    80 	*/
       
    81 	TBool OwnsResourceId(const TInt& aResourceId) const;
       
    82 
       
    83 	/** 
       
    84 	Reads Resource File Uid3.
       
    85 	@param  Void
       
    86 	@return Uid3 of Resource File.
       
    87 	*/
       
    88 
       
    89 	TUid ReadAppUidL();
       
    90 
       
    91 	/** 
       
    92 	Reads Resource File Uid2.
       
    93 	@param  Void
       
    94 	@return Uid2 of Resource File.
       
    95 	*/
       
    96 
       
    97 	TUid ReadFileUidL();
       
    98 	 
       
    99 private:
       
   100 	/**
       
   101 	prevent default copy constructor
       
   102 	*/
       
   103 	CResourceFile(const CResourceFile&);
       
   104 	/**
       
   105 	prevent default assignment operator
       
   106 	*/
       
   107 	CResourceFile& operator=(const CResourceFile&);
       
   108 	/** 
       
   109 	@return Non-const pointer to the implementation. 
       
   110 	*/
       
   111 	RResourceFileImpl* Impl();
       
   112 	/** 
       
   113 	@return Const pointer to the implementation. 
       
   114 	*/
       
   115 	const RResourceFileImpl* Impl() const;
       
   116 
       
   117 private:
       
   118 	enum
       
   119 		{
       
   120 		KRscFileSize = 24,
       
   121 		};
       
   122 	TUint8 iImpl[KRscFileSize];
       
   123 	};
       
   124 
       
   125 
       
   126 /**
       
   127 This class implements the exception handling mechanism
       
   128 required for resource file parsing.
       
   129 */
       
   130 class CResourceFileException
       
   131 {
       
   132 public:
       
   133 
       
   134 	/**
       
   135 	Initializes the CResourceFileException class with the required
       
   136 	exception message.
       
   137 	@param aValue Exception message that is to be displayed.
       
   138 	*/
       
   139 	inline CResourceFileException(const std::string& aValue)
       
   140 							   :iValue(aValue)
       
   141 		{
       
   142 		}
       
   143 
       
   144 	/**
       
   145 	Displays the exception message
       
   146 	*/
       
   147 	void Display() const;
       
   148 
       
   149 	/**
       
   150 	Get the exception message
       
   151 	*/
       
   152 	std::string GetMsg();
       
   153 
       
   154 private:
       
   155 	std::string iValue;
       
   156 };
       
   157 
       
   158 #endif//__BARSC2_H__