Symbian3/SDK/Source/GUID-D535D51E-EAF5-581A-929B-5B1EF179A273.dita
changeset 7 51a74ef9ed63
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-D535D51E-EAF5-581A-929B-5B1EF179A273" xml:lang="en"><title>Parsing
       
    13 an URI</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>This tutorial describes the steps to parse an URI. </p>
       
    15 <section><title>Introduction </title> <p>Parsing is done before performing
       
    16 any of the following tasks: </p> <ul>
       
    17 <li id="GUID-9A1003CA-B215-5AC6-BEE5-8A2803260219"><p>Extracting the URI components </p> </li>
       
    18 <li id="GUID-E8705543-F900-5EA7-8CDF-683A03F9D83A"><p>Modifying the URI components </p> </li>
       
    19 <li id="GUID-D89056C6-2F34-5F80-8C8D-26F215362DCD"><p>Getting the file name </p> </li>
       
    20 <li id="GUID-0E42A1EE-C99E-594C-BB80-A1252FA024F1"><p>Modifying the delimiters </p> </li>
       
    21 <li id="GUID-11FCEE3E-753B-5C67-AF99-F51CA7E23E02"><p>Resolving the URI </p> </li>
       
    22 </ul> <p>The URI is parsed into its components (scheme, authority, path, query
       
    23 and fragment) to check if they are syntactically correct. Also, the checks
       
    24 the validity of individual components that needs to be parsed, using <xref href="GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1.dita#GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1/GUID-F72D57B8-DFD4-38B7-A54B-29103540E8AA"><apiname>TUriParser8::Parse()</apiname></xref>. </p> </section>
       
    25 <section><title>Parsing an URI descriptor object</title> <p>The following
       
    26 code fragment parses the URI descriptor object. It returns <codeph>KErrNone</codeph> if
       
    27 parsing is successful and <codeph>EUriUtilsParserErrInvalidUri</codeph> if
       
    28 the passed descriptor is invalid. </p> <codeblock id="GUID-C1B10F10-1D4E-5268-93D4-4C6ECA7C9F7C" xml:space="preserve">
       
    29 LIT8( KUri,"http://web.intra/Dev/Sysdoc/devlib.htm" );
       
    30 TUriParser8 parser;                          // URI parser object
       
    31 TInt result = parser.Parse( KUri );            // Parse the URI descriptor 
       
    32 const TDesC8&amp; des1 = parser.UriDes();        // Returns the parsed URI
       
    33 </codeblock> <p>where, <codeph>KUri</codeph> is the URI descriptor to be parsed.
       
    34 This code returns the descriptor containing <codeph>http://web.intra/Dev/Sysdoc/devlib.htm</codeph>,
       
    35 the parsed form of the URI. </p> <p> <xref href="GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1.dita#GUID-EB2EEEF1-705B-334D-A4B0-3D0C4CBE2DA1/GUID-F72D57B8-DFD4-38B7-A54B-29103540E8AA"><apiname>TUriParser8::Parse()</apiname></xref> parses
       
    36 the URI components, except for SIP and SIPS scheme component. </p> </section>
       
    37 <section><title>Parsing an authority component</title><p>To make use of the
       
    38 authority parsing utilities, declare a <xref href="GUID-985C12CB-9230-3A35-9F5F-E455D4C23EBB.dita"><apiname>TAuthorityParser8</apiname></xref> parser
       
    39 object, and parse the descriptor containing the URI authority component. Call <xref href="GUID-985C12CB-9230-3A35-9F5F-E455D4C23EBB.dita#GUID-985C12CB-9230-3A35-9F5F-E455D4C23EBB/GUID-7CCA2647-E8D0-312B-83BE-BE857FB61D0C"><apiname>TAuthorityParser8::Parse()</apiname></xref> to
       
    40 parse the authority component. </p> <codeblock id="GUID-49539B54-F682-5CDD-BC57-44FAA006E1E9" xml:space="preserve">_LIT8( KAuthorityDesc,    "http://user:pass@www.mypage.com" );
       
    41 TAuthorityParser8 authorityParser;                     // the authority parser object 
       
    42 //Parse the authority component by passing authority descriptor   
       
    43 authorityParser.Parse( KAuthorityDesc );  
       
    44 const TDesC8&amp; des = authorityParser.AuthorityDes();    //retrieve the parsed URI
       
    45 </codeblock> <p>where, <codeph>des</codeph> is a descriptor that contains
       
    46 the parsed URI. </p></section>
       
    47 <section><title> See also</title> <p>For related information, see <xref href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita">HTTP
       
    48 Utilities Library Overview</xref> </p> </section>
       
    49 </conbody></concept>