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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This file contains the API definition for the classes TDelimitedParserBase16
15 // and CDelimitedData16.
22 @file DelimitedParser16.h
27 #ifndef __DELIMITEDPARSER16_H__
28 #define __DELIMITEDPARSER16_H__
33 #include <delimitedparsercommon.h>
37 Comments : Provides non-modifying functionality for parsing data delimited by
38 a single character. The data is delimited into segments. Uses 16-bit descriptors.
40 The object contains a descriptor with the data which can be parsed from left
41 to right, or right to left. It is non-owning. The current segment can be extracted,
42 which then parses the string for the next segment.
44 This is a base class and an object of this type cannot be instantiated. It should
45 be derived. The derived class should ensure that the data iDataDes is set before
46 calling one of the protected parsing functions. The derived class should also ensure
47 that the delimiting character has been set.
49 If the data iDataDes has not been parsed, then calling any functionality that
50 requires the data to have been parsed will result in a panic
51 KDelimitedParserErrNotParsed. The data can only be parsed by calling one of the
52 protected parsing functions from the derived class.
54 If the delimiting character iDelimiter has not been set, then calling the protected
55 parsing functions and some of the other public functionality that requires the
56 delimiter to be set will result in a panic KDelimitingParserErrNoDelimiter.
61 class TDelimitedParserBase16
65 IMPORT_C void Reset() const;
67 IMPORT_C TInt GetNext(TPtrC16& aSegment) const;
69 IMPORT_C TInt Inc() const;
71 IMPORT_C TInt Dec() const;
73 IMPORT_C TInt Peek(TPtrC16& aSegment) const;
75 IMPORT_C TBool Eos() const;
77 IMPORT_C TBool FrontDelimiter() const;
79 IMPORT_C TBool BackDelimiter() const;
81 IMPORT_C const TDesC16& Des() const;
83 IMPORT_C TInt Remainder(TPtrC16& aRemainder) const;
87 IMPORT_C TDelimitedParserBase16();
89 IMPORT_C void Parse(const TDesC16& aData);
91 IMPORT_C void ParseReverse(const TDesC16& aData);
93 IMPORT_C void SetDelimiter(TChar aDelimiter);
97 void DoParse(const TDesC16& aData);
99 TInt FindNextSegment(TInt aStartPos) const;
101 TInt FindPrevSegment(TInt aStartPos) const;
103 private: // Attributes
105 /** Descriptor with the string
109 /** Descriptor with the current segment.
111 mutable TPtrC16 iCurrentSegment;
113 /** Position of next segment.
115 mutable TInt iNextSegmentPos;
117 /** Direction of parsing.
119 TDelimitedDataParseMode iMode;
121 /** Delimiting character
127 @see CDelimitedDataBase16
130 friend class CDelimitedDataBase16;
139 typedef TDelimitedParserBase16 TDelimitedParserBase;
142 Dependencies : CBase, TDelimitedParserBase16
143 Comments : Provides functionality for creating and editing a delimited data object.
144 Uses 16-bit descriptors
146 The object contains a descriptor buffer with the data. Functionality is provided
147 to allow segments to be added or removed from the data. There is access to the
148 internal delimited data parser to provide parsing functionality to be excercised
151 This a base class that cannot be instantiated. It should be derived. The derived
152 class must set the delimited data parser, which is an object derived from
153 TDelimitedParserBase. This helper class must set the delimiting object
155 If the delimiting character has not been set, then calling any of the functionality
156 will cause a panic KDelimitedParserErrNoDelimiter.
161 class CDelimitedDataBase16 : public CBase
166 IMPORT_C ~CDelimitedDataBase16();
168 IMPORT_C void InsertCurrentL(const TDesC16& aSegment);
170 IMPORT_C void RemoveCurrentL();
172 IMPORT_C void PushBackL(const TDesC16& aSegment);
174 IMPORT_C void PopBackL();
176 IMPORT_C void PushFrontL(const TDesC16& aSegment);
178 IMPORT_C void PopFrontL();
180 IMPORT_C void TrimFrontDelimiterL();
182 IMPORT_C void AddFrontDelimiterL();
184 IMPORT_C void TrimBackDelimiterL();
186 IMPORT_C void AddBackDelimiterL();
188 IMPORT_C void Parse();
190 IMPORT_C void ParseReverse();
192 IMPORT_C const TDelimitedParserBase16& Parser() const;
194 protected: // Methods
196 IMPORT_C CDelimitedDataBase16();
198 IMPORT_C void ConstructL(const TDesC16& aData);
200 IMPORT_C void SetDelimiter(TChar aDelimiter);
204 void SetDataL(const TDesC16& aData);
206 void SetData(HBufC16* aDataBuf);
208 void DoInsertL(const TDesC16& aSegment);
212 private: // Attributes
214 /** Descriptor buffer.
220 TDelimitedParserBase16 iParser;
229 typedef CDelimitedDataBase16 CDelimitedDataBase;
231 #endif // __DELIMITEDPARSER16_H__