TResourceReaderImpl Class Reference

class TResourceReaderImpl

Interprets resource data read from a resource file.

To use an instance of this class, pass the buffer containing the resource data to it by calling SetBuffer().

The buffer containing the resource data is created by RResourceFile::AllocReadLC()/CResourceFileAllocReadLC() or RResourceFile::AllocReadL()/CResourceFileAllocReadL() which reads the specified resource into it.

The current position within the buffer is always maintained and any request for data is always supplied from the current position. The current position is always updated .

Expected behaviour when assignment operator or copy constructor is called: The class doesn't have assignment operator and copy constructor, so the compiler generated ones will be used. The buffer used by the source class instance will be shared with the destination class instance. However source and destination instances will have their own current position pointers, both pointed initially to the same buffer position.

Methods panic/leave behaviour: "L" methods panics/leave behaviour depends on iAssertObj member which could be initialized calling SetAssertObj. If iAssertObj internal state is TBaAssert::EPanic - "L" methods will panic, otherwise they will leave if something goes wrong. By default "L" methods will panic.

TResourceReaderImpl::SetBuffer() RResourceFile::AllocReadL() RResourceFile::AllocReadLC() CResourceFile::AllocReadL() CResourceFile::AllocReadLC()

Constructor & Destructor Documentation

TResourceReaderImpl()

TResourceReaderImpl()

An error will be issued at compile time if the class size is not KRsReaderImplSize.

Member Functions Documentation

AdvanceL(TInt)

voidAdvanceL(TIntaLength)

Moves the current buffer position forwards by the specified amount.

Pre-condition
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 82 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

Parameters

TInt aLengthThe length by which the current position is to be advanced.

MovePtrL(const TUint8 *)

voidMovePtrL(const TUint8 *aPtr)[private]

Updates iCurrentPtr with a new value.

Pre-condition
iBuffer is not NULL.
aPtr is not NULL.
Post-condition
iCurrentPtr is updated.
panic
BAFL 4 The new iCurrentPtr points beyond the buffer end.
panic
BAFL 70 iBuffer is NULL. DEBUG build only.
panic
BAFL 71 aPtr is NULL. DEBUG build only.
leave
KErrOff The new iCurrentPtr points beyond the buffer end.

Parameters

const TUint8 * aPtrThe new value of iCurrentPtr.

Ptr()

const TAny *Ptr()

Returns the current position within the resource buffer.

The function makes no assumption about the type of data in the buffer at the current position.

ReadDesC16ArrayL()

CDesC16ArrayFlat *ReadDesC16ArrayL()

Interprets the data at the current buffer position as an array of leading byte count data and constructs a flat array of 16 bit descriptors.

Each descriptor in the descriptor array corresponds to an element of the resource array.

At the current buffer position, the buffer is expected to contain an array of data elements preceded by a TInt16 value defining the number of elements within that array.

Each element of the array is interpreted as:

a byte value defining the number of 8 bit text characters or the length of binary data (the resource string/binary data length is limited to 255 characters max)

followed by:

the 16 bit text characters.

The current position within the resource buffer is updated.

Do not use this explicit 16 bit variant when the resource contains binary data; use the explicit 8 bit variant instead. If the resource contains text, use the build independent variant ReadDesCArrayL().

Pre-condition
The same as ReadTPtrC16L().
Post-condition
The same as ReadTPtrC16L().
panic
The same as ReadTPtrC16L().
leave
The same as ReadTPtrC16L().
leave
KErrNoMemory There is not enough memory for the resulting buffer.
ReadTPtrC16L()

ReadDesC8ArrayL()

CDesC8ArrayFlat *ReadDesC8ArrayL()

Interprets the data at the current buffer position as an array of leading byte count data and constructs a flat array of 8 bit descriptors.

Each descriptor in the descriptor array corresponds to an element of the resource array.

At the current buffer position, the buffer is expected to contain an array of data elements preceded by a TInt16 value defining the number of elements within that array.

Each element of the array is interpreted as:

a byte value defining the number of 8 bit text characters or the length of binary data (the resource string/binary data length is limited to 255 characters max)

followed by:

the text characters or binary data.

The current position within the resource buffer is updated.

