epoc32/include/delimitedparser16.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     4
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
// This file contains the API definition for the classes TDelimitedParserBase16
williamr@2
    15
// and CDelimitedData16.
williamr@2
    16
// 
williamr@2
    17
//
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
/**
williamr@2
    22
 @file DelimitedParser16.h
williamr@2
    23
 @publishedAll
williamr@2
    24
 @released	
williamr@2
    25
*/
williamr@2
    26
williamr@2
    27
#ifndef __DELIMITEDPARSER16_H__
williamr@2
    28
#define __DELIMITEDPARSER16_H__
williamr@2
    29
williamr@2
    30
// System includes
williamr@2
    31
//
williamr@2
    32
#include <e32base.h>
williamr@2
    33
#include <delimitedparsercommon.h>
williamr@2
    34
williamr@2
    35
williamr@2
    36
/**
williamr@2
    37
Comments : Provides non-modifying functionality for parsing data delimited by
williamr@2
    38
a single character. The data is delimited into segments. Uses 16-bit descriptors.
williamr@2
    39
williamr@2
    40
The object contains a descriptor with the data which can be parsed from left
williamr@2
    41
to right, or right to left. It is non-owning. The current segment can be extracted,
williamr@2
    42
which then parses the string for the next segment.
williamr@2
    43
williamr@2
    44
This is a base class and an object of this type cannot be instantiated. It should
williamr@2
    45
be derived. The derived class should ensure that the data iDataDes is set before
williamr@2
    46
calling one of the protected parsing functions. The derived class should also ensure
williamr@2
    47
that the delimiting character has been set.
williamr@2
    48
williamr@2
    49
If the data iDataDes has not been parsed, then calling any functionality that
williamr@2
    50
requires the data to have been parsed will result in a panic
williamr@2
    51
KDelimitedParserErrNotParsed. The data can only be parsed by calling one of the
williamr@2
    52
protected parsing functions from the derived class.
williamr@2
    53
williamr@2
    54
If the delimiting character iDelimiter has not been set, then calling the protected
williamr@2
    55
parsing functions and some of the other public functionality that requires the
williamr@2
    56
delimiter to be set will result in a panic KDelimitingParserErrNoDelimiter.
williamr@2
    57
@publishedAll
williamr@2
    58
@released
williamr@2
    59
@since 6.0
williamr@2
    60
*/
williamr@2
    61
class TDelimitedParserBase16
williamr@2
    62
	{
williamr@2
    63
public:	// Methods
williamr@2
    64
williamr@2
    65
	IMPORT_C void Reset() const;
williamr@2
    66
	
williamr@2
    67
	IMPORT_C TInt GetNext(TPtrC16& aSegment) const;
williamr@2
    68
williamr@2
    69
	IMPORT_C TInt Inc() const;
williamr@2
    70
williamr@2
    71
	IMPORT_C TInt Dec() const;
williamr@2
    72
williamr@2
    73
	IMPORT_C TInt Peek(TPtrC16& aSegment) const;
williamr@2
    74
williamr@2
    75
	IMPORT_C TBool Eos() const;
williamr@2
    76
williamr@2
    77
	IMPORT_C TBool FrontDelimiter() const;
williamr@2
    78
williamr@2
    79
	IMPORT_C TBool BackDelimiter() const;
williamr@2
    80
williamr@2
    81
	IMPORT_C const TDesC16& Des() const;
williamr@2
    82
williamr@2
    83
	IMPORT_C TInt Remainder(TPtrC16& aRemainder) const;
williamr@2
    84
williamr@2
    85
protected:	// Methods
williamr@2
    86
williamr@2
    87
	IMPORT_C TDelimitedParserBase16();
williamr@2
    88
williamr@2
    89
	IMPORT_C void Parse(const TDesC16& aData);
williamr@2
    90
williamr@2
    91
	IMPORT_C void ParseReverse(const TDesC16& aData);
williamr@2
    92
williamr@2
    93
	IMPORT_C void SetDelimiter(TChar aDelimiter);
williamr@2
    94
williamr@2
    95
private:	// Methods
williamr@2
    96
williamr@2
    97
	void DoParse(const TDesC16& aData);
williamr@2
    98
williamr@2
    99
	TInt FindNextSegment(TInt aStartPos) const;
williamr@2
   100
williamr@2
   101
	TInt FindPrevSegment(TInt aStartPos) const;
williamr@2
   102
williamr@2
   103
private:	// Attributes
williamr@2
   104
williamr@2
   105
	/** Descriptor with the string
williamr@2
   106
	 */
williamr@2
   107
	TPtrC16						iDataDes;
williamr@2
   108
williamr@2
   109
	/** Descriptor with the current segment.
williamr@2
   110
	 */
williamr@2
   111
	mutable TPtrC16				iCurrentSegment;
williamr@2
   112
williamr@2
   113
	/** Position of next segment.
williamr@2
   114
	 */
williamr@2
   115
	mutable TInt				iNextSegmentPos;
williamr@2
   116
williamr@2
   117
	/** Direction of parsing.
williamr@2
   118
	 */
williamr@2
   119
	TDelimitedDataParseMode		iMode;
williamr@2
   120
williamr@2
   121
	/** Delimiting character
williamr@2
   122
	*/
williamr@2
   123
	TInt						iDelimiter;
williamr@2
   124
williamr@2
   125
/**
williamr@2
   126
	A friend class.
williamr@2
   127
	@see		CDelimitedDataBase16
williamr@2
   128
	@since		6.0
williamr@2
   129
 */
williamr@2
   130
	friend class CDelimitedDataBase16;
williamr@2
   131
williamr@2
   132
	};
