Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: versit.h
Link against: versit.lib

Class CVersitParser

CVersitParser

Support

Supported from 5.0

Description

vCalendar or vCard parser.

The vCalendar or vCard data is read from or written to a stream. InternalizeL() reads the vCalendar or vCard contained in the stream and parses it, breaking it down into its constituent sub-entities (e.g. to-dos, events, and nested vCards) and properties. It also converts all date/times into machine-local values. ExternalizeL() writes the vCalendar or vCard to a write stream, converting all date/time values from machine-local into universal time. Most users of this class will only need to use these two functions.

The class also provides functions to add properties and sub-entities to an existing object. Although this is not an abstract class, in practice, you would create and use objects of one of the derived classes instead (CParserVCard or CParserVCal).

Derivation

CBaseBase class for all classes to be instantiated on the heap
CVersitParservCalendar or vCard parser

Defined in CVersitParser:
AddEntityL(), AddPropertyL(), ArrayOfEntities(), ArrayOfProperties(), ConvertAllPropertyDateTimesToMachineLocalL(), DefaultCharSet(), DefaultEncoding(), EBIG5CharSet, EEUCJPCharSet, EGB231280CharSet, EGBKCharSet, EISO2022JPCharSet, EISO885910CharSet, EISO88591CharSet, EISO88592CharSet, EISO88593CharSet, EISO88594CharSet, EISO88595CharSet, EISO88597CharSet, EISO88599CharSet, EShiftJISCharSet, EUSAsciiCharSet, EUTF7CharSet, EUTF8CharSet, EntityL(), EntityName(), ExternalizeL(), InternalizeL(), IsValidLabel(), IsValidParameterValue(), PropertyL(), SetDefaultCharSet(), SetDefaultEncoding(), SetEntityNameL(), SetParamCharType(), TVersitCharSet

Inherited from CBase:
operator new()

See also:


Stream persistence


ExternalizeL()

void ExternalizeL(RWriteStream& aStream);

Description

Externalises a versit entity (vCard or vCalendar) and all of its sub-entities and properties to a write stream. Converts all date/time values from machine-local into universal time. The presence of this function means that the standard templated operator<<() (defined in s32strm.h) is available to externalise objects of this class.

Parameters

RWriteStream& aStream

Stream to which the entity should be externalised.


ExternalizeL()

void ExternalizeL(RFile& aOutputFile);

Description

Externalises a versit entity (vCard or vCalendar) and all of its sub-entities and properties to a file. Converts all date/time values from machine-local into universal time.

Parameters

RFile& aOutputFile

The file to which to write the entity.


InternalizeL()

void InternalizeL(RReadStream& aStream);

Description

Internalises a versit entity (vCard or vCalendar) and all of its sub-entities and properties from a read stream. Converts all date/times into machine-local values. The presence of this function means that the standard templated operator>>() (defined in s32strm.h) is available to internalise objects of this class.

Parameters

RReadStream& aStream

Stream from which the entity should be internalised.


InternalizeL()

void InternalizeL(RFile& aInputFile,TInt& aBytesThroughFile);

Description

Internalises a versit entity (vCard or vCalendar) and all of its sub-entities and properties from a file. Converts all date/times into machine-local values. aBytesThroughFile is the file position at which reading should start. On return, it is updated to mark the file position of the last byte read from the file.

Parameters

RFile& aInputFile

The file from which to internalise the entity.

TInt& aBytesThroughFile

The number of bytes into the file at which to begin reading. On return, is updated to contain the last position in the file which was read.

Leave codes

KErrEof

The file position specified is beyond the end of the file.

[Top]


Entities


AddEntityL()

void AddEntityL(CVersitParser* aEntity);

Description

Adds a sub-entity (e.g. a to-do, event or a nested vCard) to the current entity. This function may be used when building up a versit parser object from a client application.

Parameters

CVersitParser* aEntity

Pointer to a sub-entity.


ArrayOfEntities()

CArrayPtr<CVersitParser>* ArrayOfEntities(TBool aTakeOwnership);

Description

Gets the current entity's array of sub-entities. The current entity may be a top level entity, or may itself be a sub-entity. If aTakeOwnership is true, the array of sub-entities owned by the current entity is then set to NULL so that the code which calls this function takes ownership of the array.

Parameters