Use this explicit 8 bit variant when the resource contains binary data. If the elements of the resource array contain text, use the build independent variant of ReadDesCArrayL().

Pre-condition
The same as ReadTPtrC8L().
Post-condition
The same as ReadTPtrC8L().
panic
The same as ReadTPtrC8L().
leave
The same as ReadTPtrC8L().
leave
KErrNoMemory There is not enough memory for the resulting buffer.
ReadTPtrC8L()

ReadHBufC16L()

HBufC16 *ReadHBufC16L()

Interprets the data at the current buffer position as leading byte count data and constructs a 16 bit heap descriptor containing a copy of this data.

The data is interpreted as:

a byte value defining the number of 16 bit text characters (the resource string/binary data length is limited to 255 characters max)

followed by:

the 16 bit text characters.

If the value of the leading byte is zero, the function assumes that no data follows the leading byte and returns a NULL pointer.

The current position within the resource buffer is updated.

Do not use this explicit 16 bit variant when the resource contains binary data; use the explicit 8 bit variant instead. If the resource contains text, use the build independent variant ReadHBufCL().

Pre-condition
The same as for ReadTPtrC16L().
Post-condition
iCurrentPtr is updated.
panic
The same as ReadTPtrC16L().
leave
The same as ReadTPtrC16L().
ReadTPtrC16L()

ReadHBufC8L()

HBufC8 *ReadHBufC8L()

Interprets the data at the current buffer position as leading byte count data and constructs an 8 bit heap descriptor containing a copy of this data.

The data is interpreted as:

a byte value defining the number of 8 bit text characters or the length of binary data (the resource string/binary data length is limited to 255 characters max)

followed by:

the 8 bit text characters or binary data.

If the value of the leading byte is zero, the function assumes that no data follows the leading byte and returns a NULL pointer.

The current position within the resource buffer is updated.

Use this explicit 8 bit variant when the resource contains binary data. If the resource contains text, then use the build independent variant ReadHBufCL().

In general, this type of resource data corresponds to one of the following:

a LTEXT type in a resource STRUCT declaration.

a variable length array within a STRUCT declaration which includes the LEN BYTE keywords.

Pre-condition
The same as for ReadTPtrC8L().
Post-condition
iCurrentPtr is updated.
panic
The same as ReadTPtrC8L().
leave
The same as ReadTPtrC8L().
ReadTPtrC8L()

ReadInt16L()

TInt ReadInt16L()

Interprets the data at the current buffer position as a TInt16 type and returns the value as a TInt.

The current position within the resource buffer is updated.

In general, a TInt16 corresponds to a WORD type in a resource STRUCT declaration.

Note that in Symbian OS, a TInt is at least as big as a TInt16.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 76 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

ReadInt32L()

TInt ReadInt32L()

Interprets the data at the current buffer position as a TInt32 type and returns the value as a TInt.

The current position within the resource buffer is updated.

In general, a TInt32 corresponds to a LONG type in a resource STRUCT declaration.

Note that in Symbian OS, TInt and TInt32 are the same size.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 78 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

ReadInt8L()

TInt ReadInt8L()

Interprets the data at the current buffer position as a TInt8 type and returns the value as a TInt.

The current position within the resource buffer is updated.

In general, a TInt8 corresponds to a BYTE type in a resource STRUCT declaration.

Note that in Symbian OS, a TInt is at least as big as a TInt8.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 74 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

ReadL(TAny *, TInt)

voidReadL(TAny *aPtr,
TIntaLength
)

Copies a specified length of data from the resource buffer, starting at the current position within the buffer, into the location pointed to by a specified pointer. No assumption is made about the type of data at being read.

The current position within the resource buffer is updated.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 80 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

Parameters

TAny * aPtrPointer to the target location for data copied from the resource buffer.
TInt aLengthThe length of data to be copied from the resource buffer.

ReadReal64L()

TReal64 ReadReal64L()

Interprets the data at the current buffer position as a TReal64 type and returns the value as a TReal64.

The current position within the resource buffer is updated.

In general, a TReal64 corresponds to a DOUBLE type in a resource STRUCT declaration.

Pre-condition
The same as ReadUint32L().
Post-condition
The same as ReadUint32L().
leave
The same as ReadUint32L().
panic
The same as ReadUint32L().
ReadUint32L()