williamr@2
   133
williamr@2
   134
/**
williamr@2
   135
typedef 
williamr@2
   136
@publishedAll
williamr@2
   137
@released
williamr@2
   138
*/
williamr@2
   139
typedef TDelimitedParserBase16 TDelimitedParserBase;
williamr@2
   140
williamr@2
   141
/**
williamr@2
   142
Dependencies : CBase, TDelimitedParserBase16
williamr@2
   143
Comments : Provides functionality for creating and editing a delimited data object.
williamr@2
   144
Uses 16-bit descriptors
williamr@2
   145
williamr@2
   146
The object contains a descriptor buffer with the data. Functionality is provided
williamr@2
   147
to allow segments to be added or removed from the data. There is access to the
williamr@2
   148
internal delimited data parser to provide parsing functionality to be excercised
williamr@2
   149
on the created data.
williamr@2
   150
williamr@2
   151
This a base class that cannot be instantiated. It should be derived. The derived
williamr@2
   152
class must set the delimited data parser, which is an object derived from
williamr@2
   153
TDelimitedParserBase. This helper class must set the delimiting object
williamr@2
   154
williamr@2
   155
If the delimiting character has not been set, then calling any of the functionality
williamr@2
   156
will cause a panic KDelimitedParserErrNoDelimiter.
williamr@2
   157
@publishedAll
williamr@2
   158
@released
williamr@2
   159
@since 6.0
williamr@2
   160
*/
williamr@2
   161
class CDelimitedDataBase16 : public CBase
williamr@2
   162
	{
williamr@2
   163
public: // Methods
williamr@2
   164
williamr@2
   165
williamr@2
   166
	IMPORT_C ~CDelimitedDataBase16();
williamr@2
   167
williamr@2
   168
	IMPORT_C void InsertCurrentL(const TDesC16& aSegment);
williamr@2
   169
williamr@2
   170
	IMPORT_C void RemoveCurrentL();
williamr@2
   171
williamr@2
   172
	IMPORT_C void PushBackL(const TDesC16& aSegment);
williamr@2
   173
williamr@2
   174
	IMPORT_C void PopBackL();
williamr@2
   175
williamr@2
   176
	IMPORT_C void PushFrontL(const TDesC16& aSegment);
williamr@2
   177
williamr@2
   178
	IMPORT_C void PopFrontL();
williamr@2
   179
williamr@2
   180
	IMPORT_C void TrimFrontDelimiterL();
williamr@2
   181
williamr@2
   182
	IMPORT_C void AddFrontDelimiterL();
williamr@2
   183
williamr@2
   184
	IMPORT_C void TrimBackDelimiterL();
williamr@2
   185
williamr@2
   186
	IMPORT_C void AddBackDelimiterL();
williamr@2
   187
williamr@2
   188
	IMPORT_C void Parse();
williamr@2
   189
williamr@2
   190
	IMPORT_C void ParseReverse();
williamr@2
   191
williamr@2
   192
	IMPORT_C const TDelimitedParserBase16& Parser() const;
williamr@2
   193
williamr@2
   194
protected:	// Methods
williamr@2
   195
williamr@2
   196
	IMPORT_C CDelimitedDataBase16();
williamr@2
   197
williamr@2
   198
	IMPORT_C void ConstructL(const TDesC16& aData);
williamr@2
   199
williamr@2
   200
	IMPORT_C void SetDelimiter(TChar aDelimiter);
williamr@2
   201
williamr@2
   202
private:	// Methods
williamr@2
   203
williamr@2
   204
	void SetDataL(const TDesC16& aData);
williamr@2
   205
williamr@2
   206
	void SetData(HBufC16* aDataBuf);
williamr@2
   207
williamr@2
   208
	void DoInsertL(const TDesC16& aSegment);
williamr@2
   209
williamr@2
   210
	void DoRemoveL();
williamr@2
   211
williamr@2
   212
private:	// Attributes
williamr@2
   213
williamr@2
   214
	/** Descriptor buffer.
williamr@2
   215
	 */
williamr@2
   216
	HBufC16*				iDataBuf;
williamr@2
   217
williamr@2
   218
	/** Parser object
williamr@2
   219
	 */
williamr@2
   220
	TDelimitedParserBase16	iParser;
williamr@2
   221
williamr@2
   222
	};
williamr@2
   223
williamr@2
   224
/**
williamr@2
   225
typedef 
williamr@2
   226
@publishedAll
williamr@2
   227
@released
williamr@2
   228
*/
williamr@2
   229
typedef CDelimitedDataBase16 CDelimitedDataBase;
williamr@2
   230
williamr@2
   231
#endif	// __DELIMITEDPARSER16_H__