williamr@2: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // This file contains the API definition for the classes TDelimitedParserBase16 williamr@2: // and CDelimitedData16. williamr@2: // williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: @file DelimitedParser16.h williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #ifndef __DELIMITEDPARSER16_H__ williamr@2: #define __DELIMITEDPARSER16_H__ williamr@2: williamr@2: // System includes williamr@2: // williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: /** williamr@2: Comments : Provides non-modifying functionality for parsing data delimited by williamr@2: a single character. The data is delimited into segments. Uses 16-bit descriptors. williamr@2: williamr@2: The object contains a descriptor with the data which can be parsed from left williamr@2: to right, or right to left. It is non-owning. The current segment can be extracted, williamr@2: which then parses the string for the next segment. williamr@2: williamr@2: This is a base class and an object of this type cannot be instantiated. It should williamr@2: be derived. The derived class should ensure that the data iDataDes is set before williamr@2: calling one of the protected parsing functions. The derived class should also ensure williamr@2: that the delimiting character has been set. williamr@2: williamr@2: If the data iDataDes has not been parsed, then calling any functionality that williamr@2: requires the data to have been parsed will result in a panic williamr@2: KDelimitedParserErrNotParsed. The data can only be parsed by calling one of the williamr@2: protected parsing functions from the derived class. williamr@2: williamr@2: If the delimiting character iDelimiter has not been set, then calling the protected williamr@2: parsing functions and some of the other public functionality that requires the williamr@2: delimiter to be set will result in a panic KDelimitingParserErrNoDelimiter. williamr@2: @publishedAll williamr@2: @released williamr@2: @since 6.0 williamr@2: */ williamr@2: class TDelimitedParserBase16 williamr@2: { williamr@2: public: // Methods williamr@2: williamr@2: IMPORT_C void Reset() const; williamr@2: williamr@2: IMPORT_C TInt GetNext(TPtrC16& aSegment) const; williamr@2: williamr@2: IMPORT_C TInt Inc() const; williamr@2: williamr@2: IMPORT_C TInt Dec() const; williamr@2: williamr@2: IMPORT_C TInt Peek(TPtrC16& aSegment) const; williamr@2: williamr@2: IMPORT_C TBool Eos() const; williamr@2: williamr@2: IMPORT_C TBool FrontDelimiter() const; williamr@2: williamr@2: IMPORT_C TBool BackDelimiter() const; williamr@2: williamr@2: IMPORT_C const TDesC16& Des() const; williamr@2: williamr@2: IMPORT_C TInt Remainder(TPtrC16& aRemainder) const; williamr@2: williamr@2: protected: // Methods williamr@2: williamr@2: IMPORT_C TDelimitedParserBase16(); williamr@2: williamr@2: IMPORT_C void Parse(const TDesC16& aData); williamr@2: williamr@2: IMPORT_C void ParseReverse(const TDesC16& aData); williamr@2: williamr@2: IMPORT_C void SetDelimiter(TChar aDelimiter); williamr@2: williamr@2: private: // Methods williamr@2: williamr@2: void DoParse(const TDesC16& aData); williamr@2: williamr@2: TInt FindNextSegment(TInt aStartPos) const; williamr@2: williamr@2: TInt FindPrevSegment(TInt aStartPos) const; williamr@2: williamr@2: private: // Attributes williamr@2: williamr@2: /** Descriptor with the string williamr@2: */ williamr@2: TPtrC16 iDataDes; williamr@2: williamr@2: /** Descriptor with the current segment. williamr@2: */ williamr@2: mutable TPtrC16 iCurrentSegment; williamr@2: williamr@2: /** Position of next segment. williamr@2: */ williamr@2: mutable TInt iNextSegmentPos; williamr@2: williamr@2: /** Direction of parsing. williamr@2: */ williamr@2: TDelimitedDataParseMode iMode; williamr@2: williamr@2: /** Delimiting character williamr@2: */ williamr@2: TInt iDelimiter; williamr@2: williamr@2: /** williamr@2: A friend class. williamr@2: @see CDelimitedDataBase16 williamr@2: @since 6.0 williamr@2: */ williamr@2: friend class CDelimitedDataBase16; williamr@2: williamr@2: }; williamr@2: williamr@2: /** williamr@2: typedef williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: typedef TDelimitedParserBase16 TDelimitedParserBase; williamr@2: williamr@2: /** williamr@2: Dependencies : CBase, TDelimitedParserBase16 williamr@2: Comments : Provides functionality for creating and editing a delimited data object. williamr@2: Uses 16-bit descriptors williamr@2: williamr@2: The object contains a descriptor buffer with the data. Functionality is provided williamr@2: to allow segments to be added or removed from the data. There is access to the williamr@2: internal delimited data parser to provide parsing functionality to be excercised williamr@2: on the created data. williamr@2: williamr@2: This a base class that cannot be instantiated. It should be derived. The derived williamr@2: class must set the delimited data parser, which is an object derived from williamr@2: TDelimitedParserBase. This helper class must set the delimiting object williamr@2: williamr@2: If the delimiting character has not been set, then calling any of the functionality williamr@2: will cause a panic KDelimitedParserErrNoDelimiter. williamr@2: @publishedAll williamr@2: @released williamr@2: @since 6.0 williamr@2: */ williamr@2: class CDelimitedDataBase16 : public CBase williamr@2: { williamr@2: public: // Methods williamr@2: williamr@2: williamr@2: IMPORT_C ~CDelimitedDataBase16(); williamr@2: williamr@2: IMPORT_C void InsertCurrentL(const TDesC16& aSegment); williamr@2: williamr@2: IMPORT_C void RemoveCurrentL(); williamr@2: williamr@2: IMPORT_C void PushBackL(const TDesC16& aSegment); williamr@2: williamr@2: IMPORT_C void PopBackL(); williamr@2: williamr@2: IMPORT_C void PushFrontL(const TDesC16& aSegment); williamr@2: williamr@2: IMPORT_C void PopFrontL(); williamr@2: williamr@2: IMPORT_C void TrimFrontDelimiterL(); williamr@2: williamr@2: IMPORT_C void AddFrontDelimiterL(); williamr@2: williamr@2: IMPORT_C void TrimBackDelimiterL(); williamr@2: williamr@2: IMPORT_C void AddBackDelimiterL(); williamr@2: williamr@2: IMPORT_C void Parse(); williamr@2: williamr@2: IMPORT_C void ParseReverse(); williamr@2: williamr@2: IMPORT_C const TDelimitedParserBase16& Parser() const; williamr@2: williamr@2: protected: // Methods williamr@2: williamr@2: IMPORT_C CDelimitedDataBase16(); williamr@2: williamr@2: IMPORT_C void ConstructL(const TDesC16& aData); williamr@2: williamr@2: IMPORT_C void SetDelimiter(TChar aDelimiter); williamr@2: williamr@2: private: // Methods williamr@2: williamr@2: void SetDataL(const TDesC16& aData); williamr@2: williamr@2: void SetData(HBufC16* aDataBuf); williamr@2: williamr@2: void DoInsertL(const TDesC16& aSegment); williamr@2: williamr@2: void DoRemoveL(); williamr@2: williamr@2: private: // Attributes williamr@2: williamr@2: /** Descriptor buffer. williamr@2: */ williamr@2: HBufC16* iDataBuf; williamr@2: williamr@2: /** Parser object williamr@2: */ williamr@2: TDelimitedParserBase16 iParser; williamr@2: williamr@2: }; williamr@2: williamr@2: /** williamr@2: typedef williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: typedef CDelimitedDataBase16 CDelimitedDataBase; williamr@2: williamr@2: #endif // __DELIMITEDPARSER16_H__