Symbian3/PDK/Source/GUID-098106AC-0A5A-5C7D-B432-492EADFE7EA3.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Fri, 22 Jan 2010 18:26:19 +0000
changeset 1 25a17d01db0c
child 3 46218c8b8afa
permissions -rw-r--r--
Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     1
<?xml version="1.0" encoding="utf-8"?>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     2
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     3
<!-- This component and the accompanying materials are made available under the terms of the License 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     4
"Eclipse Public License v1.0" which accompanies this distribution, 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     5
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     6
<!-- Initial Contributors:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     7
    Nokia Corporation - initial contribution.
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     8
Contributors: 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
     9
-->
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    10
<!DOCTYPE concept
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    11
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    12
<concept id="GUID-098106AC-0A5A-5C7D-B432-492EADFE7EA3" xml:lang="en"><title>Manipulating
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    13
URI Data </title><prolog><metadata><keywords/></metadata></prolog><conbody>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    14
<p>This tutorial describes the steps to manipulate the URI data. </p>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    15
<section><title>Introduction</title> <p> <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita"><apiname>InetProtTextUtils</apiname></xref> provides
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    16
various text parsing utilities for manipulating the data in HTTP headers.
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    17
This includes: </p> <ul>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    18
<li id="GUID-81BF0E64-8463-534B-84E3-73BE5A84C195"><p>removing the white space </p> </li>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    19
<li id="GUID-269D1163-D6FB-5A15-AC0F-52D565F40C85"><p>converting the data. </p> </li>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    20
</ul> </section>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    21
<section><title>Removing white spaces</title><p> <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita#GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE/GUID-2315E4AF-99EE-32B4-BA13-79A643F8A929"><apiname>InetProtTextUtils::RemoveWhiteSpace()</apiname></xref> removes
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    22
any contiguous white spaces at either or both the ends of the data, as specified
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    23
by the mode (right, left, or both). A white space includes blank spaces, tabs
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    24
and separators. For example, new line. </p><p>The following code removes the
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    25
white spaces on the left side of the URI. </p><codeblock id="GUID-F07260CB-6C56-53AA-A6A4-6BDB76102253" xml:space="preserve">_LIT( KFullUriPath," P:\\DV3\\gothere\\moveon.htm" ); // URI 
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    26
TPtrC uriName(KFullUriPath);                          //pointer to the URI
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    27
//Remove the white space on the left side of URI
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    28
Tint consumedWhiteSpacesLeft = InetProtTextUtils::RemoveWhiteSpace( uriName, InetProtTextUtils::ERemoveLeft );</codeblock> <p>If
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    29
the white space is removed, it returns <codeph>KErrNone</codeph>, else it
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    30
returns <codeph>KErrNotFound</codeph>. <codeph>ERemoveRight</codeph> or <codeph>ERemoveBoth</codeph> is
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    31
used to remove white spaces on right side or both sides of the URI, respectively. </p> <p> <b>Note</b>:
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    32
The white spaces within the URI cannot be removed using <codeph>RemoveWhiteSpace()</codeph>. </p> </section>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    33
<section><title>Converting the data </title><p> <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita"><apiname>InetProtTextUtils</apiname></xref> class
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    34
provides various data conversion methods. The methods can be used to convert
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    35
decimal and hex descriptors into its integer representations and vice versa.
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    36
The following are the methods: </p> <p> <b> Converting data from an integer
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    37
to a string </b>  </p> <p>Call <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita#GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE/GUID-F030F4B9-0C66-3548-A19D-8D06204E11B0"><apiname>InetProtTextUtils::ConvertIntToDescriptorL()</apiname></xref> or <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita#GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE/GUID-E28E1DDF-318C-3B59-8413-722438E748EA"><apiname>InetProtTextUtils::ConvertHexToDescriptorL()</apiname></xref> to convert an integer into a decimal or hexademial number respectively.
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    38
The following code converts the integer value of the data to a string: </p> <codeblock id="GUID-5B0E26B9-2B92-5D0D-813F-C3CA647FBE16" xml:space="preserve">// Convert the integer value of the data to a string
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    39
TInt intVal = 489;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    40
HBufC8* abuf = HBufC8::NewL( 32 );//a descriptor is allocated on the heap to hold the data.
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    41
InetProtTextUtils::ConvertIntToDescriptorL( intVal,abuf );// abuf contains "489", the extracted value.</codeblock> <p>where, <codeph>intVal</codeph> stores the data to be converted. The converted <codeph>abuf</codeph> contains
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    42
the extracted descriptor. </p> <codeblock id="GUID-7C4374D1-C702-55FE-B9A7-C36E7E4F2F1B" xml:space="preserve">TInt intVal=489;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    43
HBufC8* abuf = HBufC8::NewL( 32 );
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    44
InetProtTextUtils::ConvertHexToDescriptorL( intVal,abuf );//abuf contains 1E9</codeblock> <p>where, <codeph>intVal</codeph> stores
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    45
the data to be converted. The converted value will be stored in the buffer <codeph>abuf</codeph>. </p> <p> <b>Converting
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    46
data from a string to a number</b>  </p> <p>Call <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita#GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE/GUID-48074038-1E1E-350A-8D21-3949102DF99B"><apiname>InetProtTextUtils::ConvertDescriptorToIntL()</apiname></xref> to
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    47
convert the character representation of an integer into its numeric value.
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    48
Preceding white space is ignored and the integer is delimited by either the
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    49
end of the data, whitespace or any character other than 0 to 9. </p> <codeblock id="GUID-2B3F4CAA-6A6C-5AE4-B790-E7AAB05745FC" xml:space="preserve">//Convert the string to an integer
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    50
TInt intVal = 0;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    51
_LIT8( KNumber,"489" );
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    52
InetProtTextUtils::ConvertDescriptorToInt( KNumber,intVal ); // the intVal now holds the integer 489</codeblock> <p>Call <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita#GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE/GUID-BB5036C8-DFC8-310B-9CE5-7F8131F477C4"><apiname>InetProtTextUtils::ConvertDescriptorToHex()</apiname></xref> to convert the character representation of an integer to its hexadecimal
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    53
value. </p> <codeblock id="GUID-739AD8F3-F402-5425-9B7D-DD914567BE6C" xml:space="preserve">TInt intVal = 0;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    54
_LIT8( KNumber,"64" );
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    55
InetProtTextUtils::ConvertDescriptorToHex( KNumber,intVal ); //intVal = 100</codeblock> <p>This
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    56
function extracts the value contained in the buffer <codeph>intVal</codeph> and
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    57
considers a hexadecimal number. </p> <p> <b>Extracting the quoted string</b>  </p> <p> <xref href="GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE.dita#GUID-9FC0E63B-1927-30B0-8A97-E9CB1010FFEE/GUID-FC38525A-7C9B-3AAB-834D-3354DB86BA46"><apiname>InetProtTextUtils::ExtractQuotedStringL()</apiname></xref> extracts the quoted string within an URI. </p> <codeblock id="GUID-A115B39B-23C9-599B-AB75-ACB050C9F7D4" xml:space="preserve">_LIT8( KQuotedBuffer0,    "this is the \"inside quotes\" outside quotes" ); // the string to be manipulated
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    58
TBuf8&lt;64&gt;  quotedString;
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    59
TPtrC8 ptr( KQuotedBuffer0() ); //pointer to the string
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    60
TPtrC8 ptr1( quotedString );
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    61
//ptr contains "outside quotes" and ptr1 contains "inside quotes"
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    62
InetProtTextUtils::ExtractQuotedStringL( ptr, ptr1 ); </codeblock> <p>where, <codeph>ptr1</codeph> is
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    63
a pointer that points to the quoted string "<codeph>inside quotes</codeph> " </p></section>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    64
<section><title>See also</title> <p><xref href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita">HTTP
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    65
Utilities Library Overview</xref>  </p> </section>
25a17d01db0c Addition of the PDK content and example code for Documentation_content according to Feature bug 1607 and bug 1608
Dominic Pinkman <Dominic.Pinkman@Nokia.com>
parents:
diff changeset
    66
</conbody></concept>