Symbian3/SDK/Source/GUID-834F5FC8-EBE4-4076-B1E3-38DDFF89D700.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 task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task id="GUID-834F5FC8-EBE4-4076-B1E3-38DDFF89D700" xml:lang="en"><title>Modifying
       
    13 the Data and Delimiter</title><shortdesc>This tutorial describes the steps to modify the data and delimiter.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    14 <prereq>       <p>HTTP Utilities Library provides <codeph>CDelimitedXxxx8</codeph> classes
       
    15 to modify the data and the delimiter. </p>     </prereq>
       
    16 <context>       <p>Use <codeph>CDelimitedXxxx8</codeph> classes to parse,
       
    17 add or remove the delimiter and segment within the URI.<note> <codeph>TDelimitedXxxxParser8</codeph> classes
       
    18 provide the functionality only for parsing.</note></p><p><xref href="GUID-51DFAA06-EC5E-32E6-9819-39938C46B2C0.dita"><apiname>CDelimitedPath8</apiname></xref>, <xref href="GUID-CF89AECB-5085-32CA-85B4-3573CDB1D595.dita"><apiname>CDelimitedPathSegment8</apiname></xref> and <xref href="GUID-9A640379-04BC-3A8E-9452-54833B2419AE.dita"><apiname>CDelimitedQuery8</apiname></xref> classes are derived from <xref href="GUID-347440D2-D58D-3505-88EB-5BA4B89F2FC2.dita"><apiname>CDelimitedDataBase</apiname></xref> to
       
    19 add and remove data and delimiters from the respective component.   <codeph>CDelimitedXxxx8</codeph> classes
       
    20 provide the following functionality:</p><ul>
       
    21 <li><p><codeph>SetDelimiter()</codeph>, <codeph>Parse()</codeph> and <codeph>ParseReverse()</codeph> functions
       
    22 are used to set the delimiter and parse the data. </p><p/></li>
       
    23 <li><p><codeph>ParseReverse()</codeph> is used, for example, when you want
       
    24 to extract the file name. For more details on parsing the delimited data,
       
    25 refer to <xref href="GUID-42F0F282-58D6-4878-B53D-EAEEF86A3D7D.dita">Parsing the
       
    26 delimited data</xref>.</p></li>
       
    27 </ul><note> Delimiter must be set before the data is parsed. </note><p>The
       
    28 following are some of the URI data and delimiter modifications that can be
       
    29 performed on a URI: <codeblock xml:space="preserve">_LIT8(KPath,"c:/myfolder");
       
    30 _LIT8(KLogs,"logs");
       
    31 //Create CDelimitedPath8 object
       
    32 CDelimitedPath8* dpath = CDelimitedPath8::NewL(KPath); </codeblock></p>  
       
    33   </context>
       
    34 <steps-unordered>
       
    35 <step id="GUID-3CDC248D-ABF4-46C6-9841-E79C7DE80C50"><cmd/>
       
    36 <info><b>Removing a segment:</b> The following code removes the first segment
       
    37 from the data. <p/></info>
       
    38 <stepxmp><codeblock xml:space="preserve">dpath-&gt;PopFrontL();
       
    39 // remove first segment containing "c:"
       
    40 const TDesC8&amp; des = dpath-&gt;Parser().Des();</codeblock></stepxmp>
       
    41 <stepresult><p>Here, <codeph>des</codeph> holds "<filepath>/myfolder/logs</filepath>"
       
    42 after removing "<filepath>c:</filepath>". To remove the last segment from
       
    43 the data, use <codeph>PopBackL()</codeph>. </p></stepresult>
       
    44 </step>
       
    45 <step id="GUID-4DAA1D56-D5FF-476C-A58A-2401605B8872"><cmd/>
       
    46 <info><p><b>Adding a segment:</b> The following code adds a new segment at
       
    47 the end of the data. </p></info>
       
    48 <stepxmp><codeblock xml:space="preserve">dpath-&gt;PushBackL(KLogs);
       
    49 // add "logs" at the end
       
    50 const TDesC8&amp; des = dpath-&gt;Parser().Des();</codeblock></stepxmp>
       
    51 <stepresult><p>Here, <codeph>des</codeph> holds "<filepath>c:/myfolder/logs</filepath>"
       
    52 after adding "logs". To add a new segment at the beginning of the data, use <codeph>PushFrontL()</codeph>. </p></stepresult>
       
    53 </step>
       
    54 <step id="GUID-ACE640AB-3C04-417F-A8FC-9688ED80D81B"><cmd/>
       
    55 <info><p><b>Removing a delimiter:</b> The following code removes the delimiter
       
    56 from the beginning of the data. </p></info>
       
    57 <stepxmp><codeblock xml:space="preserve">dpath-&gt;TrimFrontDelimiterL();
       
    58 // remove delimiter "/" at the beginning
       
    59 const TDesC8&amp; des = dpath-&gt;Parser().Des();</codeblock></stepxmp>
       
    60 <stepresult><p>Here, <codeph>des</codeph> holds "<filepath>myfolder/logs</filepath>"
       
    61 after removing "/". To add the delimiter at the beginning or at the end of
       
    62 the data, use <codeph>AddFrontDelimiterL()</codeph> and <codeph>AddBackDelimiterL()</codeph> respectively. </p></stepresult>
       
    63 </step>
       
    64 <step id="GUID-65DA38D0-6CCE-4443-86F0-0B55F716FB19"><cmd/>
       
    65 <info><p><b>Parsing data and removing the current segment of data:</b> The
       
    66 following code parses the data and removes the current segment of data. </p></info>
       
    67 <stepxmp><codeblock xml:space="preserve">//Parse before removing the segment
       
    68 dpath-&gt;Parse();
       
    69 //remove the current segment
       
    70 dpath-&gt;RemoveCurrentL();
       
    71 // parse the data after removing "myfolder"
       
    72 const TDesC8&amp; des = dpath-&gt;Parser().Des();</codeblock></stepxmp>
       
    73 <stepresult><p>Here, <codeph>des</codeph> holds "<filepath>/logs</filepath>"
       
    74 after removing "<filepath>myfolder</filepath>". </p><note> The data must be
       
    75 parsed after removing the segment. </note></stepresult>
       
    76 </step>
       
    77 <step id="GUID-B4A6C14F-D971-456D-9F9E-1AD6AEC9E2F5"><cmd/>
       
    78 <info><p><b>Adding a delimiter:</b> The following code inserts a new segment
       
    79 before the current parsed segment. </p></info>
       
    80 <stepxmp><codeblock xml:space="preserve">// data to insert
       
    81 _LIT8(KHolyfolder,"Holyfolder");
       
    82 //insert a new segment before the current segment
       
    83 dpath-&gt;InsertCurrentL(KHolyfolder);
       
    84 // parse the data after inserting "Holyfolder"
       
    85 const TDesC8&amp; des = dpath-&gt;Parser().Des();</codeblock></stepxmp>
       
    86 <stepresult><p>Here, des holds "<filepath>/Holyfolder/logs</filepath>" after
       
    87 inserting "<filepath>Holyfolder</filepath>". </p></stepresult>
       
    88 </step>
       
    89 </steps-unordered>
       
    90 </taskbody><related-links>
       
    91 <link href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita"><linktext>HTTP Utilities
       
    92 Library Overview</linktext></link>
       
    93 <link href="GUID-42F0F282-58D6-4878-B53D-EAEEF86A3D7D.dita"><linktext>Parsing Delimited
       
    94 Data</linktext></link>
       
    95 <link href="GUID-38B65AAC-3CFA-5C9B-AD6F-36823B6C2C0E.dita"><linktext>Escape and
       
    96 insert concept</linktext></link>
       
    97 </related-links></task>