ReadTPtrC16L()

TPtrC16 ReadTPtrC16L()

Interprets the data at the current buffer position as leading byte count data and constructs a 16 bit non modifiable pointer descriptor to represent this data.

The data is interpreted as:

a byte value defining the number of 16 bit text characters (the resource string/binary data length is limited to 255 characters max)

followed by:

the 16 bit text characters.

If the value of the leading byte is zero, calling Length() on the returned TPtrC16 returns zero.

The current position within the resource buffer is updated.

Do not use this explicit 16 bit variant when the resource contains binary data; use the explicit 8 bit variant instead. If the resource contains text, use the build independent variant ReadTPtrC().

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
iCurrentPtr is updated.
panic
BAFL 73 iCurrentPtr is NULL. DEBUG build only.
panic
BAFL 15 The resource is a unicode string and it is not properly aligned. DEBUG build only.
panic
The same as MovePtrL(const TUint8* aPtr).
leave
KErrCorrupt The resource is a unicode string and it is not properly aligned.
leave
The same as MovePtrL(const TUint8* aPtr).
MovePtrL(const TUint8* aPtr)

ReadTPtrC16L(TInt, const TDesC8 *)

TPtrC16 ReadTPtrC16L(TIntaIndex,
const TDesC8 *aBuffer
)

Interprets the data within the specified resource buffer as an array of leading byte count data and constructs a 16 bit non modifiable pointer descriptor to represent an element within this array.

The function sets the buffer containing the resource data and sets the current position to the start of this buffer. Any buffer set by a previous call to SetBuffer() etc., is lost.

The buffer is expected to contain an array of data elements preceded by a TInt16 value defining the number of elements within that array.

Each element of the array is interpreted as:

a byte value defining the number of 8 bit text characters or the length of binary data (the resource string/binary data length is limited to 255 characters max)

followed by:

the 16 bit text characters.

If the value of the leading byte is zero, calling Length() on the returned TPtrC16 returns zero.

The current position within the resource buffer is updated.

Do not use this explicit 16 bit variant when the resource contains binary data; use the explicit 8 bit variant instead. If the resource contains text, use the build independent variant ReadTPtrC(TInt,const TDesC8*).

Pre-condition
aBuffer != NULL.
The same as ReadTPtrC16L().
Post-condition
iBuffer is initialized with aBuffer.
The same as ReadTPtrC16L().
panic
BAFL 4 aIndex is greater or equal than the string length.
panic
The same as ReadTPtrC16L().
leave
KErrOff aIndex is grater or equal than the string length.
leave
The same as ReadTPtrC16L().
ReadTPtrC16L()

Parameters

TInt aIndexThe position of the element within the array. This value is relative to zero.
const TDesC8 * aBufferThe buffer containing the resource data.

ReadTPtrC8L()

TPtrC8 ReadTPtrC8L()

Interprets the data at the current buffer position as leading byte count data and constructs an 8 bit non modifiable pointer descriptor to represent this data.

The data is interpreted as:

a byte value defining the number of text characters or the length of binary data (the resource string/binary data length is limited to 255 characters max)

followed by:

the 8 bit text characters or binary data.

If the value of the leading byte is zero, calling Length() on the returned TPtrC8 returns zero.

The current position within the resource buffer is updated.

Use this explicit 8 bit variant when the resource contains binary data. If the resource contains text, then use the build independent variant ReadTPtrC().

In general, this type of resource data corresponds to one of the following:

a LTEXT type in a resource STRUCT declaration.

a variable length array within a STRUCT declaration which includes the LEN BYTE keywords.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
iCurrentPtr is updated.
panic
BAFL 72 iCurrentPtr is NULL. DEBUG build only.
panic
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
MovePtrL(const TUint8* aPtr)

ReadTPtrC8L(TInt, const TDesC8 *)

TPtrC8 ReadTPtrC8L(TIntaIndex,
const TDesC8 *aBuffer
)

Interprets the data within the specified resource buffer as an array of leading byte count data and constructs an 8 bit non modifiable pointer descriptor to represent an element within this array.

The function sets the buffer containing the resource data and sets the current position to the start of this buffer. Any buffer set by a previous call to SetBuffer() etc, is lost.

