Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: e32std.h
Link against: euser.lib

Class Mem

Mem

Support

Supported from 5.0

Description

Contains a set of static functions which perform manipulation of data in memory.

The arguments passed to the functions of this class are pointers to memory locations and length values. These functions are, therefore, not normally used in open code but are suitable for implementing data manipulation for other classes. Typically the interface provided by such classes is typesafe and hides this direct memory to memory manipulation.

Defined in Mem:
CollationMethodById(), CollationMethodByIndex(), CollationMethodId(), CollationMethods(), CollationRuleSetById(), CollationRuleSetByIndex(), CollationRuleSetId(), CollationRuleSets(), Compare(), CompareC(), CompareF(), Copy(), Crc(), Fill(), FillZ(), Move(), Swap()


Copying, moving and swapping data


Copy()

static TUint8* Copy(TAny* aTrg,const TAny* aSrc,TInt aLength);

Description

Copies data from a source location to a target location and returns a pointer to the end of the copied data. The source and target areas can overlap.

The copy operation is optimised so that if both source and target locations are aligned on a word boundary, the operation performs the copy on a word by word basis.

Parameters

TAny* aTrg

A pointer to the target location for the copy operation.

const TAny* aSrc

A pointer to the source location for the copy operation.

TInt aLength

The number of bytes to be copied. This value must not be negative. In debug builds only, a negative value causes the function to raise a USER 90 panic.

Return value

TUint8*

A pointer to a location aLength bytes beyond aTrg (i.e. the location aTrg+aLength).


Move()

static TUint8* Move(TAny* aTrg,const TAny* aSrc,TInt aLength);

Description

Moves a block of data from a source location to a target location and returns a pointer to the end of the moved data. The source and target areas can overlap.

Both source and target locations must be aligned on a word boundary. The specified length must also be a multiple of 4.

Parameters

TAny* aTrg

A pointer to the target location for the move operation. This pointer must be word aligned. In debug builds only, the function raises a USER 93 panic if the pointer is not word aligned.

const TAny* aSrc

A pointer to the source location for the move operation. This pointer must be word aligned. In debug builds only, the function raises a USER 92 panic if the pointer is not word aligned.

TInt aLength

The number of bytes to be copied. This value must be a multiple of 4. In debug builds only, the function raises a USER 91 panic if this value is not a multiple of 4.

Return value

TUint8*

A pointer to a location aLength bytes beyond aTrg (i.e. the location aTrg+aLength).


Swap()

static void Swap(TAny* aPtr1,TAny* aPtr2,TInt aLength);

Description

Swaps a number of bytes of data between two specified locations. The source and target areas can overlap.

Parameters

TAny* aPtr1

A pointer to the first location taking part in the swap.

TAny* aPtr2

A pointer to second location taking part in the swap.

TInt aLength

The number of bytes to be swapped between the two locations. This value must not be negative. In debug builds only, the function raises a USER 94 panic if this value is negative.

[Top]


Filling memory


Fill()

static void Fill(TAny* aTrg,TInt aLength,TChar aChar);

Description

Fills a specified block of data with a specified character, replacing any existing content. The function assumes that the fill character is a non-Unicode character.

Parameters

TAny* aTrg

A pointer to the location where filling is to start.

TInt aLength

The number of bytes to be filled. This value must not be negative. In debug builds only, the function raises a USER 95 panic if this value is negative.

TChar aChar

The fill character.


FillZ()

static void FillZ(TAny* aTrg,TInt aLength);

Description

Fills a specified block of data with binary zeroes (i.e. 0x00), replacing any existing content.

Parameters

TAny* aTrg

A pointer to the location where filling is to start.

TInt aLength

The number of bytes to be filled. This value must not be negative. In debug builds only, the function raises a USER 95 panic if this value is negative.

[Top]


Calculate a checksum


Crc()

static void Crc(TUint16& aCrc,const TAny* aPtr,TInt aLength);

Description

Performs a CCITT CRC checksum on the specified data.

On return from this function, the referenced 16 bit integer contains the checksummed value.

