Modifying the Data and Delimiter

This tutorial describes the steps to modify the data and delimiter.

HTTP Utilities Library provides CDelimitedXxxx8 classes to modify the data and the delimiter.

Use CDelimitedXxxx8 classes to parse, add or remove the delimiter and segment within the URI.
Note: TDelimitedXxxxParser8 classes provide the functionality only for parsing.

CDelimitedPath8, CDelimitedPathSegment8 and CDelimitedQuery8 classes are derived from CDelimitedDataBase to add and remove data and delimiters from the respective component. CDelimitedXxxx8 classes provide the following functionality:

  • SetDelimiter(), Parse() and ParseReverse() functions are used to set the delimiter and parse the data.

  • ParseReverse() is used, for example, when you want to extract the file name. For more details on parsing the delimited data, refer to Parsing the delimited data.

Note: Delimiter must be set before the data is parsed.
The following are some of the URI data and delimiter modifications that can be performed on a URI:
_LIT8(KPath,"c:/myfolder");
_LIT8(KLogs,"logs");
//Create CDelimitedPath8 object
CDelimitedPath8* dpath = CDelimitedPath8::NewL(KPath); 

  • Removing a segment: The following code removes the first segment from the data.

    dpath->PopFrontL();
    // remove first segment containing "c:"
    const TDesC8& des = dpath->Parser().Des();

    Here, des holds "/myfolder/logs" after removing "c:". To remove the last segment from the data, use PopBackL().


  • Adding a segment: The following code adds a new segment at the end of the data.

    dpath->PushBackL(KLogs);
    // add "logs" at the end
    const TDesC8& des = dpath->Parser().Des();

    Here, des holds "c:/myfolder/logs" after adding "logs". To add a new segment at the beginning of the data, use PushFrontL().


  • Removing a delimiter: The following code removes the delimiter from the beginning of the data.

    dpath->TrimFrontDelimiterL();
    // remove delimiter "/" at the beginning
    const TDesC8& des = dpath->Parser().Des();

    Here, des holds "myfolder/logs" after removing "/". To add the delimiter at the beginning or at the end of the data, use AddFrontDelimiterL() and AddBackDelimiterL() respectively.


  • Parsing data and removing the current segment of data: The following code parses the data and removes the current segment of data.

    //Parse before removing the segment
    dpath->Parse();
    //remove the current segment
    dpath->RemoveCurrentL();
    // parse the data after removing "myfolder"
    const TDesC8& des = dpath->Parser().Des();

    Here, des holds "/logs" after removing "myfolder".

    Note: The data must be parsed after removing the segment.

  • Adding a delimiter: The following code inserts a new segment before the current parsed segment.

    // data to insert
    _LIT8(KHolyfolder,"Holyfolder");
    //insert a new segment before the current segment
    dpath->InsertCurrentL(KHolyfolder);
    // parse the data after inserting "Holyfolder"
    const TDesC8& des = dpath->Parser().Des();

    Here, des holds "/Holyfolder/logs" after inserting "Holyfolder".

Related tasks
Parsing Delimited Data