This tutorials describe the steps to extract URI components.
URI components can be extracted from an URI using TUriC8::Extract() and passing a TUriComponent flag. For example, EUriQuery or EUriPath .
The following code fragment illustrates how to extract a scheme component. Parse the URI before the component is extracted calling TUriParser8::Parse() .
_LIT8( KUri,"http://web.intra/Dev/Sysdoc/devlib.htm" ); TUriParser8 parser; // URI parser object TInt result = parser.Parse( KUri ); // parse the URI descriptor //Extract the scheme component from the parsed URI const TDesC8& des = parser.Extract( EUriScheme );
where des is a descriptor that contains the extracted scheme component. Other components such as userinfo, host, port and so on defined in TUriComponent can be extracted in a similar way.
To retrieve a specific authority component from the URI, call TAuthority8::Extract() . The following code fragment illustrates how to extract a authority component.
_LIT8( KAuthorityDesc, "http://user:email@example.com" ); TAuthorityParser8 authorityParser; //Authority parser object authorityParser.Parse( KAuthorityDesc ); //Parse the authority descriptor //extract the user infomation from the authority component const TDesC8& des = authorityParser.Extract( EAuthorityUserinfo );
where, des contains the user info that is extracted from the authority component. EAuthorityUserinfo is an enum value of TAuthorityComponent . Similarly, host and port can be extracted using EAuthorityHost and EAuthorityPort respectively, which are defined in TAuthorityComponent .
To create a new descriptor containing the desired component or the full URI, call TUriC8::DisplayFormL() .
This converts a component into a new descriptor. The component to be converted can take any value between EUriScheme and EUriFragment or EUriComplete (for the full URI). This method is used to obtain a pointer to a 16 bit descriptor for GUI display of URI.
where EUriComplete indicates that all the components in the URI are displayed.
To create a new descriptor containing a specific component or the full authority component, call TAuthority8::DisplayFormL() .
This converts a component into a new descriptor. The component to be converted can take any value between EAuthorityUserinfo and EAuthorityPort or the full authority, EAuthorityComplete .
where EAuthorityComplete means that the complete authority is displayed.
For related information, see:
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.