TResourceReader Class Reference

#include <barsread.h>

class TResourceReader
Public Member Functions
IMPORT_C voidAdvance(TInt)
IMPORT_C const TAny *Ptr()
IMPORT_C voidRead(TAny *, TInt)
IMPORT_C CDesC16ArrayFlat *ReadDesC16ArrayL()
IMPORT_C CDesC8ArrayFlat *ReadDesC8ArrayL()
CDesCArrayFlat *ReadDesCArrayL()
IMPORT_C HBufC16 *ReadHBufC16L()
IMPORT_C HBufC8 *ReadHBufC8L()
HBufC *ReadHBufCL()
IMPORT_C TIntReadInt16()
IMPORT_C TIntReadInt32()
IMPORT_C TIntReadInt8()
IMPORT_C TReal64ReadReal64()
TPtrC ReadTPtrC()
TPtrC ReadTPtrC(TInt, const TDesC8 *)
IMPORT_C TPtrC16ReadTPtrC16()
IMPORT_C TPtrC16ReadTPtrC16(TInt, const TDesC8 *)
IMPORT_C TPtrC8ReadTPtrC8()
IMPORT_C TPtrC8ReadTPtrC8(TInt, const TDesC8 *)
IMPORT_C TUintReadUint16()
IMPORT_C TUintReadUint32()
IMPORT_C TUintReadUint8()
IMPORT_C voidRewind(TInt)
IMPORT_C voidSetBuffer(const TDesC8 *)

Detailed Description

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() or RResourceFile::AllocReadL() 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 .

See also: TResourceReader::SetBuffer() RResourceFile::AllocReadL() RResourceFile::AllocReadLC()

Member Function Documentation

Advance ( TInt )

IMPORT_C voidAdvance(TIntaLength)

Moves the current buffer position forwards by the specified amount.

If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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

Ptr ( )

IMPORT_C 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.

Return Value
A pointer to the current position within the resource buffer.

Read ( TAny *, TInt )

IMPORT_C voidRead(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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

Parameters
aPtrA pointer to the target location for data copied from the resource buffer.
aLengthThe length of data to be copied from the resource buffer.

ReadDesC16ArrayL ( )

IMPORT_C 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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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().

Return Value
A pointer to a 16-bit variant flat descriptor array.

ReadDesC8ArrayL ( )

IMPORT_C 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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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().

Return Value
A pointer to an 8-bit variant flat descriptor array.

ReadDesCArrayL ( )

CDesCArrayFlat *ReadDesCArrayL()[inline]

Interprets the data at the current buffer position as an array of leading byte count data and constructs a build independent flat array of 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 text characters or the length of binary data

followed by:

the text characters or binary data. This resource data is interpreted as either 8-bit or 16-bit, depending on the build.

The current position within the resource buffer is updated. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

Use this build independent variant when the elements contain text. If the elements contain binary data, use the explicit 8-bit variant ReadDesC8ArrayL().

Return Value
A pointer to a build independent flat descriptor array.

ReadHBufC16L ( )

IMPORT_C 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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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().

Return Value
A pointer to the 16-bit heap descriptor containing a copy of the data following the leading byte count at the current position within the resource buffer. The pointer can be NULL.

ReadHBufC8L ( )

IMPORT_C 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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
A pointer to the 8-bit heap descriptor containing a copy of the data following the leading byte count at the current position within the resource buffer. The pointer can be NULL.

ReadHBufCL ( )

HBufC *ReadHBufCL()[inline]

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

The data is interpreted as:

a byte value defining the number of text characters or the length of binary data

followed by:

the text characters or binary data. This resource data is interpreted as either 8-bit or 16-bit, depending on the build.

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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

Return Value
A pointer to the heap descriptor containing a copy of the data following the leading byte count at the current position within the resource buffer. The pointer can be NULL.

ReadInt16 ( )

IMPORT_C TIntReadInt16()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
The TInt16 value taken from the resource buffer.

ReadInt32 ( )

IMPORT_C TIntReadInt32()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
The TInt32 value taken from the resource buffer.

ReadInt8 ( )

IMPORT_C TIntReadInt8()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
The TInt8 value taken from the resource buffer.

ReadReal64 ( )

IMPORT_C TReal64ReadReal64()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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

Return Value
The TReal64 value taken from the resource buffer.

ReadTPtrC ( )

TPtrC ReadTPtrC()[inline]

Interprets the data at the current buffer position as leading byte count data and constructs a 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

followed by:

the text characters or binary data. This resource data is interpreted as either 8-bit or 16-bit, depending on the build.

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

The current position within the resource buffer is updated. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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

Return Value
A non modifiable pointer descriptor representing the data following the leading byte count at the current position within the resource buffer.

ReadTPtrC ( TInt, const TDesC8 * )

TPtrC ReadTPtrC(TIntaIndex,
const TDesC8 *aBuffer
)[inline]

Interprets the data within the specified resource buffer as an array of leading byte count data and constructs a 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 text characters or the length of binary data

followed by:

the text characters or binary data. This resource data is interpreted as either 8-bit or 16-bit, depending on the build.

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

The current position within the resource buffer is updated. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

Use this build independent variant when the elements contain text. If the elements contain binary data, use the explicit 8-bit variant ReadTPtrC8(TInt,constTDesC8*).

Parameters
aIndexThe position of the element within the array. This value is relative to zero.
aBufferThe buffer containing the resource data.
Return Value
A non modifiable pointer descriptor representing the data following the leading byte count of the element at the specified position within the array.

ReadTPtrC16 ( )

IMPORT_C TPtrC16ReadTPtrC16()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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().

Return Value
A 16-bit non modifiable pointer descriptor representing the data following the leading byte count at the current position within the resource buffer.

ReadTPtrC16 ( TInt, const TDesC8 * )

IMPORT_C TPtrC16ReadTPtrC16(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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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,constTDesC8*).

Parameters
aIndexThe position of the element within the array. This value is relative to zero.
aBufferThe buffer containing the resource data.
Return Value
A 16-bit non modifiable pointer descriptor representing the data following the leading byte count of the element at position within the array

ReadTPtrC8 ( )

IMPORT_C TPtrC8ReadTPtrC8()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
An 8-bit non modifiable pointer descriptor representing the data following the leading byte count at the current position within the resource buffer.

ReadTPtrC8 ( TInt, const TDesC8 * )

IMPORT_C TPtrC8ReadTPtrC8(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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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,constTDesC8*).

Parameters
aIndexThe position of the element within the array. This value is relative to zero.
aBufferThe buffer containing the resource data.
Return Value
An 8-bit non modifiable pointer descriptor representing the data following the leading byte count of the element at the specified position within the array.

ReadUint16 ( )

IMPORT_C TUintReadUint16()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
The TUint16 value taken from the resource buffer.

ReadUint32 ( )

IMPORT_C TUintReadUint32()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
The TUint32 value taken from the resource buffer.

ReadUint8 ( )

IMPORT_C TUintReadUint8()

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. If the resulting position lies beyond the end of the resource buffer, then the function raises a BAFL 4 panic.

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.

Return Value
The TUint8 value taken from the resource buffer.

Rewind ( TInt )

IMPORT_C voidRewind(TIntaLength)

Moves the current buffer position backwards by the specified amount.

If the resulting position lies before the start of the resource buffer, then the function raises a BAFL 5 panic.

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

SetBuffer ( const TDesC8 * )

IMPORT_C 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.

Parameters
aBufferA pointer to an 8-bit non-modifiable descriptor containing or representing resource data.