os/ossrv/genericservices/httputils/AuthorityParser/CAuthority.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 "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 //
    15 
    16 #include <authority8.h>
    17 #include <authority16.h>
    18 #include "CAuthorityInternal.h"
    19 #include <uriutilscommon.h>
    20 #include <escapeutils.h>
    21 #include <uriutils.h>
    22 
    23 
    24 //
    25 //
    26 // Implementation of CAuthority8
    27 //
    28 //
    29 
    30 /**
    31 	Static factory constructor. Uses two phase construction and leaves nothing on the 
    32 	CleanupStack. Creates an authority object which is a copy of the input parameter 
    33 	aAuthority.
    34 	
    35 	@since			6.0
    36 	@param			aAuthority	A reference to a parsed authority object.
    37 	@return			A pointer to the newly created CAuthority8 object. 
    38 	@post			A fully constructed and initialized CAuthority8 object.
    39 */
    40 EXPORT_C CAuthority8* CAuthority8::NewL(const TAuthorityC8& aAuthority)
    41 	{
    42 	CAuthority8* self = CAuthority8::NewLC(aAuthority);
    43 	CleanupStack::Pop(self);
    44 	return self;
    45 	}
    46 
    47 /**
    48 	Static factory constructor. Uses two phase construction and leaves a pointer to created 
    49 	object on the CleanupStack. Creates an authority object which is a copy of the input 
    50 	parameter aAuthority.
    51 	
    52 	@since			6.0
    53 	@param			aAuthority	A reference to a parsed authority object.
    54 	@return			A pointer to the newly created CAuthority8 object. 
    55 	@post			A fully constructed and initialized CAuthority8 object.
    56  */
    57 EXPORT_C CAuthority8* CAuthority8::NewLC(const TAuthorityC8& aAuthority)
    58 	{
    59 	CAuthority8* self = new (ELeave) CAuthority8(aAuthority);
    60 	CleanupStack::PushL(self);
    61 	self->ConstructL();
    62 	return self;
    63 	}
    64 
    65 /**
    66 	Static factory constructor. Uses two phase construction and leaves nothing on the CleanupStack. 
    67 	Creates an authority object which is empty.
    68 	
    69 	@since			6.0
    70 	@return			A pointer to the newly created CAuthority8 object. 
    71 	@post			A fully constructed and initialized CAuthority8 object.
    72  */
    73 EXPORT_C CAuthority8* CAuthority8::NewL()
    74 	{
    75 	CAuthority8* self = CAuthority8::NewLC();
    76 	CleanupStack::Pop(self);
    77 	return self;
    78 	}
    79 
    80 /**
    81 	Static factory constructor. Uses two phase construction and leaves a pointer to created object on 
    82 	the CleanupStack. Creates an authority object which is empty.
    83 	
    84 	@since			6.0
    85 	@return			A pointer to the newly created CAuthority8 object. 
    86 	@post			A fully constructed and initialized CAuthority8 object.
    87  */
    88 EXPORT_C CAuthority8* CAuthority8::NewLC()
    89 	{
    90 	CAuthority8* self = new (ELeave) CAuthority8(TAuthorityC8());
    91 	CleanupStack::PushL(self);
    92 	self->ConstructL();
    93 	return self;
    94 	}
    95 
    96 /**
    97 	Destructor.
    98 	
    99 	@since			6.0
   100  */
   101 EXPORT_C CAuthority8::~CAuthority8()
   102 	{
   103 	delete iAuthorityBuf;
   104 	}
   105 
   106 /**
   107 	Provides a reference to the parsed authority. Allows access to the non-modifying API for TAuthorityC8.
   108 	
   109 	@since			6.0
   110 	@return			A const reference to the parsed authority object.
   111  */
   112 EXPORT_C const TAuthorityC8& CAuthority8::Authority() const
   113 	{
   114 	return iAuthority;
   115 	}
   116 
   117 /**
   118 	Sets the specified component in the authority. The component is set to the value given in the argument 
   119 	aData. If the specified component already exists then it is replaced with the new value.
   120 	
   121 	@since			6.0
   122 	@param			aData		A descriptor pointer to the new value for the authority component.
   123 	@param			aComponent	An enum specifying the component to be set.
   124 	@pre 			Object is fully constructed.
   125 	@post			The authority has the specified component set to the new value.
   126 	@Leave          KErrArgument  If aComponent goes out of range.
   127  */
   128 EXPORT_C void CAuthority8::SetComponentL(const TDesC8& aData, TAuthorityComponent aComponent)
   129 	{		
   130 	// Update the appropriate component table entry
   131 	iAuthority.iComponent[aComponent].Set(aData);
   132 
   133 	// Copy to the buffer by forming the Authority
   134 	FormAuthorityL();
   135 	}
   136 
   137 /**
   138 	Escape encodes the component then sets the specified component in the authority. The component is set to the 
   139 	value given in the argument aData. If the specified component already exists then it is replaced with the new 
   140 	value.
   141 	
   142 	@since			6.0
   143 	@param			aData		A descriptor pointer to the new value for the authority component.
   144 	@param			aComponent	An enum specifying the component to be set.
   145 	@pre 			Object is fully constructed.
   146 	@post			The authority has the specified component set to the new value.
   147  */
   148 EXPORT_C void CAuthority8::SetAndEscapeComponentL(const TDesC8& aData, TAuthorityComponent aComponent)
   149 	{
   150 	// Create escaped version of component
   151 	HBufC8* escaped = EscapeUtils::EscapeEncodeL(aData, EscapeUtils::EEscapeAuth);
   152 	CleanupStack::PushL(escaped);
   153 
   154 	// Set the component	
   155 	if(aComponent<EAuthorityMaxComponents && aComponent >=EAuthorityUserinfo )
   156 	   {
   157 	    SetComponentL(*escaped, aComponent);
   158 	   }
   159 	else
   160 	   {
   161 		User::Leave(KErrArgument);	
   162 	   }
   163 
   164 	// Cleanup
   165 	CleanupStack::PopAndDestroy(escaped);
   166 	}
   167 	
   168 /**
   169 	Removes the specified component from the authority. If the component does not exist then this function does 
   170 	nothing.
   171 	
   172 	@since			6.0
   173 	@param			aComponent	An enum specifying the component to be removed.
   174 	@pre 			Object is fully constructed.
   175 	@post			The authority is updated to exclude the specified component.
   176  */
   177 EXPORT_C void CAuthority8::RemoveComponentL(TAuthorityComponent aComponent)
   178 	{
   179 	if( iAuthority.IsPresent(aComponent) )
   180 		{
   181 		// Remove the component - set pointer to NULL and length to zero
   182 		iAuthority.iComponent[aComponent].Set(NULL,0);
   183 
   184 		// Re-form buffer and component table
   185 		FormAuthorityL();
   186 		}
   187 	}
   188 
   189 /**
   190 	Constructor. First phase of two-phase construction method. Does non-allocating construction.
   191 	
   192 	@param			aNewAuthority	The parsed authority component information from which 
   193 	to create the authority.
   194 	@since			6.0
   195  */
   196 CAuthority8::CAuthority8(const TAuthorityC8& aNewAuthority)
   197 : CBase(), iAuthority(aNewAuthority)
   198 	{
   199 	}
   200 
   201 /**
   202 	Second phase of two-phase construction method. Does any allocations required to fully construct 
   203 	the object.
   204 	
   205 	@since			6.0
   206 	@pre 			First phase of construction is complete.
   207 	@post			The object is fully constructed and initialized.
   208  */
   209 void CAuthority8::ConstructL()
   210 	{
   211 	// Create the HBufC8
   212 	FormAuthorityL();
   213 	}
   214 
   215 /**
   216 	Forms the authority from the parsed authority information. A copy of the parsed authority is created. 
   217 	The parsed authority is changed to refer to the copy.
   218 	
   219 	@since			6.0
   220 	@pre 			The parsed authority information is set.
   221 	@post			The authority buffer is a copy of the parsed authority, and the 
   222 	parsed authority now refers to the copy.
   223  */
   224 void CAuthority8::FormAuthorityL()
   225 	{
   226 	TBool isIPv6Host;
   227 
   228 	// Calculate length of of the Authority
   229 	TInt length = CalculateAuthorityLength(iAuthority.iComponent, isIPv6Host);
   230 
   231 	// Create a temporary buffer and descriptor pointer to it
   232 	HBufC8* buf = HBufC8::NewL(length);
   233 	TPtr8 authority = buf->Des();
   234 
   235 	// Create the authority, updating the internal authority object
   236 	DoFormAuthority(authority, iAuthority.iComponent, isIPv6Host);
   237 
   238 	// Update the internal buffer and descriptor pointer for the authority object
   239 	delete iAuthorityBuf;
   240 	iAuthorityBuf = buf;
   241 	iAuthority.iAuthorityDes.Set(iAuthorityBuf->Des());
   242 	}
   243 
   244 //
   245 //
   246 // Implementation of CAuthority16
   247 //
   248 //
   249 
   250 /**
   251 	Static factory constructor. Uses two phase construction and leaves nothing on the CleanupStack. 
   252 	Creates an authority object which is a copy of the input parameter aAuthority.
   253 	
   254 	@since			6.0
   255 	@deprecated 	Deprecated in 9.1
   256 	@param			aAuthority	A reference to a parsed authority object.
   257 	@return			A pointer to the newly created CAuthority16 object. 
   258 	@post			A fully constructed and initialized CAuthority16 object.
   259  */
   260 EXPORT_C CAuthority16* CAuthority16::NewL(const TAuthorityC16& aAuthority)
   261 	{
   262 	CAuthority16* self = CAuthority16::NewLC(aAuthority);
   263 	CleanupStack::Pop(self);
   264 	return self;
   265 	}
   266 
   267 /**
   268 	Static factory constructor. Uses two phase construction and leaves a pointer to created object on 
   269 	the CleanupStack. Creates an authority object which is a copy of the input parameter aAuthority.
   270 	
   271 	@since			6.0
   272 	@deprecated 	Deprecated in 9.1
   273 	@param			aAuthority	A reference to a parsed authority object.
   274 	@return			A pointer to the newly created CAuthority16 object. 
   275 	@post			A fully constructed and initialized CAuthority16 object.
   276  */
   277 EXPORT_C CAuthority16* CAuthority16::NewLC(const TAuthorityC16& aAuthority)
   278 	{
   279 	CAuthority16* self = new (ELeave) CAuthority16(aAuthority);
   280 	CleanupStack::PushL(self);
   281 	self->ConstructL();
   282 	return self;
   283 	}
   284 
   285 /**
   286 	Static factory constructor. Uses two phase construction and leaves nothing on the CleanupStack. 
   287 	Creates an authority object which is empty.
   288 	
   289 	@since			6.0
   290 	@deprecated 	Deprecated in 9.1
   291 	@return			A pointer to the newly created CAuthority16 object. 
   292 	@post			A fully constructed and initialized CAuthority16 object.
   293  */
   294 EXPORT_C CAuthority16* CAuthority16::NewL()
   295 	{
   296 	CAuthority16* self = CAuthority16::NewLC();
   297 	CleanupStack::Pop(self);
   298 	return self;
   299 	}
   300 
   301 /**
   302 	Static factory constructor. Uses two phase construction and leaves a pointer to created object on the 
   303 	CleanupStack. Creates an authority object which is empty.
   304 	
   305 	@since			6.0
   306 	@deprecated 	Deprecated in 9.1
   307 	@return			A pointer to the newly created CAuthority16 object. 
   308 	@post			A fully constructed and initialized CAuthority16 object.
   309  */
   310 EXPORT_C CAuthority16* CAuthority16::NewLC()
   311 	{
   312 	CAuthority16* self = new (ELeave) CAuthority16(TAuthorityC16());
   313 	CleanupStack::PushL(self);
   314 	self->ConstructL();
   315 	return self;
   316 	}
   317 
   318 /**
   319 	Destructor.
   320 	
   321 	@since			6.0
   322 	@deprecated 	Deprecated in 9.1
   323  */
   324 EXPORT_C CAuthority16::~CAuthority16()
   325 	{
   326 	delete iAuthorityBuf;
   327 	}
   328 
   329 /**
   330 	Provides a reference to the parsed authority. Allows access to the non-modifying API for TAuthorityC.
   331 	
   332 	@since			6.0
   333 	@deprecated 	Deprecated in 9.1
   334 	@return			A const reference to the parsed authority object.
   335  */
   336 EXPORT_C const TAuthorityC16& CAuthority16::Authority() const
   337 	{
   338 	return iAuthority;
   339 	}
   340 
   341 /**
   342 	Sets the specified component in the authority. The component is set to the value given in the argument aData. 
   343 	If the specified component already exists then it is replaced with the new value.
   344 	
   345 	@since			6.0
   346 	@deprecated 	Deprecated in 9.1
   347 	@param			aData		A descriptor pointer to the new value for the authority component.
   348 	@param			aComponent	An enum specifying the component to be set.
   349 	@pre 			Object is fully constructed.
   350 	@post			The authority has the specified component set to the new value.
   351 	@Leave          KErrArgument  If aComponent goes out of range.
   352  */
   353 EXPORT_C void CAuthority16::SetComponentL(const TDesC16& aData, TAuthorityComponent aComponent)
   354 	{
   355 	// Update the appropriate component table entry
   356 	iAuthority.iComponent[aComponent].Set(aData);
   357 
   358 	// Copy to the buffer by forming the Authority
   359 	FormAuthorityL();
   360 	}
   361 
   362 /**
   363 	Escape encodes the component then sets the specified component in the authority. The component is set to the 
   364 	value given in the argument aData. If the specified component already exists then it is replaced with the new 
   365 	value.
   366 	
   367 	@since			6.0
   368 	@deprecated 	Deprecated in 9.1
   369 	@param			aData		A descriptor pointer to the new value for the authority component.
   370 	@param			aComponent	An enum specifying the component to be set.
   371 	@pre 			Object is fully constructed.
   372 	@post			The authority has the specified component set to the new value.
   373  */
   374 EXPORT_C void CAuthority16::SetAndEscapeComponentL(const TDesC16& aData, TAuthorityComponent aComponent)
   375 	{
   376 	// Need to convert to utf8 first
   377 	HBufC8* utf8 = EscapeUtils::ConvertFromUnicodeToUtf8L(aData);
   378 	CleanupStack::PushL(utf8);
   379 
   380 	// Create escaped version of component
   381 	HBufC8* escaped = EscapeUtils::EscapeEncodeL(*utf8, EscapeUtils::EEscapeAuth);
   382 	CleanupStack::PushL(escaped);
   383 
   384 	// Convert back to 16-bits
   385 	HBufC16* converted = HBufC16::NewLC(escaped->Length());
   386 	converted->Des().Copy(*escaped);
   387 
   388 	// Set the component
   389 	if(aComponent<EAuthorityMaxComponents && aComponent >=EAuthorityUserinfo )
   390 	   {
   391 		SetComponentL(*converted, aComponent);
   392 	   }
   393     else
   394 	   {
   395 		User::Leave(KErrArgument);	
   396 	   }	
   397 
   398 	// Cleanup
   399 	CleanupStack::PopAndDestroy(3, utf8);	// utf8, escaped, converted
   400 	}
   401 
   402 /**
   403 	Removes the specified component from the authority. If the component does not exist then this 
   404 	function does nothing.
   405 	
   406 	@since			6.0
   407 	@deprecated 	Deprecated in 9.1
   408 	@param			aComponent	An enum specifying the component to be removed.
   409 	@pre 			Object is fully constructed.
   410 	@post			The authority is updated to exclude the specified component.
   411  */
   412 EXPORT_C void CAuthority16::RemoveComponentL(TAuthorityComponent aComponent)
   413 	{
   414 	if( iAuthority.IsPresent(aComponent) )
   415 		{
   416 		// Remove the component - set pointer to NULL and length to zero
   417 		iAuthority.iComponent[aComponent].Set(NULL,0);
   418 
   419 		// Re-form buffer and component table
   420 		FormAuthorityL();
   421 		}
   422 	}
   423 
   424 /**
   425 	Constructor. First phase of two-phase construction method. Does non-allocating construction.
   426 	
   427 	@since			6.0
   428 	@param			aNewAuthority	The parsed authority component information from which 
   429 	to create the authority.
   430  */
   431 CAuthority16::CAuthority16(const TAuthorityC16& aNewAuthority)
   432 : CBase(), iAuthority(aNewAuthority)
   433 	{
   434 	}
   435 
   436 /**
   437 	Second phase of two-phase construction method. Does any allocations required to fully construct 
   438 	the object.
   439 	
   440 	@since			6.0
   441 	@pre 			First phase of construction is complete.
   442 	@post			The object is fully constructed and initialized.
   443  */
   444 void CAuthority16::ConstructL()
   445 	{
   446 	// Create the HBufC16
   447 	FormAuthorityL();
   448 	}
   449 
   450 /**
   451 	Forms the authority from the parsed authority information. A copy of the parsed authority is created.
   452 	The parsed authority is changed to refer to the copy.
   453 	
   454 	@since			6.0
   455 	@pre 			The parsed authority information is set.
   456 	@post			The authority buffer is a copy of the parsed authority, and the 
   457 					parsed authority now refers to the copy.
   458  */
   459 void CAuthority16::FormAuthorityL()
   460 	{
   461 	TBool isIPv6Host;
   462 
   463 	// Calculate length of of the Authority
   464 	TInt length = CalculateAuthorityLength(iAuthority.iComponent, isIPv6Host);
   465 
   466 	// Create a temporary buffer and descriptor pointer to it
   467 	HBufC16* buf = HBufC16::NewL(length);
   468 	TPtr16 authority = buf->Des();
   469 
   470 	// Create the authority, updating the internal authority object
   471 	DoFormAuthority(authority, iAuthority.iComponent, isIPv6Host);
   472 
   473 	// Update the internal buffer and descriptor pointer for the authority object
   474 	delete iAuthorityBuf;
   475 	iAuthorityBuf = buf;
   476 	iAuthority.iAuthorityDes.Set(iAuthorityBuf->Des());
   477 	}
   478 
   479 //
   480 //
   481 // Implementation of templated LOCAL functions
   482 //
   483 //
   484 
   485 /**
   486 	Calculates the length of the authority from a list of the components.
   487 					  
   488 	@since			6.0
   489 	@param			aComponent	The array of descriptor pointers to the authority 
   490 	components.
   491 	@param			aIsIPv6Host	Specifies ETrue or EFalse.
   492 	@return			The length of the authority including the required delimiters.	
   493 */
   494 template<class TPtrCType>
   495 TInt CalculateAuthorityLength(const TPtrCType aComponent[], TBool& aIsIPv6Host)
   496 	{
   497 	aIsIPv6Host = EFalse;
   498 	TInt length=0;
   499 	for( TInt i=0; i<EAuthorityMaxComponents; ++i )
   500 		{
   501 		if( aComponent[i].Ptr() )
   502 			{
   503 			length += aComponent[i].Length();
   504 			// Need to make space for a delimiter if not a host
   505 			if( i != EAuthorityHost )
   506 				++length;
   507 			else
   508 				// Check the host type
   509 				if (UriUtils::HostType(aComponent[i]) == UriUtils::EIPv6Host)
   510 					{
   511 					// If its an IPv6 format host, need to increase the length for the []
   512 					aIsIPv6Host = ETrue;
   513 					length+=2;
   514 					}
   515 			}
   516 		}
   517 	return length;
   518 	}
   519 
   520 /**
   521 	Templated function to form an authority. The new authority component information is given by 
   522 	the input/output argument aComponent. For each authority component that exists in aComponent, 
   523 	that component and its appropriate delimiters are appended to aAuthority. Then the components 
   524 	in aComponent are updated to refer to the copied versions in aUri.
   525 	
   526 	@since			6.0
   527 	@param			aAuthority	The descriptor pointer to buffer to be appended.
   528 	@param			aComponent	The array of descriptor pointers to be copied and 
   529 	then updated.
   530 	@param			aIsIPv6Host	Specifies ETrue or EFalse.
   531 	@pre 			The buffer pointed to by aAuthority should be large enough 
   532 	to have the authority components given in aNewComponent copied into it, as well as 
   533 	the required delimiters.
   534 	@post			The authority buffer will have a copy of the authority defined in
   535 	aNewComponent, and aOldComponent will refer to copies of these components in aAuthority.
   536 */
   537 template<class TPtrType, class TPtrCType>
   538 void DoFormAuthority(TPtrType& aAuthority, TPtrCType aComponent[], const TBool& aIsIPv6Host)
   539 	{
   540 	if( aComponent[EAuthorityUserinfo].Ptr() )
   541 		{
   542 		// Update the userinfo
   543 		SetUserinfo(aAuthority, aComponent[EAuthorityUserinfo]);
   544 		}
   545 	if( aComponent[EAuthorityHost].Ptr() )
   546 		{
   547 		// Update the host
   548 		SetHost(aAuthority, aComponent[EAuthorityHost], aIsIPv6Host);
   549 		}
   550 	if( aComponent[EAuthorityPort].Ptr() )
   551 		{
   552 		// Update the port
   553 		SetPort(aAuthority, aComponent[EAuthorityPort]);
   554 		}
   555 	}
   556 
   557 /**
   558 	Templated function to set the userinfo in an authority. The output argument aAuthority points to 
   559 	the descriptor buffer into which aNewUserInfo will be copied. The argument aOldUserInfo is updated 
   560 	to point to the copied version of aNewUserInfo in aAuthority.
   561 						
   562 	@warning		This function will panic with KAuthorityErrBufferOverflow if there is not
   563 	enough space in the descriptor to append the component and any required delimiters.
   564 	@since			6.0
   565 	@param			aAuthority	The descriptor pointer to buffer to be appended.
   566 	@param			aUserinfo	The descriptor pointer to the userinfo component to be copied 
   567 	and then updated.
   568 	@pre 			The buffer pointed to by aAuthority should be large enough to have 
   569 	aNewUserInfo appended to it with the required delimiter.
   570 	@post			The authority buffer now includes aNewUserInfo and aOldUserInfo points
   571 	to the copy of the userinfo component in aAuthority.
   572 */
   573 template<class TPtrType, class TPtrCType> 
   574 void SetUserinfo(TPtrType& aAuthority, TPtrCType& aUserinfo)
   575 	{
   576 	// Append the userinfo and delimiter
   577 	aAuthority.Append(aUserinfo);
   578 	aAuthority.Append(KUserinfoDelimiter);
   579 
   580 	// Update the component table
   581 	aUserinfo.Set(aAuthority.Left(aUserinfo.Length()));
   582 	}
   583 
   584 /**
   585 	Templated function to set the host in an authority. The output argument aAuthority points to the 
   586 	descriptor buffer into which aNewHost will be copied. The argument aOldHost is updated to point to 
   587 	the copied version of aNewHost in aAuthority.
   588 						
   589 	@warning		This function will panic with KAuthorityErrBufferOverflow if there is not
   590 	enough space in the descriptor to append the component and any required delimiters.
   591 	@since			6.0
   592 	@param			aAuthority	The descriptor pointer to buffer to appended.
   593 	@param			aHost		The descriptor pointer to the host component to be copied 
   594 	and then updated.
   595 	@param			aIsIPv6Host	Specifies ETrue or EFalse.
   596 	@pre 			The buffer pointed to by aAuthority should be large enough to have 
   597 	aNewHost appended to it with the required delimiter.
   598 	@post			The authority buffer now includes aNewHost and aOldHost points to the 
   599 	copy of the host component in aAuthority.
   600 */
   601 template<class TPtrType, class TPtrCType> 
   602 void SetHost(TPtrType& aAuthority, TPtrCType& aHost, const TBool& aIsIPv6Host)
   603 	{
   604 	if (aIsIPv6Host)
   605 		{
   606 		aAuthority.Append(KIPv6UriOpenBrace);
   607 		aAuthority.Append(aHost);
   608 		aAuthority.Append(KIPv6UriCloseBrace);
   609 
   610 		// Position = (length of uri - length of host) - length of end brace
   611 		aHost.Set( aAuthority.Mid((aAuthority.Length()-aHost.Length())-1, aHost.Length()) );
   612 		}
   613 	else
   614 		{
   615 		// Append the host
   616 		aAuthority.Append(aHost);
   617 
   618 		// Update the component table
   619 		aHost.Set(aAuthority.Right(aHost.Length()));
   620 		}
   621 	}
   622 
   623 /**
   624 	Templated function to set the port in an authority. The output argument aAuthority points to the 
   625 	descriptor buffer into which aNewPort will be copied. The argument aOldPort is updated to point to 
   626 	the copied version of aNewPort in aAuthority.
   627 						
   628 	@warning		This function will panic with KAuthorityErrBufferOverflow if there is not
   629 	enough space in the descriptor to append the component and any required delimiters.
   630 	@since			6.0
   631 	@param			aAuthority	The descriptor pointer to buffer to appended.
   632 	@param			aPort		The descriptor pointer to the port component to be copied 
   633 	and then updated.
   634 	@pre 			The buffer pointed to by aAuthority should be large enough to have aNewPort
   635 	appended to it with the required delimiter.
   636 	@post			The authority buffer now includes aNewPort and aOldPort points to the 
   637 	copy of the port component in aAuthority.
   638 */
   639 template<class TPtrType, class TPtrCType> 
   640 void SetPort(TPtrType& aAuthority, TPtrCType& aPort)
   641 	{
   642 	// Append delimiter and the port
   643 	aAuthority.Append(KPortDelimiter);
   644 	aAuthority.Append(aPort);
   645 
   646 	// Update the component table
   647 	aPort.Set(aAuthority.Right(aPort.Length()));
   648 	}