TBool aTakeOwnership

If ETrue, the calling code takes ownership of the array. If EFalse, ownership remains with the parser.

Return value

CArrayPtr<CVersitParser>*

Array of pointers to the current entity's array of sub-entities.


EntityL()

CArrayPtr<CVersitParser>* EntityL(const TDesC& aEntityName,TBool aTakeOwnership);

Description

Gets all sub-entities in the current entity, whose name matches the name specified.

Parameters

const TDesC& aEntityName

The sub-entity name of interest, e.g. KVersitVarTokenVEVENT, or KVersitVarTokenVTODO. All sub-entities which match this name are returned in the array of pointers.

TBool aTakeOwnership

If ETrue, the calling code takes ownership of each matching sub-entity (the sub-entity in the array owned by the current entity is set to NULL). If EFalse, ownership remains with the current entity.

Return value

CArrayPtr<CVersitParser>*

An array of pointers to all sub-entities with the specified name property.


SetEntityNameL()

void SetEntityNameL(const TDesC& aEntityName);

Description

Sets the name for the current entity to one of: VCARD, VCALENDAR, VEVENT or VTODO.

Parameters

const TDesC& aEntityName

The new name for the current parser entity. Any existing name is first deleted.

Leave codes

KErrNoMemory

Memory is allocated for the new entity name on the heap, so it can leave if there is insufficient memory available.


EntityName()

TPtrC EntityName() const;

Description

Gets the current entity's name. If no name has been set, returns an empty descriptor.

Return value

TPtrC

The current entity's name.

[Top]


Properties


AddPropertyL()

void AddPropertyL(CParserProperty* aProperty,TBool aInternalizing);

Description

Appends a property to the current entity's list of properties. This function may be used when building up a versit parser object from a client application.

Parameters

CParserProperty* aProperty

Pointer to the property to add to the entity.

TBool aInternalizing

This parameter is used to distinguish between reading an entity from a stream or file (i.e. internalizing), in which case the argument should have a value of ETrue, and building an entity "by hand" (e.g. creating a vCard in the Contacts application), in which case, the argument should have a value of EFalse.


ArrayOfProperties()

CArrayPtr<CParserProperty>* ArrayOfProperties(TBool aTakeOwnership);

Description

Gets the current entity’s array of properties. If aTakeOwnership is true, the entity’s array of properties is then set to NULL so that the code which calls this function takes ownership of the array.

Parameters

TBool aTakeOwnership

If ETrue, the calling code takes ownership of the array. If EFalse, ownership remains with the entity.

Return value

CArrayPtr<CParserProperty>*

Array of pointers to the entity’s properties.


PropertyL()

CArrayPtr<CParserProperty>* PropertyL(const TDesC& aPropertyName,const TUid& aPropertyUid,TBool aTakeOwnership);

Description

Gets all properties in the current entity's list of properties whose name and value match the name and value specified.

Parameters

const TDesC& aPropertyName

The property name of interest. Property names are defined in file vtoken.h.

const TUid& aPropertyUid

The property value of interest. See the property UID values defined in file vuid.h.

TBool aTakeOwnership

If ETrue, the calling code takes ownership of each matching property (the property in the entity’s array is set to NULL). If EFalse, ownership remains with the entity.

Return value

CArrayPtr<CParserProperty>*

An array of pointers to all properties with the name and value specified.


ConvertAllPropertyDateTimesToMachineLocalL()

void ConvertAllPropertyDateTimesToMachineLocalL(const TTimeIntervalSeconds& aIncrement,const CVersitDaylight* aDaylight);

Description

Converts all date/time property values contained in the current entity's list of properties into machine local values.

It does this first by converting all date/times into universal time, by adding aIncrement and subtracting the daylight saving offset specified in aDaylight (if daylight saving is in effect). Then, these universal time values are converted into machine local times by adding the universal time offset for the machine's locale.

Note that this function is called by InternalizeL().

Parameters

const TTimeIntervalSeconds& aIncrement

A time interval in seconds to add to the date/time.

const CVersitDaylight* aDaylight

The specification for daylight saving. If a date/time value is within the period for daylight saving, the date/time is modified by the daylight saving offset.

[Top]


Validation


IsValidLabel()

TBool IsValidLabel(const TDesC& aLabel, TInt& aPos);

