1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This file contains the API definition for the classes TDelimitedParserBase16
15 // and CDelimitedData16.
20 @file DelimitedParser16.h
25 #ifndef __DELIMITEDPARSER16_H__
26 #define __DELIMITEDPARSER16_H__
31 #include <delimitedparsercommon.h>
35 Comments : Provides non-modifying functionality for parsing data delimited by
36 a single character. The data is delimited into segments. Uses 16-bit descriptors.
38 The object contains a descriptor with the data which can be parsed from left
39 to right, or right to left. It is non-owning. The current segment can be extracted,
40 which then parses the string for the next segment.
42 This is a base class and an object of this type cannot be instantiated. It should
43 be derived. The derived class should ensure that the data iDataDes is set before
44 calling one of the protected parsing functions. The derived class should also ensure
45 that the delimiting character has been set.
47 If the data iDataDes has not been parsed, then calling any functionality that
48 requires the data to have been parsed will result in a panic
49 KDelimitedParserErrNotParsed. The data can only be parsed by calling one of the
50 protected parsing functions from the derived class.
52 If the delimiting character iDelimiter has not been set, then calling the protected
53 parsing functions and some of the other public functionality that requires the
54 delimiter to be set will result in a panic KDelimitingParserErrNoDelimiter.
59 class TDelimitedParserBase16
63 IMPORT_C void Reset() const;
65 IMPORT_C TInt GetNext(TPtrC16& aSegment) const;
67 IMPORT_C TInt Inc() const;
69 IMPORT_C TInt Dec() const;
71 IMPORT_C TInt Peek(TPtrC16& aSegment) const;
73 IMPORT_C TBool Eos() const;
75 IMPORT_C TBool FrontDelimiter() const;
77 IMPORT_C TBool BackDelimiter() const;
79 IMPORT_C const TDesC16& Des() const;
81 IMPORT_C TInt Remainder(TPtrC16& aRemainder) const;
85 IMPORT_C TDelimitedParserBase16();
87 IMPORT_C void Parse(const TDesC16& aData);
89 IMPORT_C void ParseReverse(const TDesC16& aData);
91 IMPORT_C void SetDelimiter(TChar aDelimiter);
95 void DoParse(const TDesC16& aData);
97 TInt FindNextSegment(TInt aStartPos) const;
99 TInt FindPrevSegment(TInt aStartPos) const;
101 private: // Attributes
103 /** Descriptor with the string
107 /** Descriptor with the current segment.
109 mutable TPtrC16 iCurrentSegment;
111 /** Position of next segment.
113 mutable TInt iNextSegmentPos;
115 /** Direction of parsing.
117 TDelimitedDataParseMode iMode;
119 /** Delimiting character
125 @see CDelimitedDataBase16
128 friend class CDelimitedDataBase16;
137 typedef TDelimitedParserBase16 TDelimitedParserBase;
140 Dependencies : CBase, TDelimitedParserBase16
141 Comments : Provides functionality for creating and editing a delimited data object.
142 Uses 16-bit descriptors
144 The object contains a descriptor buffer with the data. Functionality is provided
145 to allow segments to be added or removed from the data. There is access to the
146 internal delimited data parser to provide parsing functionality to be excercised
149 This a base class that cannot be instantiated. It should be derived. The derived
150 class must set the delimited data parser, which is an object derived from
151 TDelimitedParserBase. This helper class must set the delimiting object
153 If the delimiting character has not been set, then calling any of the functionality
154 will cause a panic KDelimitedParserErrNoDelimiter.
159 class CDelimitedDataBase16 : public CBase
164 IMPORT_C ~CDelimitedDataBase16();
166 IMPORT_C void InsertCurrentL(const TDesC16& aSegment);
168 IMPORT_C void RemoveCurrentL();
170 IMPORT_C void PushBackL(const TDesC16& aSegment);
172 IMPORT_C void PopBackL();
174 IMPORT_C void PushFrontL(const TDesC16& aSegment);
176 IMPORT_C void PopFrontL();
178 IMPORT_C void TrimFrontDelimiterL();
180 IMPORT_C void AddFrontDelimiterL();
182 IMPORT_C void TrimBackDelimiterL();
184 IMPORT_C void AddBackDelimiterL();
186 IMPORT_C void Parse();
188 IMPORT_C void ParseReverse();
190 IMPORT_C const TDelimitedParserBase16& Parser() const;
192 protected: // Methods
194 IMPORT_C CDelimitedDataBase16();
196 IMPORT_C void ConstructL(const TDesC16& aData);
198 IMPORT_C void SetDelimiter(TChar aDelimiter);
202 void SetDataL(const TDesC16& aData);
204 void SetData(HBufC16* aDataBuf);
206 void DoInsertL(const TDesC16& aSegment);
210 private: // Attributes
212 /** Descriptor buffer.
218 TDelimitedParserBase16 iParser;
227 typedef CDelimitedDataBase16 CDelimitedDataBase;
229 #endif // __DELIMITEDPARSER16_H__