epoc32/include/delimitedparser8.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // This file contains the API definition for the classes TDelimitedParserBase8
    15 // and CDelimitedData8. 
    16 // 
    17 //
    18 
    19 
    20 
    21 /**
    22  @file DelimitedParser8.h
    23  @publishedAll
    24  @released	
    25 */
    26 
    27 #ifndef __DELIMITEDPARSER8_H__
    28 #define __DELIMITEDPARSER8_H__
    29 
    30 // System includes
    31 //
    32 #include <e32base.h>
    33 #include <delimitedparsercommon.h>
    34 
    35 
    36 /**
    37 Comments : Provides non-modifying functionality for parsing data delimited by 
    38 a single character. The data is delimited into segments. Uses 8-bit descriptors.
    39 
    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.
    43 
    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.
    48 
    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.
    53 
    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.
    57 @publishedAll
    58 @released
    59 @since 6.0
    60 */
    61 class TDelimitedParserBase8
    62 	{
    63 public:	// Methods
    64 
    65 	IMPORT_C void Reset() const;
    66 
    67 	IMPORT_C TInt GetNext(TPtrC8& aSegment) const;
    68 
    69 	IMPORT_C TInt Inc() const;
    70 
    71 	IMPORT_C TInt Dec() const;
    72 
    73 	IMPORT_C TInt Peek(TPtrC8& aSegment) const;
    74 
    75 	IMPORT_C TBool Eos() const;
    76 
    77 	IMPORT_C TBool FrontDelimiter() const;
    78 
    79 	IMPORT_C TBool BackDelimiter() const;
    80 
    81 	IMPORT_C const TDesC8& Des() const;
    82 
    83 	IMPORT_C TInt Remainder(TPtrC8& aRemainder) const;
    84 
    85 protected:	// Methods
    86 
    87 	IMPORT_C TDelimitedParserBase8();
    88 
    89 	IMPORT_C void Parse(const TDesC8& aData);
    90 
    91 	IMPORT_C void ParseReverse(const TDesC8& aData);
    92 
    93 	IMPORT_C void SetDelimiter(TChar aDelimiter);
    94 
    95 private:	// Methods
    96 
    97 	void DoParse(const TDesC8& aData);
    98 
    99 	TInt FindNextSegment(TInt aStartPos) const;
   100 
   101 	TInt FindPrevSegment(TInt aStartPos) const;
   102 
   103 private:	// Attributes
   104 
   105 	/** Descriptor with the string
   106 	 */
   107 	TPtrC8						iDataDes;
   108 
   109 	/** Descriptor with the current segment.
   110 	 */
   111 	mutable TPtrC8				iCurrentSegment;
   112 
   113 	/** Position of next segment.
   114 	 */
   115 	mutable TInt				iNextSegmentPos;
   116 
   117 	/** Direction of parsing.
   118 	 */
   119 	TDelimitedDataParseMode		iMode;
   120 
   121 	/** Delimiting character
   122 	*/
   123 	TInt						iDelimiter;
   124 
   125 /**
   126 	A friend class.
   127 	@see		CDelimitedDataBase8
   128 	@since		6.0
   129  */
   130 	friend class CDelimitedDataBase8;
   131 
   132 	};
   133 
   134 /**
   135 Dependencies : CBase, TDelimitedParserBase8
   136 Comments : Provides functionality for creating and editing a delimited data object.
   137 Uses 8-bit descriptors
   138 
   139 The object contains a descriptor buffer with the data. Functionality is provided 
   140 to allow segments to be added or removed from the data. There is access to the 
   141 internal delimited data parser to provide parsing functionality to be excercised 
   142 on the created data.
   143 
   144 This a base class that cannot be instantiated. It should be derived. The derived 
   145 class must set the delimited data parser, which is an object derived from 
   146 TDelimitedParserBase. This helper class must set the delimiting object
   147 
   148 If the delimiting character has not been set, then calling any of the functionality 
   149 will cause a panic KDelimitedParserErrNoDelimiter.
   150 @publishedAll
   151 @released
   152 @since 6.0
   153 */
   154 class CDelimitedDataBase8 : public CBase
   155 	{
   156 public: // Methods
   157 
   158 	IMPORT_C ~CDelimitedDataBase8();
   159 
   160 	IMPORT_C void InsertCurrentL(const TDesC8& aSegment);
   161 
   162 	IMPORT_C void RemoveCurrentL();
   163 
   164 	IMPORT_C void PushBackL(const TDesC8& aSegment);
   165 
   166 	IMPORT_C void PopBackL();
   167 
   168 	IMPORT_C void PushFrontL(const TDesC8& aSegment);
   169 
   170 	IMPORT_C void PopFrontL();
   171 
   172 	IMPORT_C void TrimFrontDelimiterL();
   173 
   174 	IMPORT_C void AddFrontDelimiterL();
   175 
   176 	IMPORT_C void TrimBackDelimiterL();
   177 
   178 	IMPORT_C void AddBackDelimiterL();
   179 
   180 	IMPORT_C void Parse();
   181 
   182 	IMPORT_C void ParseReverse();
   183 
   184 	IMPORT_C const TDelimitedParserBase8& Parser() const;
   185 
   186 protected:	// Methods
   187 
   188 	IMPORT_C CDelimitedDataBase8();
   189 
   190 	IMPORT_C void ConstructL(const TDesC8& aData);
   191 
   192 	IMPORT_C void SetDelimiter(TChar aDelimiter);
   193 
   194 private:	// Methods
   195 
   196 
   197 	void SetDataL(const TDesC8& aData);
   198 
   199 	void SetData(HBufC8* aDataBuf);
   200 
   201 	void DoInsertL(const TDesC8& aSegment);
   202 
   203 	void DoRemoveL();
   204 
   205 private:	// Attributes
   206 
   207 	/** Descriptor buffer.
   208 	 */
   209 	HBufC8*					iDataBuf;
   210 
   211 	/** Parser object
   212 	 */
   213 	TDelimitedParserBase8	iParser;
   214 
   215 	};
   216 
   217 #endif	// __DELIMITEDPARSER8_H__