applayerprotocols/httptransportfw/Test/T_HttpIntegration/TfrLex.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // $Header$
       
    15 // TfrLex.cpp
       
    16 // This module implements TfrLex collection of static lexical functions.
       
    17 // rev:	mjdavey, symbian@mjdss.com, July 2002
       
    18 // for:	Typhoon (7.0s) & JetStream (8.0)
       
    19 // 
       
    20 //
       
    21 
       
    22 #ifndef __TFRLEX_H__
       
    23 #define __TFRLEX_H__
       
    24 
       
    25 //-----------------------------------------------------------------------------
       
    26 
       
    27 #include <e32base.h>
       
    28 
       
    29 //-----------------------------------------------------------------------------
       
    30 
       
    31 class TfrLex
       
    32 {
       
    33 public:     // New functions
       
    34 
       
    35 	// Extract a term. The TLex variants return KErr* (KErrNone if
       
    36 	// found) and advance next position. The TDesC& variants check
       
    37 	// if text begins with term and return ETrue/EFalse.
       
    38 	static TInt  Val ( TLex& aLex        , const TDesC& aTerm );
       
    39 	static TBool Val ( const TDesC& aText, const TDesC& aTerm );
       
    40 	static TInt  ValF( TLex& aLex        , const TDesC& aTerm );
       
    41 	static TBool ValF( const TDesC& aText, const TDesC& aTerm );
       
    42 
       
    43 	// Skip spaces and get token up to end-of-string, a space char
       
    44 	// or up to the very character/characters you define. The GetF
       
    45 	// supports tokens like "*". If a token begins with apostrophe
       
    46 	// but does not end to one, the functions L E A V E with error
       
    47 	// KErrArgument.
       
    48 	static TPtrC GetL( TLex& aLex, const TChar  aChar = 0 );
       
    49 	static TPtrC GetL( TLex& aLex, const TDesC& aList     );
       
    50 
       
    51 	// Skip spaces and then eat the very character or the very term
       
    52 	// you define. Return ETrue (was found and swallowed) or EFalse.
       
    53 	static TBool Eat ( TLex& aLex, const TChar aChar  );
       
    54 	static TBool Eat ( TLex& aLex, const TDesC& aTerm );
       
    55 	static TBool EatF( TLex& aLex, const TDesC& aTerm );
       
    56 
       
    57 	// Get count of tokens. REMOVED
       
    58 	// static TInt TokenCount( const TDesC& aText );
       
    59 	// static TInt TokenCount( TLex aLex );
       
    60 
       
    61 	// Get from first non white space onwards.
       
    62 	static TPtrC TrimLeft( const TDesC& aText );
       
    63 
       
    64 	// Get up to the last non white space.
       
    65 	static TPtrC TrimRight( const TDesC& aText );
       
    66 
       
    67 	// Get from first non white space onwards up to the last
       
    68 	// non white space i.e. TrimLeft and TrimRight.
       
    69 	static TPtrC Trim( const TDesC& aText );
       
    70 
       
    71 	// Get text like "*" without the two apostrophes. If not
       
    72 	// like "*", then returns the text as such as the whole.
       
    73 	static TPtrC Peel( const TDesC& aText );
       
    74 
       
    75 	// Trim and then Peel.
       
    76 	static TPtrC TrimAndPeel( const TDesC& aText );
       
    77 
       
    78 	// Peel and them Trim.
       
    79 	static TPtrC PeelAndTrim( const TDesC& aText );
       
    80 
       
    81 };
       
    82 
       
    83 //-----------------------------------------------------------------------------
       
    84 
       
    85 #endif  // __TFRLEX_H__
       
    86 
       
    87 //-----------------------------------------------------------------------------
       
    88 //	Get count of tokens.
       
    89 
       
    90 /*
       
    91 TInt TfrLex::TokenCount( const TDesC& aText )
       
    92 {
       
    93 TLex lex( aText );
       
    94 return TokenCount( lex );
       
    95 }
       
    96 TInt TfrLex::TokenCount( TLex aLex )
       
    97 {
       
    98 TPtrC token;
       
    99 TInt count = 0;
       
   100 do
       
   101 {
       
   102 token.Set( aLex.NextToken() );
       
   103 if ( token.Length() > 0 ) count++;
       
   104 } while ( token.Length() > 0 );
       
   105 
       
   106 return count;
       
   107 }        
       
   108 */
       
   109 
       
   110 //-----------------------------------------------------------------------------
       
   111 // End of File
       
   112 //-----------------------------------------------------------------------------