menufw/hierarchynavigator/hnutilities/inc/hnliwutils.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HNLIWUTILS_H
       
    20 #define HNLIWUTILS_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32hashtab.h>
       
    24 #include <liwcommon.h>
       
    25 
       
    26 
       
    27 class CHnMdBaseKey;
       
    28 class CLiwGenericParamList;
       
    29 class TLiwVariant;
       
    30 
       
    31 /**
       
    32  *  Provides static methods which handles operations
       
    33  *  like extracting data from and inserting data to 
       
    34  *  LIW composite classes ( CLiwGenericParamList, TLiwVariant ).   
       
    35  * 
       
    36  *  @lib hnutilities.lib
       
    37  *  @since S60 v5.0
       
    38  *  @ingroup group_hnutilities
       
    39  */
       
    40 NONSHARABLE_CLASS( HnLiwUtils )
       
    41     {   
       
    42 public:
       
    43     /**
       
    44      * Appends key-value pairs stored in aKeys to aInParam.
       
    45      * Keys are appended in the same order as they occur in the aKeys array.
       
    46      * Every key value is converted to a TLiwVariant before appending to the
       
    47      * param list.
       
    48      * 
       
    49      * @since S60 v5.0
       
    50      * @param aKeys Keys to append.
       
    51      * @param aInParam Param list to be modified.
       
    52      */    
       
    53     IMPORT_C static void SetGenericParamListL(
       
    54         const RPointerArray<CHnMdBaseKey> & aKeys,
       
    55         CLiwGenericParamList& aInParam );
       
    56 
       
    57     /**
       
    58      * Creates a string representing a selected value from the param list.
       
    59      * The aPath paramter is the path to the selected param list element.
       
    60      * 
       
    61      * @since S60 v5.0
       
    62      * @param aParam Param list.
       
    63      * @param aPath URI Path.
       
    64      * @param aBuf Output buffer.
       
    65      * @return Error code.
       
    66      */
       
    67     IMPORT_C static TInt GetStringL(
       
    68         const CLiwGenericParamList& aParam, 
       
    69         const TDesC8& aPath, 
       
    70         RBuf& aBuf );
       
    71 
       
    72     /**
       
    73      * Creates a string representing a selected value from the param list.
       
    74      * The aPath paramter is the path to the selected param list element.
       
    75      * 
       
    76      * @since S60 v5.0
       
    77      * @param aParam Param list.
       
    78      * @param aPath URI Path.
       
    79      * @param aBuf Output buffer.
       
    80      * @return Error code.
       
    81      */
       
    82     IMPORT_C static TInt GetStringL(
       
    83         const CLiwGenericParamList& aParam, 
       
    84         const TDesC8& aPath, 
       
    85         RBuf8& aBuf );
       
    86     
       
    87     /**
       
    88      * Returns TInt64 value using the given path.
       
    89      * 
       
    90      * @since S60 v5.0
       
    91      * @param aParam Param list.
       
    92      * @param aPath URI Path.
       
    93      * @param aPos Position.
       
    94      * @param aRet Return TInt64 value.
       
    95      * @return TInt64 value or KErrNotFound.
       
    96      */
       
    97     IMPORT_C static TInt GetInt64L( const CLiwGenericParamList& aParam,
       
    98     	    const TDesC8& aPath, TInt aPos, TInt64& aRet );
       
    99     
       
   100     /**
       
   101      * Creates a string representing a selected value from the param list.
       
   102      * The aPath paramter is the path to the selected param list element.
       
   103      * 
       
   104      * @since S60 v5.0
       
   105      * @param aParam Param list.
       
   106      * @param aPath URI Path.
       
   107      * @param aPos Position.
       
   108      * @param aBuf Output buffer.
       
   109      * @return Error code.
       
   110      */
       
   111     IMPORT_C static TInt GetStringL(
       
   112         const CLiwGenericParamList& aParam, 
       
   113         const TDesC8& aPath, 
       
   114         TInt aPos,
       
   115         RBuf& aBuf );
       
   116 
       
   117     /**
       
   118      * Creates a string representing a selected value from the param list.
       
   119      * The aPath paramter is the path to the selected param list element.
       
   120      * 
       
   121      * @since S60 v5.0
       
   122      * @param aParam Param list.
       
   123      * @param aPath URI Path.
       
   124      * @param aPos Position.
       
   125      * @param aBuf Output buffer.
       
   126      * @return Error code.
       
   127      */
       
   128     IMPORT_C static TInt GetStringL(
       
   129         const CLiwGenericParamList& aParam, 
       
   130         const TDesC8& aPath, 
       
   131         TInt aPos,
       
   132         RBuf8& aBuf );
       
   133     
       
   134     /**
       
   135      *  Exctracts variant from param list.
       
   136      * 
       
   137      * @since S60 v5.0
       
   138      * @param aParam Param list.
       
   139      * @param aPath URI path.
       
   140      * @param aPos Position.
       
   141      * @param aRet Output buffer.
       
   142      * @return Error code.
       
   143      */
       
   144     IMPORT_C static TInt GetVariantL(
       
   145         const CLiwGenericParamList& aParam,
       
   146         const TDesC8& aPath,
       
   147         TInt aPos,
       
   148         TLiwVariant& aRet );
       
   149 
       
   150     /**
       
   151      *  Exctracts variant from param list.
       
   152      * 
       
   153      * @since S60 v5.0
       
   154      * @param aParam Param list.
       
   155      * @param aPath URI path.
       
   156      * @param aRet Output buffer.
       
   157      * @return Error code.
       
   158      */
       
   159     IMPORT_C static TInt GetVariantL(
       
   160         const CLiwGenericParamList& aParam,
       
   161         const TDesC8& aPath,
       
   162         TLiwVariant& aRet );
       
   163     
       
   164     /**
       
   165      * Creates a string representation of a variant value.
       
   166      * Supported variant types are: EVariantTypeDesC, 
       
   167      * EVariantTypeDesC8, EVariantTypeTUid, EVariantTypeTInt32,
       
   168      * and EVariantTypeTUint.
       
   169      * 
       
   170      * @since S60 v5.0
       
   171      * @param aVariant Source variant.
       
   172      * @param aBuf Output buffer.
       
   173      * @return EFalse if variant type is not supported.
       
   174      */
       
   175     IMPORT_C static TBool VariantToStringL( TLiwVariant& aVariant,
       
   176                                            RBuf& aBuf );
       
   177     
       
   178     /**
       
   179      * Creates a string representation of a variant value.
       
   180      * Supported variant types are: EVariantTypeDesC, 
       
   181      * EVariantTypeDesC8, EVariantTypeTUid, EVariantTypeTInt32,
       
   182      * and EVariantTypeTUint.
       
   183      * 
       
   184      * @since S60 v5.0
       
   185      * @param aVariant Source variant.
       
   186      * @param aBuf Output buffer.
       
   187      * @return EFalse if variant type is not supported.
       
   188      */
       
   189     IMPORT_C static TBool VariantToStringL( TLiwVariant& aVariant,
       
   190                                            RBuf8& aBuf );
       
   191 
       
   192     /**
       
   193      * Gets total number of items held by an iterable.
       
   194      * 
       
   195      * @param aIterable the iterable
       
   196      * @return total number of items stored in aIterable
       
   197      */
       
   198     IMPORT_C static TInt GetIterableItemCountL( CLiwIterable& aIterable );
       
   199 
       
   200 private:
       
   201     
       
   202     /**
       
   203      * Exctracts namespace from param list.
       
   204      *
       
   205      * @since S60 v5.0
       
   206      * @param aParam Param list.
       
   207      * @param aNameSpace Namespace.
       
   208      * @param aRet Output variant.
       
   209      * @return Error code.
       
   210      */
       
   211     static TInt ExtractNameSpaceL( const CLiwGenericParamList& aParam,
       
   212                                    const TDesC8& aNameSpace,
       
   213                                    TLiwVariant& aRet );
       
   214     
       
   215     /**
       
   216      * Process path for selecting elements separated by colon or slash.
       
   217      *
       
   218      * @since S60 v5.0
       
   219      * @param aPath Path.
       
   220      * @param aPathParts Elements of the path.
       
   221      */
       
   222     static void ParsePathL( const TDesC8& aPath, 
       
   223                            RArray< TPtrC8 >& aPathParts );
       
   224 
       
   225     /**
       
   226      * Replaces the first occurence of the string "$index" with a number.
       
   227      * On successful execution the string contained in aPath8 will have
       
   228      * have the first occurence of the substring "$index" replaced by
       
   229      * a string representation of the number given in aPos.
       
   230      *  
       
   231      * @since S60 v5.0
       
   232      * @param aPath8 A path to the variant in the generic param list.
       
   233      * @param aPos A position of the item in the group of items.
       
   234      * @return Length of the new path, ending at the index object.
       
   235      */
       
   236     static TInt ReplaceIndexL( RBuf8& aPath8, TInt aPos );
       
   237         
       
   238     /**
       
   239      * Extracts a number enclosed in square brackets from a string.
       
   240      * The number is assumed to be non-negative (otherwise it would be
       
   241      * impossible to determine if the function executed successfully).
       
   242      * If the string contains more than one pair of square brackets, only
       
   243      * the first pair is processed by this method.
       
   244      * 
       
   245      * @since S60 v5.0
       
   246      * @param aPosition String containing the position number.
       
   247      * @return Number extracted from string or error code on failure.
       
   248      */
       
   249     static TInt GetPosition( const TDesC8& aPosition );
       
   250 
       
   251     /**
       
   252      * Uses iterator object to extract variant pointed by position. 
       
   253      *
       
   254      * @since S60 v5.0
       
   255      * @param aIterable Iterator to use.
       
   256      * @param aPos Position of the variant.
       
   257      * @param aVariant Output variant.
       
   258      * @return ETrue if variant found.
       
   259      */
       
   260     static TBool GetIterableByPositionL(
       
   261         CLiwIterable & aIterable,
       
   262         TInt aPos,
       
   263         TLiwVariant & aVariant );
       
   264      
       
   265      };
       
   266 
       
   267 #endif // HNLIWUTILS_H
       
   268