Parameters

TUint16& aCrc

A reference to a 16 bit integer to contain the checksummed value.

const TAny* aPtr

A pointer to the start of the data to be checksummed.

TInt aLength

The length of the data to be checksummed.

[Top]


Comparison of data


Compare()

static TInt Compare(const TUint8* aLeft,TInt aLeftL,const TUint8* aRight,TInt aRightL);
static TInt Compare(const TUint16* aLeft,TInt aLeftL,const TUint16* aRight,TInt aRightL);

Description

Compares a block of data at one specified location with a block of data at another specified location. Data is interpreted as being either 8 bit data or 16 bit data, depending on the specific overloaded function.

For the 8 bit function, the comparison proceeds on a byte for byte basis. The result of the comparison is based on the difference of the first bytes to disagree.

For the 16 bit function, the comparison proceeds on a double-byte for double byte basis. The result of the comparison is based on the difference of the first pair of bytes to disagree.

For both functions, the data at the two locations are equal if they have the same length and content. Where the lengths are different and the shorter section of data is the same as the first part of the longer section of data, the shorter is considered to be less than the longer.

Parameters

const TUint8* aLeft

A pointer to the first (or left) block of 8 bit data to be compared.

const TUint16* aLeft

A pointer to the first (or left) block of 16 bit data to be compared.

TInt aLeftL

The length of the first (or left) block of data to be compared. In the 8 bit function, this is the number of bytes. In the 16 bit function, this is the number of double-bytes.

const TUint8* aRight

A pointer to the second (or right) block of 8 bit data to be compared.

const TUint16* aRight

A pointer to the second (or right) block of 16 bit data to be compared.

TInt aRightL

The length of the second (or right) block of data to be compared. In the 8 bit function, this is the number of bytes. In the 16 bit function, this is the number of double-bytes.

Return value

TInt

Positive, if the first (or left) block of data is greater than the second (or right) block of data. Negative, if the first (or left) block of data is less than the second (or right) block of data. Zero, if both the first (or left) and second (or right) blocks of data have the same length and the same content.


CompareF()

static TInt CompareF(const TUint8* aLeft,TInt aLeftL,const TUint8* aRight,TInt aRightL);
static TInt CompareF(const TUint16* aLeft,TInt aLeftL,const TUint16* aRight,TInt aRightL);

Description

Compares a block of data at one specified location with a block of data at another specified location, using the standard folding method appropriate to the current locale. Data is interpreted as being either 8 bit data or 16 bit data, depending on the specific overloaded function.

Parameters

const TUint8* aLeft

A pointer to the first (or left) block of 8 bit data to be compared.

const TUint16* aLeft

A pointer to the first (or left) block of 16 bit data to be compared.

TInt aLeftL

The length of the first (or left) block of data to be compared. In the 8 bit function, this is the number of bytes. In the 16 bit function, this is the number of double-bytes.

const TUint8* aRight

A pointer to the second (or right) block of 8 bit data to be compared.

const TUint16* aRight

A pointer to the second (or right) block of 16 bit data to be compared.

TInt aRightL

The length of the second (or right) block of data to be compared. In the 8 bit function, this is the number of bytes. In the 16 bit function, this is the number of double-bytes.

Return value

TInt

Positive, if the first (or left) block of data is greater than the second (or right) block of data. Negative, if the first (or left) block of data is less than the second (or right) block of data. Zero, if both the first (or left) and second (or right) blocks of data have the same length and the same content.

See also:


CompareC()

static TInt CompareC(const TUint8* aLeft,TInt aLeftL,const TUint8* aRight,TInt aRightL);
static TInt CompareC(const TUint16* aLeft,TInt aLeftL,const TUint16* aRight,TInt aRightL);

Support

Withdrawn in 5.1
Supported from 5.0

Description

Compares a block of data at one specified location with a block of data at another specified location using the standard collation method appropriate to the current locale. Data is interpreted as being either 8 bit data or 16 bit data, depending on the specific overloaded function.

Parameters

const TUint8* aLeft

A pointer to the first (or left) block of 8 bit data to be compared.

