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