1.1 --- a/epoc32/include/delimitedparser16.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/delimitedparser16.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,231 @@
1.4 -delimitedparser16.h
1.5 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +// This file contains the API definition for the classes TDelimitedParserBase16
1.19 +// and CDelimitedData16.
1.20 +//
1.21 +//
1.22 +
1.23 +
1.24 +
1.25 +/**
1.26 + @file DelimitedParser16.h
1.27 + @publishedAll
1.28 + @released
1.29 +*/
1.30 +
1.31 +#ifndef __DELIMITEDPARSER16_H__
1.32 +#define __DELIMITEDPARSER16_H__
1.33 +
1.34 +// System includes
1.35 +//
1.36 +#include <e32base.h>
1.37 +#include <delimitedparsercommon.h>
1.38 +
1.39 +
1.40 +/**
1.41 +Comments : Provides non-modifying functionality for parsing data delimited by
1.42 +a single character. The data is delimited into segments. Uses 16-bit descriptors.
1.43 +
1.44 +The object contains a descriptor with the data which can be parsed from left
1.45 +to right, or right to left. It is non-owning. The current segment can be extracted,
1.46 +which then parses the string for the next segment.
1.47 +
1.48 +This is a base class and an object of this type cannot be instantiated. It should
1.49 +be derived. The derived class should ensure that the data iDataDes is set before
1.50 +calling one of the protected parsing functions. The derived class should also ensure
1.51 +that the delimiting character has been set.
1.52 +
1.53 +If the data iDataDes has not been parsed, then calling any functionality that
1.54 +requires the data to have been parsed will result in a panic
1.55 +KDelimitedParserErrNotParsed. The data can only be parsed by calling one of the
1.56 +protected parsing functions from the derived class.
1.57 +
1.58 +If the delimiting character iDelimiter has not been set, then calling the protected
1.59 +parsing functions and some of the other public functionality that requires the
1.60 +delimiter to be set will result in a panic KDelimitingParserErrNoDelimiter.
1.61 +@publishedAll
1.62 +@released
1.63 +@since 6.0
1.64 +*/
1.65 +class TDelimitedParserBase16
1.66 + {
1.67 +public: // Methods
1.68 +
1.69 + IMPORT_C void Reset() const;
1.70 +
1.71 + IMPORT_C TInt GetNext(TPtrC16& aSegment) const;
1.72 +
1.73 + IMPORT_C TInt Inc() const;
1.74 +
1.75 + IMPORT_C TInt Dec() const;
1.76 +
1.77 + IMPORT_C TInt Peek(TPtrC16& aSegment) const;
1.78 +
1.79 + IMPORT_C TBool Eos() const;
1.80 +
1.81 + IMPORT_C TBool FrontDelimiter() const;
1.82 +
1.83 + IMPORT_C TBool BackDelimiter() const;
1.84 +
1.85 + IMPORT_C const TDesC16& Des() const;
1.86 +
1.87 + IMPORT_C TInt Remainder(TPtrC16& aRemainder) const;
1.88 +
1.89 +protected: // Methods
1.90 +
1.91 + IMPORT_C TDelimitedParserBase16();
1.92 +
1.93 + IMPORT_C void Parse(const TDesC16& aData);
1.94 +
1.95 + IMPORT_C void ParseReverse(const TDesC16& aData);
1.96 +
1.97 + IMPORT_C void SetDelimiter(TChar aDelimiter);
1.98 +
1.99 +private: // Methods
1.100 +
1.101 + void DoParse(const TDesC16& aData);
1.102 +
1.103 + TInt FindNextSegment(TInt aStartPos) const;
1.104 +
1.105 + TInt FindPrevSegment(TInt aStartPos) const;
1.106 +
1.107 +private: // Attributes
1.108 +
1.109 + /** Descriptor with the string
1.110 + */
1.111 + TPtrC16 iDataDes;
1.112 +
1.113 + /** Descriptor with the current segment.
1.114 + */
1.115 + mutable TPtrC16 iCurrentSegment;
1.116 +
1.117 + /** Position of next segment.
1.118 + */
1.119 + mutable TInt iNextSegmentPos;
1.120 +
1.121 + /** Direction of parsing.
1.122 + */
1.123 + TDelimitedDataParseMode iMode;
1.124 +
1.125 + /** Delimiting character
1.126 + */
1.127 + TInt iDelimiter;
1.128 +
1.129 +/**
1.130 + A friend class.
1.131 + @see CDelimitedDataBase16
1.132 + @since 6.0
1.133 + */
1.134 + friend class CDelimitedDataBase16;
1.135 +
1.136 + };
1.137 +
1.138 +/**
1.139 +typedef
1.140 +@publishedAll
1.141 +@released
1.142 +*/
1.143 +typedef TDelimitedParserBase16 TDelimitedParserBase;
1.144 +
1.145 +/**
1.146 +Dependencies : CBase, TDelimitedParserBase16
1.147 +Comments : Provides functionality for creating and editing a delimited data object.
1.148 +Uses 16-bit descriptors
1.149 +
1.150 +The object contains a descriptor buffer with the data. Functionality is provided
1.151 +to allow segments to be added or removed from the data. There is access to the
1.152 +internal delimited data parser to provide parsing functionality to be excercised
1.153 +on the created data.
1.154 +
1.155 +This a base class that cannot be instantiated. It should be derived. The derived
1.156 +class must set the delimited data parser, which is an object derived from
1.157 +TDelimitedParserBase. This helper class must set the delimiting object
1.158 +
1.159 +If the delimiting character has not been set, then calling any of the functionality
1.160 +will cause a panic KDelimitedParserErrNoDelimiter.
1.161 +@publishedAll
1.162 +@released
1.163 +@since 6.0
1.164 +*/
1.165 +class CDelimitedDataBase16 : public CBase
1.166 + {
1.167 +public: // Methods
1.168 +
1.169 +
1.170 + IMPORT_C ~CDelimitedDataBase16();
1.171 +
1.172 + IMPORT_C void InsertCurrentL(const TDesC16& aSegment);
1.173 +
1.174 + IMPORT_C void RemoveCurrentL();
1.175 +
1.176 + IMPORT_C void PushBackL(const TDesC16& aSegment);
1.177 +
1.178 + IMPORT_C void PopBackL();
1.179 +
1.180 + IMPORT_C void PushFrontL(const TDesC16& aSegment);
1.181 +
1.182 + IMPORT_C void PopFrontL();
1.183 +
1.184 + IMPORT_C void TrimFrontDelimiterL();
1.185 +
1.186 + IMPORT_C void AddFrontDelimiterL();
1.187 +
1.188 + IMPORT_C void TrimBackDelimiterL();
1.189 +
1.190 + IMPORT_C void AddBackDelimiterL();
1.191 +
1.192 + IMPORT_C void Parse();
1.193 +
1.194 + IMPORT_C void ParseReverse();
1.195 +
1.196 + IMPORT_C const TDelimitedParserBase16& Parser() const;
1.197 +
1.198 +protected: // Methods
1.199 +
1.200 + IMPORT_C CDelimitedDataBase16();
1.201 +
1.202 + IMPORT_C void ConstructL(const TDesC16& aData);
1.203 +
1.204 + IMPORT_C void SetDelimiter(TChar aDelimiter);
1.205 +
1.206 +private: // Methods
1.207 +
1.208 + void SetDataL(const TDesC16& aData);
1.209 +
1.210 + void SetData(HBufC16* aDataBuf);
1.211 +
1.212 + void DoInsertL(const TDesC16& aSegment);
1.213 +
1.214 + void DoRemoveL();
1.215 +
1.216 +private: // Attributes
1.217 +
1.218 + /** Descriptor buffer.
1.219 + */
1.220 + HBufC16* iDataBuf;
1.221 +
1.222 + /** Parser object
1.223 + */
1.224 + TDelimitedParserBase16 iParser;
1.225 +
1.226 + };
1.227 +
1.228 +/**
1.229 +typedef
1.230 +@publishedAll
1.231 +@released
1.232 +*/
1.233 +typedef CDelimitedDataBase16 CDelimitedDataBase;
1.234 +
1.235 +#endif // __DELIMITEDPARSER16_H__