const TUint16* aLeft

A pointer to the first (or left) block of 16 bit data to be compared.

TInt aLeftL

The length of the first (or left) block of data to be compared. In the 8 bit function, this is the number of bytes. In the 16 bit function, this is the number of double-bytes.

const TUint8* aRight

A pointer to the second (or right) block of 8 bit data to be compared.

const TUint16* aRight

A pointer to the second (or right) block of 16 bit data to be compared.

TInt aRightL

The length of the second (or right) block of data to be compared. In the 8 bit function, this is the number of bytes. In the 16 bit function, this is the number of double-bytes.

Return value

TInt

Positive, if the first (or left) block of data is greater than the second (or right) block of data. Negative, if the first (or left) block of data is less than the second (or right) block of data. Zero, if both the first (or left) and second (or right) blocks of data have the same length and the same content.

See also:


CompareC()

static TInt CompareC(const TUint16* aLeft,TInt aLeftL,const TUint16* aRight,TInt aRightL,const TInt16* aCollationRules);

Support

Withdrawn in 5.1

Description

Compares a block of data at one specified location with a block of data at another specified location using the specified collation rule set.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

const TUint16* aLeft

A pointer to the first (or left) block of 16 bit data to be compared.

TInt aLeftL

The length of the first (or left) block of data to be compared. This is the number of double-bytes.

const TUint16* aRight

A pointer to the second (or right) block of 16 bit data to be compared.

TInt aRightL

The length of the second (or right) block of data to be compared. This is the number of double-bytes.

const TInt16* aCollationRules

A pointer to the collation rule set.

Return value

TInt

Positive, if the first (or left) block of data is greater than the second (or right) block of data. Negative, if the first (or left) block of data is less than the second (or right) block of data. Zero, if both the first (or left) and second (or right) blocks of data have the same length and the same content.

See also:


CompareC()

static TInt CompareC(const TUint16* aLeft,TInt aLeftL,const TUint16* aRight,TInt aRightL,TUint32 aDesiredCollationRulesId,TUint32& aActualCollationRulesId);

Support

Withdrawn in 5.1
Supported from 5.0

Description

Compares a block of data at one specified location with a block of data at another specified location using the collation rule set associated with the specified Uid. If no collation rule set with the specified Uid can be found, the function uses a default collation rule set and returns its associated Uid.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

const TUint16* aLeft

A pointer to the first (or left) block of 16 bit data to be compared.

TInt aLeftL

The length of the first (or left) block of data to be compared. This is the number of double-bytes.

const TUint16* aRight

A pointer to the second (or right) block of 16 bit data to be compared.

TInt aRightL

The length of the second (or right) block of data to be compared. This is the number of double-bytes.

TUint32 aDesiredCollationRulesId

The Uid of the collation rule set required.

TUint32& aActualCollationRulesId

On return, contains the Uid of the collation rule set used. This may be different from the specified Uid, if there is no collation rule set with that Uid.

Return value

TInt

Positive, if the first (or left) block of data is greater than the second (or right) block of data. Negative, if the first (or left) block of data is less than the second (or right) block of data. Zero, if both the first (or left) and second (or right) blocks of data have the same length and the same content.


CompareC()

static TInt CompareC(const TUint16* aLeft,TInt aLeftL,const TUint16* aRight,TInt aRightL, TInt aMaxLevel,const TCollationMethod* aCollationMethod);

Support

Withdrawn in 5.0
Supported from 5.1

Description

Compares a block of data at one location with a block of data at another location using the specified collation method and collating to the specified maximum collation level. If no collation method is supplied, a default method, appropriate to the current locale, is used.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

const TUint16* aLeft

A pointer to the first (or left) block of 16 bit data to be compared.

TInt aLeftL

The length of the first (or left) block of data to be compared. This is the number of double-bytes.

const TUint16* aRight

A pointer to the second (or right) block of 16 bit data to be compared.

TInt aRightL

The length of the second (or right) block of data to be compared. This is the number of double-bytes.

TInt aMaxLevel