The buffer is expected to contain an array of data elements preceded by a TInt16 value defining the number of elements within that array.

Each element of the array is interpreted as:

a byte value defining the number of 8 bit text characters or the length of binary data (the resource string/binary data length is limited to 255 characters max)

followed by:

the 8 bit text characters or binary data.

If the value of the leading byte is zero, calling Length() on the returned TPtrC8 returns zero.

The current position within the resource buffer is updated.

Use this explicit 8 bit variant when the resource contains binary data, If the resource contains text, then use the build independent variant ReadTPtrC(TInt,const TDesC8*).

Pre-condition
aBuffer != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
iBuffer is initialized with aBuffer.
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 4 aIndex is greater or equal than the string length. DEBUG build only.
panic
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
MovePtrL(const TUint8* aPtr)

Parameters

TInt aIndexPosition of the element within the array. This value is relative to zero.
const TDesC8 * aBufferBuffer containing the resource data.

ReadUint16L()

TUint ReadUint16L()

Interprets the data at the current buffer position as a TUint16 type and returns the value as a TUint.

The current position within the resource buffer is updated.

In general, a TUint16 corresponds to a WORD type in a resource STRUCT declaration.

Note that in Symbian OS, a TUint is at least as big as a TUint16.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 77 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

ReadUint32L()

TUint ReadUint32L()

Interprets the data at the current buffer position as a TUint32 type and returns the value as a TUint.

The current position within the resource buffer is updated.

In general, a TUint32 corresponds to a LONG type in a resource STRUCT declaration.

Note that in Symbian OS a TUint is the same size as a TUint32.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 79 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

ReadUint8L()

TUint ReadUint8L()

Interprets the data at the current buffer position as a TUint8 type and returns the value as a TUint.

The current position within the resource buffer is updated.

In general, a TUint8 corresponds to a BYTE type in a resource STRUCT declaration.

Note that in Symbian OS, a TUint is at least as big as a TUint8.

Pre-condition
iCurrentPtr != NULL.
The same as MovePtrL(const TUint8* aPtr).
Post-condition
The same as MovePtrL(const TUint8* aPtr).
leave
The same as MovePtrL(const TUint8* aPtr).
panic
The same as MovePtrL(const TUint8* aPtr).
panic
BAFL 75 iCurrentPtr is NULL. DEBUG build only.
MovePtrL(const TUint8* aPtr)

ResetBuffer()

voidResetBuffer()
Sets the buffer and current position to NULL.
Post-condition
Buffer pointer is set to NULL.
Buffer current position pointer is set to NULL.

RewindL(TInt)

voidRewindL(TIntaLength)

Moves the current buffer position backwards by the specified amount.

Pre-condition
iCurrentPtr != NULL.
Post-condition
iCurrentPtr is updated.
leave
MovePtrL(const TUint8* aPtr).
panic
BAFL 5 If the resulting position lies before the start of the resource.
panic
BAFL 81 iCurrentPtr is NULL. DEBUG build only.
leave
KErrArgument The resulting position lies before the start of the resource.

Parameters

TInt aLengthThe length by which the current position is to be moved backward.

SetAssertObj(const TBaAssert &)

voidSetAssertObj(const TBaAssert &iAssertObj)

The method sets a new iAssertObj. If some method is called and something goes wrong - the method either will panics or asserts depending on iAssertObj state.

Post-condition
iAssertObj is updated.

Parameters

const TBaAssert & iAssertObjThe assert object.

SetBuffer(const TDesC8 *)

voidSetBuffer(const TDesC8 *aBuffer)

Sets the buffer containing the resource data.

The current position within the buffer is set to the start of the buffer so that subsequent calls to the interpreting functions, for example ReadInt8(), start at the beginning of this buffer.

Post-condition
Buffer pointer is initialized.
Buffer current position pointer is initialized.

Parameters

const TDesC8 * aBufferPointer to an 8 bit non-modifiable descriptor containing or representing resource data.

Member Data Documentation

TBaAssert iAssertObj

TBaAssert iAssertObj[private]

const TDesC8 * iBuffer

const TDesC8 *iBuffer[private]

const TUint8 * iCurrentPtr

const TUint8 *iCurrentPtr[private]