Description

Tests whether a property name is valid.

Notes:

The property name is invalid if it contains any of the following characters: —

Parameters

const TDesC& aLabel

The property name to test.

TInt& aPos

On return, contains the character position within the property name of the first invalid character found.

Return value

TBool

ETrue if valid, EFalse if invalid.


IsValidParameterValue()

TBool IsValidParameterValue(TInt& aPos,const TDesC& aParamValue) const;

Description

Tests whether a property parameter name or value is valid.

If the string aParamValue contains any punctuation characters, the string is invalid. Otherwise, it is valid. Punctuation characters are defined as any of the following: —

Parameters

TInt& aPos

On return, contains the character position of the first invalid character in the property parameter name or value.

const TDesC& aParamValue

The property parameter name or value to test.

Return value

TBool

ETrue if valid, EFalse if invalid.

[Top]


Default character sets

Description

Imported property values are always in ASCII unless the encoding format is stated in the preceding property parameter. Hence the default character set is not used for internalising Versit objects.

The only exception to this behaviour is when the default character set is specified to be UTF-7. In this case ALL property values are written in UTF-7  — even if they could be represented in ASCII.

Versit first attempts to encode property values using the ASCII character set. If a value cannot be represented in ASCII then Versit attempts to encode the value using the default character set. If this character set is also incapable of representing the property value, then UTF-8 is used.

Versit property names and property parameters are always exported using the ASCII character set. However property values may be exported using other character sets/transformation formats.


DefaultCharSet()

const CVersitParser::TVersitCharSet DefaultCharSet() const;

Support

Supported from 5.1

Description

Gets the default character set or transformation format. This may be used to encode property values in versit objects.

Notes:

Return value

TVersitCharSet

The default character set.


SetDefaultCharSet()

void SetDefaultCharSet(const CVersitParser::TVersitCharSet aCharSet);

Support

Supported from 5.1

Description

Sets the default character set or transformation format. This may be used to encode property values in versit objects.

Notes:

Parameters

const TVersitCharSet aCharSet

The default character set.


SetParamCharType()

void SetParamCharType(TUid aTokenUid);

Support

Supported from 5.1

Description

Converts a versit-specific UID value that represents a character set into a versit character set enumeration value (see CVersitParser::TVersitCharSet) and sets it as the character set for the property currently being parsed (overrides the parser's default character set). This function is called by the parser when parsing a property which contains the charset property parameter.

Parameters

TUid aTokenUid

A versit-specific UID value that represents a character set (for possible values, see the KVersitParamCharsetXxxxUid values defined in VUID.H).


DefaultEncoding()

const CVersitParser::TVersitEncoding DefaultEncoding() const;

Support

Supported from 5.1

Description

Gets the parser's default character encoding, as set by SetDefaultEncoding(). This value is initialised on construction to ENoEncoding.

Return value

CVersitParser::TVersitEncoding

The parser's default character encoding.


SetDefaultEncoding()

void SetDefaultEncoding(const CVersitParser::TVersitEncoding aEncoding);

Support

Supported from 5.1

Description

Sets the parser's default character encoding.

Parameters

const CVersitParser::TVersitEncoding aEncoding

The parser's default encoding.

[Top]


Enumerations


Enum TVersitCharSet

TVersitCharSet

Support

Supported from 5.1

Description

Versit-specific character set identifiers. These are used in the Versit API to represent foreign (non-Unicode) character set encodings for vCard and vCalendar properties.

EUSAsciiCharSet

ASCII.

EUTF8CharSet

UTF-8 Unicode transformation format.

EUTF7CharSet

UTF-7 Unicode transformation format.

EISO88591CharSet

ISO 8859-1

EISO88592CharSet

ISO 8859-2

EISO88594CharSet

ISO 8859-4

EISO88595CharSet

ISO 8859-5

EISO88597CharSet

ISO 8859-7

EISO88599CharSet

ISO 8859-9

EISO88593CharSet

ISO 8859-3

EISO885910CharSet

ISO 8859-10

EGB231280CharSet

GB 2312

EGBKCharSet

GBK

EBIG5CharSet

Big 5

EISO2022JPCharSet

ISO-2022-JP

EEUCJPCharSet

EUC-JP

EShiftJISCharSet

JIS Encoding