epoc32/include/delimitedparser16.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 delimitedparser16.h
     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 TDelimitedParserBase16
       
    15 // and CDelimitedData16.
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file DelimitedParser16.h
       
    23  @publishedAll
       
    24  @released	
       
    25 */
       
    26 
       
    27 #ifndef __DELIMITEDPARSER16_H__
       
    28 #define __DELIMITEDPARSER16_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 16-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 TDelimitedParserBase16
       
    62 	{
       
    63 public:	// Methods
       
    64 
       
    65 	IMPORT_C void Reset() const;
       
    66 	
       
    67 	IMPORT_C TInt GetNext(TPtrC16& aSegment) const;
       
    68 
       
    69 	IMPORT_C TInt Inc() const;
       
    70 
       
    71 	IMPORT_C TInt Dec() const;
       
    72 
       
    73 	IMPORT_C TInt Peek(TPtrC16& 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 TDesC16& Des() const;
       
    82 
       
    83 	IMPORT_C TInt Remainder(TPtrC16& aRemainder) const;
       
    84 
       
    85 protected:	// Methods
       
    86 
       
    87 	IMPORT_C TDelimitedParserBase16();
       
    88 
       
    89 	IMPORT_C void Parse(const TDesC16& aData);
       
    90 
       
    91 	IMPORT_C void ParseReverse(const TDesC16& aData);
       
    92 
       
    93 	IMPORT_C void SetDelimiter(TChar aDelimiter);
       
    94 
       
    95 private:	// Methods
       
    96 
       
    97 	void DoParse(const TDesC16& 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 	TPtrC16						iDataDes;
       
   108 
       
   109 	/** Descriptor with the current segment.
       
   110 	 */
       
   111 	mutable TPtrC16				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		CDelimitedDataBase16
       
   128 	@since		6.0
       
   129  */
       
   130 	friend class CDelimitedDataBase16;
       
   131 
       
   132 	};
       
   133 
       
   134 /**
       
   135 typedef 
       
   136 @publishedAll
       
   137 @released
       
   138 */
       
   139 typedef TDelimitedParserBase16 TDelimitedParserBase;
       
   140 
       
   141 /**
       
   142 Dependencies : CBase, TDelimitedParserBase16
       
   143 Comments : Provides functionality for creating and editing a delimited data object.
       
   144 Uses 16-bit descriptors
       
   145 
       
   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
       
   149 on the created data.
       
   150 
       
   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
       
   154 
       
   155 If the delimiting character has not been set, then calling any of the functionality
       
   156 will cause a panic KDelimitedParserErrNoDelimiter.
       
   157 @publishedAll
       
   158 @released
       
   159 @since 6.0
       
   160 */
       
   161 class CDelimitedDataBase16 : public CBase
       
   162 	{
       
   163 public: // Methods
       
   164 
       
   165 
       
   166 	IMPORT_C ~CDelimitedDataBase16();
       
   167 
       
   168 	IMPORT_C void InsertCurrentL(const TDesC16& aSegment);
       
   169 
       
   170 	IMPORT_C void RemoveCurrentL();
       
   171 
       
   172 	IMPORT_C void PushBackL(const TDesC16& aSegment);
       
   173 
       
   174 	IMPORT_C void PopBackL();
       
   175 
       
   176 	IMPORT_C void PushFrontL(const TDesC16& aSegment);
       
   177 
       
   178 	IMPORT_C void PopFrontL();
       
   179 
       
   180 	IMPORT_C void TrimFrontDelimiterL();
       
   181 
       
   182 	IMPORT_C void AddFrontDelimiterL();
       
   183 
       
   184 	IMPORT_C void TrimBackDelimiterL();
       
   185 
       
   186 	IMPORT_C void AddBackDelimiterL();
       
   187 
       
   188 	IMPORT_C void Parse();
       
   189 
       
   190 	IMPORT_C void ParseReverse();
       
   191 
       
   192 	IMPORT_C const TDelimitedParserBase16& Parser() const;
       
   193 
       
   194 protected:	// Methods
       
   195 
       
   196 	IMPORT_C CDelimitedDataBase16();
       
   197 
       
   198 	IMPORT_C void ConstructL(const TDesC16& aData);
       
   199 
       
   200 	IMPORT_C void SetDelimiter(TChar aDelimiter);
       
   201 
       
   202 private:	// Methods
       
   203 
       
   204 	void SetDataL(const TDesC16& aData);
       
   205 
       
   206 	void SetData(HBufC16* aDataBuf);
       
   207 
       
   208 	void DoInsertL(const TDesC16& aSegment);
       
   209 
       
   210 	void DoRemoveL();
       
   211 
       
   212 private:	// Attributes
       
   213 
       
   214 	/** Descriptor buffer.
       
   215 	 */
       
   216 	HBufC16*				iDataBuf;
       
   217 
       
   218 	/** Parser object
       
   219 	 */
       
   220 	TDelimitedParserBase16	iParser;
       
   221 
       
   222 	};
       
   223 
       
   224 /**
       
   225 typedef 
       
   226 @publishedAll
       
   227 @released
       
   228 */
       
   229 typedef CDelimitedDataBase16 CDelimitedDataBase;
       
   230 
       
   231 #endif	// __DELIMITEDPARSER16_H__