The maximum collation level.

const TCollationMethod* aCollationMethod

A pointer to the collation method or NULL.

Return value

TInt

Positive, if this descriptor is greater than the specified descriptor. Negative, if this descriptor is less than the specified descriptor. Zero, if both descriptors have the same length and the their contents are the same.

[Top]


Collation methods


CollationMethods()

static TInt CollationMethods();

Support

Withdrawn in 5.0
Supported from 5.1

Description

Returns the number of collation methods in this locale.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Return value

TInt

The number of collation methods.


CollationMethodId()

static TUint CollationMethodId(TInt aIndex);

Support

Withdrawn in 5.0
Supported from 5.1

Description

Returns the Uid associated with the specified collation method.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

TInt aIndex

An index into the set of collation methods in thie locale. This value is relative to zero; i.e. a zero value refers to the first collation method. This value: must not be negative, must be less than the total number of collation methods in this locale.In debug builds only, the function raises a USER 132 panic if these conditions are false.

Return value

TUint

The Uid of the collation method


CollationMethodByIndex()

static const TCollationMethod* CollationMethodByIndex(TInt aIndex);

Support

Withdrawn in 5.0
Supported from 5.1

Description

Returns the collation method identified by the specified index.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

TInt aIndex

An index into the set of collation methods in this locale. This value is relative to zero; i.e. a zero value refers to the first collation method. This value: must not be negative, must be less than the total number of collation methods in this locale.In debug builds only, the function raises a USER 132 panic if these conditions are false.

Return value

TCollationMethod*

A pointer to the collation method.


CollationMethodById()

static const TCollationMethod* CollationMethodById(TUint aId);

Support

Withdrawn in 5.0
Supported from 5.1

Description

Returns the collation method identified by the specified Uid.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

TUint aId

The Uid of a collation method in the set of collation methods in this locale.

Return value

TCollationMethod*

A pointer to the collation method.


CollationRuleSets()

static TInt CollationRuleSets();

Support

Withdrawn in 5.1
Supported from 5.0

Description

Returns the number of collation rule sets in this locale's collation repertoire.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Return value

TInt

The number of collation rule sets.


CollationRuleSetId()

static TInt CollationRuleSetId(TInt aIndex);

Support

Withdrawn in 5.1
Supported from 5.0

Description

Returns the Uid associated with the specified collation rule set in this locale's collation repertoire.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

TInt aIndex

An index into the collection of collation rule sets in this locale's collation repertoire. This value is relative to zero; i.e. a zero value refers to the first rule set. This value: must not be negative, must be less than the total number of rule sets.In debug builds only, the function raises a USER 132 panic if these conditions are false.

Return value

TInt

The Uid of the collation rule set.


CollationRuleSetByIndex()

static const TInt16* CollationRuleSetByIndex(TInt aIndex);

Support

Withdrawn in 5.1
Supported from 5.0

Description

Returns the collation rule set identified by the specified index.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

TInt aIndex

An index into the collection of collation rule sets in this locale's collation repertoire. This value is relative to zero; i.e. a zero value refers to the first rule set. This value: must not be negative, must be less than the total number of rule sets.In debug builds only, the function raises a USER 132 panic if these conditions are false.

Return value

TInt16*

A pointer to the collation rule set.


CollationRuleSetById()

static const TInt16* CollationRuleSetById(TUint32 aDesiredId,TUint32& aActualId);

Support

Withdrawn in 5.1
Supported from 5.0

Description

Returns the collation rule set identified by the specified Uid. If no collation rule set with the specified Uid can be found, the function returns a default collation rule set and its associated Uid.

This function is only defined for 16 bit (Unicode) build variants. This means that the function is not defined for 8 bit build variants, even when an explicit 16 bit descriptor is used.

Parameters

TUint32 aDesiredId

The Uid of the collation rule set required in this locale's collation repertoire.

TUint32& aActualId

On return, contains the Uid of the returned collation rule set. This may be different from the specified Uid, if there is no collation rule set with that Uid.

Return value

TInt16*

A pointer to the collation rule set.