Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: VERSIT.H
Link against: versit.lib

Class CLineReader

class CLineReader : public CBase;

Description

Line reader for a vCalendar or vCard parser.

Reads in a line at a time for the parser.

Also allows the first character of the next line to be checked to see if it is a space, which can indicate that the line is wrapped. This enables the reading of multi-line property values.

Used by CVersitParser to internalise streams.

Derivation

Members

Defined in CLineReader:
AppendLineIfSpaceNextL(), AppendSpaceL(), CLineReader(), ConstructL(), EExpandSize, EInitialLineSize, ELineHasContent, ELineIsCRLFOnly, ELineIsWhiteSpace, ExpandBufferL(), IsSpaceNextL(), NewL(), ReadChar(), ReadLineL(), Reserved(), SetPlugIn(), SetSkipWhiteSpaceAtStart(), anonymous, anonymous, iBufPtr, iFirstCharNextLine, iLineBuf, iReadStream, ~CLineReader()

Inherited from CBase:
Delete(), Extension_(), operator new()


Construction and destruction


NewL()

static IMPORT_C CLineReader *NewL(RReadStream &aStream);

Description

Constructs and returns a CLineReader.

Parameters

RReadStream &aStream

The stream to read the lines from.

Return value

CLineReader *


~CLineReader()

IMPORT_C ~CLineReader();

Description

Frees all resources owned by the line reader prior to its destruction.


CLineReader()

protected: inline CLineReader(RReadStream &aStream);

Description

Parameters

RReadStream &aStream


ConstructL()

protected: IMPORT_C void ConstructL();

Description

[Top]


Member functions


ReadLineL()

virtual IMPORT_C TBool ReadLineL(TInt aPos, TInt &aErr);

Description

Reads in a line from the stream.

The line is stored in a buffer pointed to by iBufPtr. Data from the stream is appended to the buffer, starting at buffer position aPos, until the next 'CRLF' ("/r/n") is reached. The line feed and carriage return are not added to the buffer. Using only linefeeds LF( ) as the line delimiters is also supported.

The buffer will be expanded if necessary to fit the line into it.

If the end of stream is reached, aErr will contain KErrEof upon return.

It would be normal to set aPos to the start of the buffer unless reading a multi-line value.

Parameters

TInt aPos

The position in the buffer pointed to by iBufPtr at which to begin appending data to the buffer. Allows lines to be appended to the buffer when reading multi-line values.

TInt &aErr

On return, this will be KErrEof if the end of the stream is reached and KErrNone otherwise.

Return value

TBool

ELineHasContent if the line has content; ELineIsWhiteSpace if the line has only white space before the CRLF; ELineIsCRLFOnly if the line is only a CRLF.


AppendLineIfSpaceNextL()

IMPORT_C TBool AppendLineIfSpaceNextL();

Description

Checks the first character of the next line and, if it is a white space, reads the next line into the buffer (pointed to by iBufPtr).

The line is appended to the buffer rather than overwriting data already in the buffer.

A plug-in option can determine that no space is to be written to the buffer between the lines. By default, a space will be written.

Used by the Versit parser while it is reading multi-line property values.

Return value

TBool

ETrue if a line was read (because the first character of the next line is a space); EFalse if a line wasn't read (because the first character of the next line isn't a space or an error occured).


IsSpaceNextL()

IMPORT_C TBool IsSpaceNextL();

Description

Checks to see if the first character of the next line is white space.

This function should not be called more than once without a line being read in.

Used by the Versit parser while it is reading multi-line property values.

Return value

TBool

ETrue if the next line starts with a white space character; EFalse if it doesn't or an error occurs.


AppendSpaceL()

IMPORT_C TInt AppendSpaceL();

Description

Appends a space to the end of the buffer (pointed to by iBufPtr).

The buffer will be expanded if necessary.

This is called by AppendLineIfSpaceNextL() to create a space in the buffer between the lines being read (as long as there is no plug-in option to to indicate there should be no space).

Return value

TInt


SetPlugIn()

inline void SetPlugIn(MVersitPlugIn *aPlugIn);

Description

Sets the plug-in.

Allows implemented functions of the MVersitPlugIn class to be used in specifying options for adding and deleting spaces to/from the buffer.

Specifically, the plug-in is used to determine whether an additional space should be added when appending a line to the buffer (by default a space will be added), and whether the white space at the start of a line should form part of the data (by default it will not form part of the data).

Using a plug-in is optional.

Parameters

MVersitPlugIn *aPlugIn

A pointer to an MVersitPlugIn instance.


SetSkipWhiteSpaceAtStart()

inline void SetSkipWhiteSpaceAtStart(TBool aDoSkip);

Description

Parameters

TBool aDoSkip


ExpandBufferL()

protected: IMPORT_C void ExpandBufferL(TInt aCurrentSize);

Description

Parameters

TInt aCurrentSize


ReadChar()

protected: IMPORT_C TUint8 ReadChar(TInt &aErr);

Description

Parameters

TInt &aErr

Return value

TUint8


Reserved()

private: virtual IMPORT_C void Reserved();

Description

[Top]


Member enumerations


Enum anonymous

n/a

Description

Defines the initial line size of, and the size of expansions to, the buffer which stores the line being read.

EInitialLineSize

The initial size of the buffer (pointed to by iBuf).

EExpandSize

The size by which the buffer (pointed to by iBuf) is expanded when it has run out of room.


Enum anonymous

n/a

Description

Defines values which describe the content of a line that has been read.

This is the return value from the function ReadLine().

ELineHasContent

The line has content (not white space).

ELineIsWhiteSpace

The line has white space only.

ELineIsCRLFOnly

The line has no content, and so is just a carriage return and line feed ("/r/n").

[Top]


Member data


iReadStream

RReadStream * iReadStream;

Description

A pointer to an RReadStream object, the ReadUint8L() function of which is used to read single characters from the stream.

This is passed into the NewL() function upon construction.


iBufPtr

TPtr8 iBufPtr;

Description

A pointer to a buffer which stores data read from the stream.

Its size on construction is EInitialLineSize, and it is expanded by EExpandSize when necessary.

A copy of this value should not be stored, since the buffer location may change if the buffer is expanded.

Data in the buffer is not lost when the buffer is expanded, but is copied to the new location.


iLineBuf

protected: HBufC8 * iLineBuf;

Description


iFirstCharNextLine

protected: TInt iFirstCharNextLine;

Description