mmappcomponents/harvester/filehandler/inc/mpxfhcommon.inl
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  inline functions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // ---------------------------------------------------------------------------
       
    20 // Parses a string for tokens separated by |
       
    21 // ---------------------------------------------------------------------------
       
    22 //
       
    23 inline void ExtractTokensL( const TDesC& aString, RArray<TPath>& aArray )
       
    24     {
       
    25      // Parse the string and add it into array
       
    26     //
       
    27     TBool done(EFalse);
       
    28     TLex lex( aString );
       
    29     lex.Mark();
       
    30     while( !done )
       
    31         {
       
    32         // Found a token
       
    33         if( lex.Peek() =='|' || lex.Eos() )
       
    34             {
       
    35             TPtrC token = lex.MarkedToken();
       
    36 
       
    37             // Ignore null length tokens
       
    38             if( token.Length() )
       
    39                 {
       
    40                 aArray.AppendL( token );
       
    41                 }
       
    42 
       
    43             // Next token
       
    44             if( lex.Eos() )
       
    45                 {
       
    46                 done = ETrue;
       
    47                 }
       
    48             else
       
    49                 {
       
    50                 lex.Inc();
       
    51                 lex.Mark();
       
    52                 }
       
    53             }
       
    54         else
       
    55             {
       
    56             // Next character
       
    57             lex.Inc();
       
    58             }
       
    59         }
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // Parses a string for tokens separated by |
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 inline void ExtractTokensL( const TDesC& aString, CDesCArray& aArray )
       
    67     {
       
    68      // Parse the string and add it into array
       
    69     //
       
    70     TBool done(EFalse);
       
    71     TLex lex( aString );
       
    72     lex.Mark();
       
    73     while( !done )
       
    74         {
       
    75         // Found a token
       
    76         if( lex.Peek() =='|' || lex.Eos() )
       
    77             {
       
    78             TPtrC token = lex.MarkedToken();
       
    79 
       
    80             // Ignore null length tokens
       
    81             if( token.Length() )
       
    82                 {
       
    83                 aArray.InsertIsqL( token );
       
    84                 }
       
    85 
       
    86             // Next token
       
    87             if( lex.Eos() )
       
    88                 {
       
    89                 done = ETrue;
       
    90                 }
       
    91             else
       
    92                 {
       
    93                 lex.Inc();
       
    94                 lex.Mark();
       
    95                 }
       
    96             }
       
    97         else
       
    98             {
       
    99             // Next character
       
   100             lex.Inc();
       
   101             }
       
   102         }
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Finds the drive number for a path
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 inline TDriveNumber ExtractDrive( const TDesC& aPath )
       
   110     {
       
   111     TParsePtrC parse( aPath );
       
   112     TDriveUnit drive( parse.Drive() );
       
   113     TInt num = drive;
       
   114     return TDriveNumber(num);
       
   115     }