homescreensrv_plat/ai_utilities_api/inc/aistrparser.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Collection of string parsing methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef AISTRPARSER_H
       
    20 #define AISTRPARSER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 
       
    27 /**
       
    28 *  It is the interface for handling string parsing.
       
    29 *
       
    30 *  @since S60 3.2
       
    31 */
       
    32 class MAiStrParser
       
    33     {
       
    34 public:
       
    35     
       
    36 	/**
       
    37 	 * Parses an integer value from string. The string may contain
       
    38 	 * the integer value either in hexadecimal or decimal format.
       
    39 	 *
       
    40 	 * @param aValue the result integer value
       
    41 	 * @param aStringValue the source string
       
    42 	 * @return KErrNone if aStringValue is parsed to aValue.
       
    43 	 */	 
       
    44 	virtual TInt ParseInt( TInt32& aValue, const TDesC8& aStringValue ) = 0;
       
    45 	
       
    46 	/**
       
    47 	 * Copies aText to aBuffer.
       
    48 	 *
       
    49 	 * @param aBuffer a buffer to hold text. If aBuffer is NULL or
       
    50 	 * insufficient, the function allocates a buffer.
       
    51 	 * @param aText the text to copy.
       
    52 	 * @return pointer to result buffer.
       
    53 	 */ 	
       
    54 	virtual HBufC16* CopyToBufferL(HBufC16* aBuffer, const TDesC16& aText) = 0;
       
    55     
       
    56     /**
       
    57 	 * Copies and converts aText to aBuffer. UTF-8 to UCS-2 conversion
       
    58 	 * is applied to aText.
       
    59 	 *
       
    60 	 * @param aBuffer a buffer to hold text. If aBuffer is NULL or
       
    61 	 * insufficient, the function allocates a buffer.
       
    62 	 * @param aText the text to copy.
       
    63 	 * @return pointer to result buffer.
       
    64  	 */ 
       
    65     virtual HBufC16* CopyToBufferL(HBufC16* aBuffer, const TDesC8& aText) = 0;
       
    66     
       
    67     /**
       
    68 	 * Copies aText to aBuffer.
       
    69 	 *
       
    70 	 * @param aBuffer a buffer to hold text. If aBuffer is NULL or
       
    71 	 * insufficient, the function allocates a buffer.
       
    72 	 * @param aText the text to copy.
       
    73 	 * @return pointer to result buffer.
       
    74 	 */ 
       
    75     virtual HBufC8* CopyToBufferL(HBufC8* aBuffer, const TDesC8& aText) = 0;
       
    76     
       
    77     /**
       
    78 	 * Copies and converts aText to aBuffer. UCS-2 to UTF-8 conversion
       
    79 	 * is applied to aText.
       
    80 	 *
       
    81 	 * @param aBuffer a buffer to hold text. If aBuffer is NULL or
       
    82 	 * insufficient, the function allocates a buffer.
       
    83 	 * @param aText the text to copy.
       
    84 	 * @return pointer to result buffer.
       
    85 	 */ 
       
    86     virtual HBufC8* CopyToBufferL(HBufC8* aBuffer, const TDesC16& aText) = 0;
       
    87     
       
    88     /**
       
    89      * Release the parser
       
    90      */
       
    91     virtual void Release() = 0;
       
    92 	    
       
    93 protected:
       
    94 	    
       
    95 	~MAiStrParser() { }
       
    96     
       
    97     };
       
    98 
       
    99 /**
       
   100  * Helper for calling MAiStrParser::Release() with NULL checking.
       
   101  */
       
   102 inline void Release(MAiStrParser* obj)
       
   103     {
       
   104     if (obj)
       
   105         {
       
   106         obj->Release();
       
   107         }
       
   108     }
       
   109 
       
   110 
       
   111 #endif      // AISTRPARSER_H
       
   112 
       
   113 // End of File