lowlevellibsandfws/apputils/inc/BaRsReadImpl.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2003-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 #ifndef __BARSREADIMPL_H__
       
    17 #define __BARSREADIMPL_H__
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <badesca.h>
       
    21 #include "BaAssert.h"
       
    22 
       
    23 /** Interprets resource data read from a resource file.
       
    24 
       
    25 To use an instance of this class, pass the buffer containing the resource 
       
    26 data to it by calling SetBuffer().
       
    27 
       
    28 The buffer containing the resource data is created by RResourceFile::AllocReadLC()/CResourceFile::AllocReadLC() 
       
    29 or RResourceFile::AllocReadL()/CResourceFile::AllocReadL() which reads the specified resource into it.
       
    30 
       
    31 The current position within the buffer is always maintained and any request 
       
    32 for data is always supplied from the current position. The current position 
       
    33 is always updated .
       
    34 
       
    35 Expected behaviour when assignment operator or copy constructor is called:
       
    36 The class doesn't have assignment operator and copy constructor, so the compiler generated
       
    37 ones will be used. The buffer used by the source class instance will be shared with the 
       
    38 destination class instance. However source and destination instances will have their own 
       
    39 current position pointers, both pointed initially to the same buffer position.
       
    40 
       
    41 Methods panic/leave behaviour: "L" methods panics/leave behaviour depends on iAssertObj
       
    42 member which could be initialized calling SetAssertObj. If iAssertObj internal state is 
       
    43 TBaAssert::EPanic - "L" methods will panic, otherwise they will leave if something goes wrong.
       
    44 By default "L" methods will panic.
       
    45 
       
    46 @internalComponent
       
    47 @see TResourceReaderImpl::SetBuffer()
       
    48 @see RResourceFile::AllocReadL()
       
    49 @see RResourceFile::AllocReadLC()
       
    50 @see CResourceFile::AllocReadL()
       
    51 @see CResourceFile::AllocReadLC() */
       
    52 class TResourceReaderImpl
       
    53     {
       
    54 public:
       
    55 	TResourceReaderImpl();
       
    56 
       
    57     void SetBuffer(const TDesC8* aBuffer);
       
    58 	void ResetBuffer();
       
    59     const TAny* Ptr();
       
    60 
       
    61     // Read counted strings into allocated buffer
       
    62     HBufC8*  ReadHBufC8L();
       
    63     HBufC16* ReadHBufC16L();
       
    64 
       
    65     // Build pointer from a counted string
       
    66     TPtrC8  ReadTPtrC8L();
       
    67     TPtrC16 ReadTPtrC16L();
       
    68 
       
    69     // Build pointer from a counted string in an array of counted strings,
       
    70     // also setting the buffer to be used.
       
    71     TPtrC8 ReadTPtrC8L(TInt aIndex,const TDesC8* aBuffer);
       
    72     TPtrC16 ReadTPtrC16L(TInt aIndex,const TDesC8* aBuffer);
       
    73 
       
    74     // Build an array of strings from a resource array
       
    75     CDesC8ArrayFlat*  ReadDesC8ArrayL();
       
    76     CDesC16ArrayFlat* ReadDesC16ArrayL();
       
    77 
       
    78     TInt ReadInt8L();
       
    79     TUint ReadUint8L();
       
    80     TInt ReadInt16L();
       
    81     TUint ReadUint16L();
       
    82     TInt ReadInt32L();
       
    83     TUint ReadUint32L();
       
    84     TReal64 ReadReal64L() __SOFTFP;
       
    85 
       
    86     void ReadL(TAny* aPtr,TInt aLength);
       
    87     void RewindL(TInt aLength);
       
    88     void AdvanceL(TInt aLength);
       
    89 
       
    90 	void SetAssertObj(const TBaAssert& iAssertObj);
       
    91 private:
       
    92     void MovePtrL(const TUint8* aPtr);
       
    93 private:
       
    94     const TDesC8* iBuffer;
       
    95     const TUint8* iCurrentPtr;
       
    96     TBaAssert iAssertObj;
       
    97     };
       
    98 
       
    99 #endif//__BARSREADIMPL_H__