servicediscoveryandcontrol/pnp/test/upnp/upnpmessage/inc/CHeaderField.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Declaration of CHeaderField, CHeaderFieldPart, THeaderFieldPartIter, CHeaderFieldParam,
       
    15 // and THeaderFieldParamIter classes.
       
    16 // 
       
    17 //
       
    18 
       
    19 #ifndef __CHEADERFIELD_H__
       
    20 #define __CHEADERFIELD_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <http/thttphdrval.h>
       
    24 #include "rhttpheaders.h"
       
    25 
       
    26 
       
    27 
       
    28 // The default chunk size for Raw data should be set to the average length of a header field when encoded in
       
    29 // plaintext
       
    30 const TInt KHttpDefaultRawChunkSize= 32;
       
    31 
       
    32 
       
    33 class CHeaders;
       
    34 class CHeaderFieldPart;
       
    35 class THeaderFieldPartIter;
       
    36 class CHeaderFieldParam;
       
    37 class THeaderFieldParamIter;
       
    38 class CHeaderCodec;
       
    39 
       
    40 
       
    41 /** Generalised internal representation of a single HTTP header field.  The field's
       
    42 	value may be contained as raw data as received by HTTP, or
       
    43 	in a object-oriented parsed form, which is accessible to the client via
       
    44 	the class API.
       
    45 
       
    46 	Each field has a type and a (potentially complex) value.  The type must
       
    47 	be chosen at construction time, and remains the same during the
       
    48 	header's lifetime.
       
    49 
       
    50 	Simple headers are represented using a single 'part'.  Several factory
       
    51 	methods are provided for each type the part can take; e.g.
       
    52 	
       
    53 	@verbatim
       
    54 	Max-Forwards: 3							-- a single integer value
       
    55 	Location: http://ayg.com/				-- a single string token value
       
    56 	Expires: Mon, 15 Jan 2001 10:30:25 GMT	-- a single date/time value
       
    57 	@endverbatim
       
    58 	
       
    59 	More complex headers are possible (see the RFC2116 for many more examples)
       
    60 	which are built up from several parts; e.g.
       
    61 	
       
    62 	@verbatim
       
    63 	Accept: text/wml, application/vnd.wap.wmlc	-- a header with two string token parts
       
    64 	Allow: GET, POST, HEAD						-- a header with three string token parts
       
    65 	@endverbatim
       
    66 	
       
    67 	Multiple parts are supported by the CHeaderFieldPart class.
       
    68 
       
    69 	Furthermore, some headers allow parameters to be supplied in the form of attribute-value
       
    70 	pairs.   These may be present on any part of the header, according to the syntax defined
       
    71 	in the RFC; e.g.
       
    72 	
       
    73 	@verbatim
       
    74 	Accept-Charset: utf-8; q=0.8, us-ascii; q=0.2
       
    75 	Cache-Control: maxage=6000
       
    76 	@endverbatim
       
    77 	
       
    78 	Parameters are supported by the CHeaderFieldParam class.	
       
    79 
       
    80     The classes CHeaderField, CHeaderFieldPart and CHeaderFieldParam are internal header representations
       
    81 	and will only be manipulated by protocol handlers and filters.  Only the RHTTPHeaders and THTTPHdrVal
       
    82 	classes are intended for use by the Client.
       
    83 	@see RHTTPHeaders
       
    84 	@see THTTPHdrVal
       
    85 	@see CHeaderFieldPart
       
    86 	@see CHeaderFieldParam
       
    87 	*/
       
    88 
       
    89 class CHeaderField : public CBase
       
    90 	{
       
    91 friend class THeaderFieldPartIter;
       
    92 friend class RHeaderField;
       
    93 public:
       
    94 	//
       
    95 	// Getters
       
    96 	//
       
    97 
       
    98 	/** Obtain the name of the header field, e.g. Accept
       
    99 		@return The header field name as a string token
       
   100 	*/
       
   101 	RStringF Name() const;
       
   102 
       
   103 	/** Access the header value parts via an iterator
       
   104 		@return An iterator constructed to point at the first part
       
   105 		@leave KErrNoMemory - insufficient free memory for object creation when decoding parts
       
   106 		@leave KErrNotSupported - if decoding when counting parts fails
       
   107 	*/
       
   108 	THeaderFieldPartIter PartsL();
       
   109 
       
   110 	/** Get the Raw header representation.  This will flip the internal state of the header,
       
   111 		if it's not already in Raw form. Requires a Codec to be set.
       
   112 		@param The 8-bit data buffer representing the header in Raw form
       
   113 		@leave KErrNoMemory - insufficient free memory for object creation when decoding parts
       
   114 		@leave KErrNotSupported - if decoding when counting parts fails
       
   115 	*/
       
   116 	IMPORT_C
       
   117 	void RawDataL(TPtrC8& aRawData);
       
   118 
       
   119 	//
       
   120 	// Setters
       
   121 	//
       
   122 
       
   123 	/** Set a part in the header. It replaces any existing parts at the specified index.
       
   124 		Note this is for use only by the header codec, when converting Raw data into parsed header parts from parsed Raw data.
       
   125 		This function may leave with any of the system wide error codes, if the attempt to append this part to the internal list
       
   126 		fails.
       
   127 		@param aPart The part to be added.  The header takes ownership of the new part.
       
   128 		@param aIndex The index of the part you are replacing
       
   129 	*/
       
   130 	//void SetPartL(CHeaderFieldPart* aPart, TInt aIndex);
       
   131 
       
   132 	/** Start setting Raw data in the header.  Leaves if initial Raw buffer allocation fails. The
       
   133 		optional parameter specifies the size to be used for Raw data chunk allocation.
       
   134 		Note this is for use only by the header codec. 
       
   135 		@leave KErrNoMemory - insufficient free memory buffer allocation
       
   136 	*/
       
   137 	void BeginRawDataL(TInt aChunkSize = KHttpDefaultRawChunkSize);
       
   138 
       
   139 	/** Add more Raw data, supplied as a descriptor.  The buffer is extended as necessary.
       
   140 		Leaves if buffer allocation fails.
       
   141 		Note this is for use only by the header codec. 
       
   142 		@leave KErrNoMemory - insufficient free memory buffer allocation
       
   143 	*/
       
   144 	void WriteRawDataL(const TDesC8& aData);
       
   145 
       
   146 	/** Add more Raw data, supplied as a single character.  The buffer is extended as necessary.
       
   147 		Leaves if buffer allocation fails.
       
   148 		Note this is for use only by the header codec. 
       
   149 		@leave KErrNoMemory - insufficient free memory buffer allocation
       
   150 	*/
       
   151 	//void WriteRawDataL(TChar aData);
       
   152 
       
   153 	/** Commit the Raw data.  The parsed header parts and parameters are removed.
       
   154 		Note this is for use only by the header codec.
       
   155 	*/
       
   156 	void CommitRawData();
       
   157 
       
   158 
       
   159 
       
   160 	/** Obtain the number of parts in this header
       
   161 		@return The number, as an integer
       
   162 		@leave KErrNoMemory - insufficient free memory for object creation when decoding parts
       
   163 		@leave KErrNotSupported - if decoding when counting parts fails
       
   164 	*/
       
   165 	TInt NumPartsL();
       
   166 
       
   167 
       
   168 	/** Create a new header field that has no value yet.
       
   169 		@param aHeaderFieldName The header field type.
       
   170 		@param aOwner The header fields collection that this field belongs to
       
   171 		@leave KErrNoMemory - insufficient free memory to create an instance of the class.
       
   172 	*/
       
   173 	static CHeaderField* NewL(RStringF aHeaderFieldName, CHeaders& aOwner);
       
   174 
       
   175 	/** Create a new header field with a single part, whose HTTP value is specified.
       
   176 		@param aHeaderFieldName The header field type.
       
   177 		@param aOwner The header fields collection that this field belongs to
       
   178 		@param aVal The header field value. A copy is taken when storing.
       
   179 		@leave KErrNoMemory - insufficient free memory to create an instance of the class, or any classes needed to create subclasses for parsing
       
   180 		@leave KErrNotSupported - if decoding for this header field can't be made
       
   181 	*/
       
   182 	static CHeaderField* NewL(RStringF aHeaderFieldName, CHeaders& aOwner, THTTPHdrVal aVal);
       
   183 
       
   184 	/** Create a new header field from the supplied Raw data using the specified transaction codec.
       
   185 		@param aHeaderFieldName The header field type.
       
   186 		@param aOwner The header fields collection that this field belongs to
       
   187 		@param aRawData The raw data buffer, as a descriptor
       
   188 		@leave KErrNoMemory - insufficient free memory to create an instance of the class, or any classes needed to create subclasses for parsing
       
   189 		@leave KErrNotSupported - if decoding for this header field can't be made
       
   190 	*/
       
   191 	static CHeaderField* NewL(RStringF aHeaderFieldName, CHeaders& aOwner, const TDesC8& aRawData);
       
   192 
       
   193 	// Class destructor
       
   194 	virtual ~CHeaderField();
       
   195 	/** Access the header value parts by index
       
   196 		@param aIndex The index of the desired part. 0 references the first one.
       
   197 		@return The indexed part, or NULL if the index was invalid.
       
   198 		@leave KErrNoMemory - insufficient free memory for object creation when decoding parts
       
   199 		@leave KErrNotSupported - if decoding when counting parts fails
       
   200 	*/
       
   201 	CHeaderFieldPart* PartL(TInt aIndex);
       
   202 
       
   203 
       
   204 	/** Add a part to the header. It is appended after any existing parts. Simple headers
       
   205 		have just one part;  they could be constructed using the 'single part' NewL() methods.
       
   206 		@param aPart The part to be added.  The header takes ownership of the new part.
       
   207 		@leave KErrNoMemory - insufficient free memory to create an instance of the class, or any classes needed to create subclasses for parsing
       
   208 		@leave KErrNotSupported - if decoding for this header field can't be made
       
   209 	*/
       
   210 	void AddPartL(CHeaderFieldPart* aPart);
       
   211 
       
   212 	/** Insert a part into the header. It is inserted at the specified index - i.e. to insert
       
   213 		a new part at the start of the header, aIndex should be set to 0.
       
   214 		@param aPart The part to be inserted.  The header takes ownership of the new part.
       
   215 		@param aIndex The index at which the part is to be inserted.
       
   216 		@leave KErrNoMemory - insufficient free memory to create an instance of the class, or any classes needed to create subclasses for parsing
       
   217 		@leave KErrNotSupported - if decoding for this header field can't be made
       
   218 	*/
       
   219 	//void InsertPartL(CHeaderFieldPart* aPart, TInt aIndex);
       
   220 
       
   221 	
       
   222 	/** Remove the specified part from the header.
       
   223 		@param aPart The part to be removed.  The header deletes the removed part.
       
   224 		@return An error code; KErrNone if the removal succeeds or KErrNotFound if it didn't.
       
   225 		@leave KErrNoMemory - insufficient free memory to create an instance of the class, or any classes needed to create subclasses for parsing
       
   226 		@leave KErrNotSupported - if decoding for this header field can't be made
       
   227 	*/
       
   228 	//TInt RemovePartL(CHeaderFieldPart* aPart);
       
   229 
       
   230 
       
   231 	/** Remove the indexed part from the header
       
   232 		@param aIndex An index to the part to be removed.  The header deletes the removed part.
       
   233 		@return An error code; KErrNone if the removal succeeds or KErrNotFound if it didn't.
       
   234 		@leave KErrNoMemory - insufficient free memory to create an instance of the class, or any classes needed to create subclasses for parsing
       
   235 		@leave KErrNotSupported - if decoding for this header field can't be made
       
   236 	*/
       
   237 	TInt RemovePartL(TInt aIndex);
       
   238 private: // methods
       
   239 
       
   240 	//
       
   241 	// Internal format conversion
       
   242 	//
       
   243 
       
   244 	/** Create an Raw encoding of the header's field name and value. This is done
       
   245 		using the Codec, which must be supplied prior to this call.	The part data is removed
       
   246 		after conversion to the Raw format.
       
   247 		@leave KErrNotSupported if a codec that supports encoding this header cannot be found
       
   248 	*/
       
   249 	void ConvertToRawFormatL();
       
   250 
       
   251 	/** Create the part objects that represent the header field's value, by parsing the 
       
   252 		Raw data received by HTTP.  The Raw data is removed after conversion completes
       
   253 		successfully.
       
   254 		@leave KErrNotSupported if a codec that supports encoding this header cannot be found
       
   255 	*/
       
   256 	void ConvertToParsedFormatL();	
       
   257 
       
   258 	/** Standard constructor.  Used when client constructs headers.
       
   259 		@param aHeaderFieldName A string table reference to the header field's name.
       
   260 		@param aOwner The header fields collection that this field belongs to
       
   261 		@return The constructed instance of CHeaderField
       
   262 	*/
       
   263 	CHeaderField(RStringF aHeaderFieldName, CHeaders& aOwner);
       
   264 
       
   265 	/** Phase Two construction. This variant copies-to-keep the supplied Raw data buffer.
       
   266 		@param aRawData An 8-bit buffer containing raw header data received by HTTP.
       
   267 	*/
       
   268 	void ConstructL(const TDesC8& aRawData);
       
   269 
       
   270 	// Empty and destroy contents of the 'parts' array.
       
   271 	void ClearParsedData();
       
   272 
       
   273 	// Empty and destroy any Raw data held
       
   274 	void ClearRawData();
       
   275 
       
   276 private: // types and enums
       
   277 
       
   278 	/** Enumeration of the states in which this header's value data can exist.
       
   279 	*/
       
   280 	enum TDataState
       
   281 		{
       
   282 		ENoDataSupplied	= 0x00, /**< the header object is not populated with data after construction*/
       
   283 		EDataInRawForm	= 0x01, /**< the data is in it's raw form, i.e. not accessible by part*/
       
   284 		EDataParsedOK	= 0x02, /**< the data is in it's client representation, i.e. parsed into parts.	*/
       
   285 		EDataParseError	= 0x03  /**< the data could not be parsed so remains in Raw form*/
       
   286 		};
       
   287 
       
   288 private: // attributes
       
   289 
       
   290 	/**  Name of this header (a reference into the string table) 
       
   291 	*/
       
   292 	RStringF iName;
       
   293 
       
   294 	/** Has this header been parsed yet? did it parse correctly?
       
   295 	*/
       
   296 	TDataState iDataParseState;
       
   297 
       
   298 	/**  Headers collection that owns this field
       
   299 	*/
       
   300 	CHeaders* iOwner;
       
   301 
       
   302 	/** Header data - in Raw format.
       
   303 	*/
       
   304 	HBufC8* iRawData;
       
   305 
       
   306 	/** Header data - in parsed format.
       
   307 	*/
       
   308 	RPointerArray<CHeaderFieldPart> iParts;
       
   309 	
       
   310 	/** Codec used to convert this header
       
   311 	*/
       
   312 	const CHeaderCodec& iCodec;
       
   313 
       
   314 	/** Size of data chunk used when allocating and extending the Raw data buffer
       
   315 	*/
       
   316 	TInt iRawChunkSize;
       
   317 	};
       
   318 
       
   319 
       
   320 
       
   321 
       
   322 /** Generalised representation of a single HTTP header value part.  The part takes a
       
   323 	value of one of the following three types:
       
   324 
       
   325 	- integer, signed (i.e. can be -ve or +ve)
       
   326 	- string token, which can represent free text (i.e. text with no special meaning; ETags; MD5 hashes;
       
   327 	  MIME types, etc.), enumerations (words with special meanings such as 'private', 'close', ') or URLs
       
   328 	- Date/Time
       
   329 
       
   330 	In addition the part may have one or more parameters.  These take the form of
       
   331 	attribute-value pairs.  They are implemented by the CHeaderFieldParam class.
       
   332 */
       
   333 class CHeaderFieldPart : public CBase
       
   334 	{
       
   335 friend class THeaderFieldParamIter;
       
   336 
       
   337 public:
       
   338 	/** Create a new part, for the supplied HTTP value 
       
   339 		@param aVal The HTTP value for this part of the header field. A copy is taken when storing.
       
   340 		@return The constructed instance of CHeaderFieldPart.
       
   341 	*/
       
   342 	IMPORT_C
       
   343 	static CHeaderFieldPart* NewL(THTTPHdrVal aVal);
       
   344 
       
   345 	// Class destructor
       
   346 	virtual ~CHeaderFieldPart();
       
   347 
       
   348 	//
       
   349 	// Getters
       
   350 	//
       
   351 
       
   352 	/** Obtain the value held in this field part.  The caller must call Copy() on the returned THTTPHdrVal
       
   353 		if it is going to be stored.  This is needed in order to correctly maintain string references.
       
   354 		@return The field part's HTTP value
       
   355 	*/
       
   356 	IMPORT_C
       
   357 	THTTPHdrVal Value() const;
       
   358 
       
   359 	/** Obtain the number of parameters in this header
       
   360 		@return The number, as an integer
       
   361 	*/ 
       
   362 	IMPORT_C
       
   363 	TInt NumParameters() const;
       
   364 
       
   365 	/** Access the parameters in this header part via an iterator
       
   366 		@return An iterator constructed to point at the first parameter
       
   367 	*/
       
   368 	IMPORT_C
       
   369 	THeaderFieldParamIter Parameters() const;
       
   370 
       
   371 	/** Access the header parameters by index
       
   372 		@param aIndex The index of the desired parameter. 0 references the first one.
       
   373 		@return The indexed parameter, or NULL if the index was invalid.
       
   374 	*/
       
   375 	//CHeaderFieldParam* Parameter(TInt aIndex) const;
       
   376 
       
   377 	/** Access the header parameters by parameter name
       
   378 		@param aParamName The name of the desired part.
       
   379 		@return The named parameter, or NULL if it doesn't exist.
       
   380 	*/
       
   381 	CHeaderFieldParam* Parameter(RStringF aParamName) const;
       
   382 
       
   383 	//
       
   384 	// Setters
       
   385 	//
       
   386 
       
   387 	/** Change the value held in this field part
       
   388 		@param  The HTTP value. It is copied in order to store it.
       
   389 	*/
       
   390 	//void SetValue(THTTPHdrVal aVal);
       
   391 
       
   392 	/** Add a parameter to the header part. It is appended after any existing
       
   393 		parameters.
       
   394 		@param aParam The parameter to be added.  The header takes ownership of the
       
   395 					  new parameter.
       
   396 	*/
       
   397 	IMPORT_C
       
   398 	void AddParamL(CHeaderFieldParam* aParam);
       
   399 
       
   400 	/** Remove the specified parameter from the header part.
       
   401 		@param aParam The parameter to be removed.  The header deletes the removed
       
   402 					  parameter.
       
   403 		@return An error code; KErrNone if the removal succeeds or KErrNotFound if
       
   404 				it didn't.
       
   405 	*/
       
   406 	//TInt RemoveParam(CHeaderFieldParam* aParam);
       
   407 
       
   408 private: // methods
       
   409 
       
   410 	// Default constructor. 
       
   411 	CHeaderFieldPart(THTTPHdrVal aVal);
       
   412 
       
   413 private: // attributes
       
   414 
       
   415 	// The value of this part of the header field
       
   416 	THTTPHdrVal iValue;
       
   417 
       
   418 	// Parameters for this part.
       
   419 	RPointerArray<CHeaderFieldParam> iParams;
       
   420 	};
       
   421 
       
   422 
       
   423 /** Generalised representation of a single HTTP header parameter.  The parameter has
       
   424 	a name and takes a value using one of the three types supported in CHeaderFieldPart.
       
   425 
       
   426 	Special case:
       
   427 	- an unnamed parameter with an assigned value
       
   428 
       
   429 	Examples of the use for this special case are:
       
   430 
       
   431 	@verbatim
       
   432 	Cache-Control: max-stale [=delta-seconds]
       
   433 	Expect: expectation1=value1; expectation2=value2
       
   434 	Content-Range: bytes 0-1023/4096
       
   435 	@endverbatim
       
   436 
       
   437 	Cache-Control's max-stale directive can take an optional value; hence the client
       
   438 	should create a one-part header where the part is an enumeration value 'max-stale',
       
   439 	and assign to that part an un-named parameter for the delta-seconds value if it is
       
   440 	desired.
       
   441 
       
   442 	Expect's sets of expectation expressions should each be added by the client as a
       
   443 	separate part, each of which is given an unnamed parameter that takes the
       
   444 	expectation	value.
       
   445 
       
   446 	Content-Range should have one part added containing the enumeration 'bytes'.  Three
       
   447 	parameters should be defined for that part: 'first', 'last' and 'total' which take
       
   448 	the values in the byte-range.  This is, of course, application-specific and similar
       
   449 	guidelines might be adopted by the parser to represent other headers.
       
   450 	*/
       
   451 
       
   452 class CHeaderFieldParam : public CBase
       
   453 	{
       
   454 public: // methods
       
   455 
       
   456 	/** Create a new header parameter that has a descriptor value. 
       
   457 		@param aParamName The name of the parameter, as a string table
       
   458 						  reference. Can be an empty string.
       
   459 		@param aVal The HTTP value of the parameter. A copy is taken when storing.
       
   460 		@return The constructed instance of CHeaderFieldParam
       
   461 	*/
       
   462 	IMPORT_C
       
   463 	static CHeaderFieldParam* NewL(RStringF aParamName, THTTPHdrVal aVal);
       
   464 
       
   465 	// Class destructor
       
   466 	virtual ~CHeaderFieldParam();
       
   467 
       
   468 	//
       
   469 	// Getters
       
   470 	//
       
   471 
       
   472 	/** Obtain the name of the parameter, e.g. q
       
   473 	    @return String table reference to the name
       
   474 	*/
       
   475 	IMPORT_C
       
   476 	RStringF Name() const;
       
   477 
       
   478 	/** Obtain the value of the parameter.  The caller must call Copy() on the returned THTTPHdrVal
       
   479 		if it is going to be stored.  This is needed in order to correctly maintain string references.
       
   480 		@return The parameter's HTTP value
       
   481 	*/
       
   482 	IMPORT_C
       
   483 	THTTPHdrVal Value() const;
       
   484 
       
   485 	//
       
   486 	// Setters
       
   487 	//
       
   488 
       
   489 	/** Change the value held in this field parameter
       
   490 		@param  The HTTP value
       
   491 	*/
       
   492 	//void SetValue(THTTPHdrVal aVal);
       
   493 
       
   494 private: // methods
       
   495 
       
   496 	/** Default constructor. 
       
   497 	*/
       
   498 	CHeaderFieldParam(RStringF aName, THTTPHdrVal aVal);
       
   499 
       
   500 private: // attributes
       
   501 
       
   502 	// A string table reference for the name of this parameter
       
   503 	RStringF iName;
       
   504 
       
   505 	// The value of this part of the header field
       
   506 	THTTPHdrVal iValue;
       
   507 	};
       
   508 
       
   509 /** Iterator class to iterate the parts contained within a header field. Requires friendship with
       
   510 	CHeaderField and as such is tightly bound to that class.
       
   511 */
       
   512 class THeaderFieldPartIter
       
   513 	{
       
   514 public:
       
   515 	/** Construct an iterator for the parts of the supplied header.
       
   516 		@param aHeader The header whose parts we want to iterate
       
   517 	*/
       
   518 	THeaderFieldPartIter(const CHeaderField* aHeader);
       
   519 	/** Class destructor
       
   520 	*/
       
   521 
       
   522 	/** Reset iterator to point at the first part of the header
       
   523 	*/
       
   524 	IMPORT_C
       
   525 	void First();
       
   526 	/** Check if the iterator is at the end of the list. If so, further calls to
       
   527 	    operator() will return NULL.
       
   528 		@return True if the iterator has hit the end of the parts list
       
   529 	*/
       
   530 	IMPORT_C
       
   531 	TBool AtEnd();
       
   532 
       
   533 	/** Advance the iterator.
       
   534 	*/
       
   535 	IMPORT_C
       
   536 	void operator++();
       
   537 	/** Obtain the header part currently pointed at by the iterator.
       
   538 		@return The header part;  NULL if the iterator has gone off the end of the list
       
   539 	*/
       
   540 	IMPORT_C
       
   541 	const CHeaderFieldPart* operator()();
       
   542 
       
   543 private:
       
   544 
       
   545 	/** Check the iterator state for invalidity following deletions in the list
       
   546 	*/
       
   547 	void CheckInvalidation();
       
   548 
       
   549 	/** The header whose parts we are iterating.
       
   550 	*/
       
   551 	const CHeaderField* iHeader;
       
   552 
       
   553 	/** The index of the part in the header that is currently pointed at by the iterator
       
   554 	*/
       
   555 	TInt iPosIdx;
       
   556 	};
       
   557 
       
   558 /** Iterator class to iterate the parameters contained within a header part. Requires friendship with
       
   559 	CHeaderFieldPart and as such is tightly bound to that class.
       
   560 */
       
   561 class THeaderFieldParamIter
       
   562 	{
       
   563 public:
       
   564 	/** Construct an iterator for the parameterss of the supplied header part.
       
   565 		@param aHeaderPart The header part whose parameters we want to iterate
       
   566 	*/
       
   567 	THeaderFieldParamIter(const CHeaderFieldPart* aHeaderPart);
       
   568 	/** Class destructor
       
   569 	*/
       
   570 	IMPORT_C
       
   571 	~THeaderFieldParamIter();
       
   572 
       
   573 	/** Reset iterator to point at the first part of the header
       
   574 	*/
       
   575 	IMPORT_C
       
   576 	void First();
       
   577 	/** Check if the iterator is at the end of the list. If so, further calls to
       
   578 	    operator() will return NULL.
       
   579 	*/
       
   580 	IMPORT_C
       
   581 	TBool AtEnd();
       
   582 
       
   583 	/** Advance the iterator.
       
   584 		@return True if the iterator still points at a valid parameter after advancing.
       
   585 	*/
       
   586 	IMPORT_C
       
   587 	void operator++();
       
   588 	/** Obtain the header parameter currently pointed at by the iterator.
       
   589 		@return The header parameter;  NULL if the iterator has gone off the end of the list
       
   590 	*/
       
   591 	IMPORT_C
       
   592 	const CHeaderFieldParam* operator()();
       
   593 
       
   594 private:
       
   595 
       
   596 	/** Check the iterator state for invalidity following deletions in the list
       
   597 	*/
       
   598 	void CheckInvalidation();
       
   599 
       
   600 	/** The header part whose parameters we are iterating.
       
   601 	*/
       
   602 	const CHeaderFieldPart* iHeaderPart;
       
   603 	/** The index of the parameter in the header part that is currently pointed at by the iterator
       
   604 	*/
       
   605 	TInt iPosIdx;
       
   606 	};
       
   607 
       
   608 #endif // __CHEADERFIELD_H__