imservices/ossprotocoladaptation/dataconvlib/inc/stringutils.h
branchRCL_3
changeset 20 7797b2f86d2b
parent 18 b6f2a363adf7
child 25 cfe5eb8bb9ca
equal deleted inserted replaced
18:b6f2a363adf7 20:7797b2f86d2b
     1 /*
       
     2 * Copyright (c) 2005-2007 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:   	Header file for stringutils
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __STRINGUTILS_H__
       
    19 #define __STRINGUTILS_H__
       
    20 
       
    21 /** @file stringutils.h
       
    22  * stringutils is a DLL that exports some set of genaralized APIs using which 
       
    23  * user can convert the SYMBIAN descriptors to standard C character/wide-character
       
    24  * strings and vice-versa
       
    25  */
       
    26 
       
    27 //Symbian Headers
       
    28 #include <e32cmn.h>
       
    29 #include <wchar.h>
       
    30 
       
    31 /**
       
    32   * Aliases : Cconverting HBufC variants to char/wchar_t strings involves
       
    33   * similiar procedure to that of converting TBufC variants to  char/wchar_t strings.
       
    34   * Hence HBufC to char/wchar_t conversion Apis are aliased to their corresponding TBufC 
       
    35   * counterparts
       
    36   */
       
    37 
       
    38 
       
    39 /**
       
    40   * Alias to the function tbufC16towchar
       
    41   */
       
    42 #define hbufC16towchar	tbufC16towchar
       
    43 /**
       
    44   * Alias to the function tbufC16tochar
       
    45   */
       
    46 #define hbufC16tochar	tbufC16tochar
       
    47 /**
       
    48   * Alias to the function tbufC8towchar
       
    49   */
       
    50 #define hbufC8towchar	tbufC8towchar
       
    51 /**
       
    52   * Alias to the function tbufC8tochar
       
    53   */
       
    54 #define hbufC8tochar	tbufC8tochar
       
    55 
       
    56 		
       
    57 //Function prototypes
       
    58 
       
    59 /** Functions to convert SYMBIAN descriptors to C character and
       
    60   * Wide-Character strings 
       
    61   */
       
    62 
       
    63 /**
       
    64   * This Api converts the tbuf16 to a wide-character string
       
    65   * @param aArg TDes object
       
    66   * @return	a pointer to a wide-character string
       
    67   */
       
    68 IMPORT_C wchar_t* tbuf16towchar(TDes& aArg);
       
    69 
       
    70 /**
       
    71   * This Api converts the tbuf8 to a character string
       
    72   * @param aArg TDes8 object
       
    73   * @return	a pointer to a character string
       
    74   */
       
    75 IMPORT_C char* tbuf8tochar(TDes8& aArg);
       
    76 
       
    77 /**
       
    78   * This Api converts the tbuf16 to a character string. It is user
       
    79   * responsibality to allocate a required size of char object. Api may
       
    80   * resulting in crash, if the destination object size is smaller than
       
    81   * that of the source.
       
    82   * @param 		aSrc TDes16 object
       
    83   * @param 		aDes character pointer, to which the resultant string will be copied.
       
    84   * @return		returns an integer value.
       
    85   * @return		Api returns -1 in case of any error.
       
    86   */
       
    87 IMPORT_C int tbuf16tochar(TDes& aSrc, char* aDes);
       
    88 	
       
    89 /**
       
    90   * This Api converts the tbuf8 to a wide-character string. It is user
       
    91   * responsibality to allocate a required size of wide-char object. Api	may
       
    92   * resulting in crash, if the destination object size is smaller than that 
       
    93   * of the source.
       
    94   * @param 		aSrc TDes8 object
       
    95   * @param 		aDes wide-character pointer, to which the resultant string will be copied.
       
    96   * @return		returns an integer value.
       
    97   * @return		Api returns -1 in case of any error.
       
    98   */
       
    99 IMPORT_C int tbuf8towchar(TDes8& aSrc, wchar_t* aDes);
       
   100 	
       
   101 /**
       
   102   * This Api converts the tbuf16 to a wide-character string. It is user
       
   103   * responsibality to allocate a required size of wide-char object. Api may
       
   104   * resulting in crash, if the destination object size is smaller than
       
   105   * that of the source.
       
   106   * @param 		aSrc TDes16 object
       
   107   * @param 		aDes wide-character pointer, to which the resultant string will be copied.
       
   108   * @return		none
       
   109   */
       
   110 IMPORT_C void tbufC16towchar(TDesC& aSrc ,wchar_t* aDes);
       
   111 
       
   112   
       
   113  /**
       
   114   * This Api converts the tbufC8 to a character string. It is user 
       
   115   * responsibality to allocate a required size of wide-char object. Api may
       
   116   * resulting in crash, if the destination object size is smaller than
       
   117   * that of the source.
       
   118   * @param 		aSrc TDesC8 object
       
   119   * @param 		aDes character pointer, to which the resultant string will be copied.
       
   120   * @return		none
       
   121   */
       
   122   
       
   123 IMPORT_C void tbufC8tochar(TDesC8& aSrc, char* aDes);
       
   124 
       
   125 /**
       
   126   * This Api converts the TBufC16 to a character string. It is user
       
   127   *	responsibality to allocate a required size of wide-char object. Api may
       
   128   * resulting in crash, if the destination object size is smaller than
       
   129   * that of the source.
       
   130   * @param 		aSrc TDesC object
       
   131   * @param 		aDes character pointer, to which the resultant string will be copied.
       
   132   * @return		returns an integer value.
       
   133   * @return		Api returns -1 in case of any error.
       
   134   */
       
   135 IMPORT_C int tbufC16tochar(TDesC& aSrc, char* aDes);
       
   136 	
       
   137 	
       
   138 /**
       
   139   * This Api converts the TBufC8 to a wide-character string. It is user 
       
   140   * responsibality to allocate a required size of wide-char object. Api may
       
   141   * resulting in crash, if the destination object size is smaller than
       
   142   * that of the source.
       
   143   *	@param 		aSrc TDesC8 object
       
   144   * @param 		aDes wide-character pointer, to which the resultant string will be copied.
       
   145   *	@return		returns an integer value.
       
   146   * @return		Api returns -1 in case of any error.
       
   147   */
       
   148 IMPORT_C int tbufC8towchar(TDesC8& aSrc, wchar_t* aDes);
       
   149 
       
   150 
       
   151 /**
       
   152   * Functions to convert C character and
       
   153   * Wide-Character strings to SYMBIAN descriptors 
       
   154   */
       
   155 
       
   156 /**
       
   157   * This Api converts the wide-char to a TBuf16. It is user responsibality 
       
   158   * to allocate a required size of TBuf16 object. Api may	resulting in crash,
       
   159   * if the destination object size is smaller than	that of the source.
       
   160   * @param 		aSrc wide-character pointer.
       
   161   * @param 		aDes TBuf16 object, to which the resultant string will be copied.
       
   162   * @return		none
       
   163   */
       
   164 IMPORT_C void wchartotbuf16(const wchar_t *aSrc, TDes16& aDes);
       
   165 	
       
   166 
       
   167  /**
       
   168   * This Api converts the char to a TBuf16. It is user responsibality 
       
   169   * to allocate a required size of TBuf16 object. Api may	resulting in crash,
       
   170   * if the destination object size is smaller than	that of the source.
       
   171   * @param 		aSrc character pointer.
       
   172   * @param 		aDes TBuf16 object, to which the resultant string will be copied.
       
   173   * @return		returns an integer value.
       
   174   * @return		Api returns -1 in case of any error.
       
   175   */
       
   176 IMPORT_C int chartotbuf16(const char* aSrc, TDes16& aDes);
       
   177 	
       
   178 /**
       
   179   * This Api converts the wide-char string to a TBuf8. It is user 
       
   180   * responsibality to allocate a required size of TBuf8 object. Api may
       
   181   *	resulting in crash, if the destination object size is smaller than
       
   182   * that of the source.
       
   183   * @param 		aSrc 	wide-character pointer.
       
   184   * @param 		aDes	TBuf8 object, to which the resultant string will be copied.
       
   185   * @return		returns an integer value.
       
   186   * @return		Api returns -1 in case of any error.
       
   187   */
       
   188 IMPORT_C int wchartotbuf8(const wchar_t* aSrc, TDes8& aDes);
       
   189 
       
   190 
       
   191  /*
       
   192   * This Api converts the character string to a TBuf8. It is user 
       
   193   *	responsibality to allocate a required size of TBuf8 object. Api may	
       
   194   * resulting in crash, if the destination object size is smaller than
       
   195   * that of the source.
       
   196   * @param 		aSrc character pointer.
       
   197   * @param 		aDes TBuf8 object, to which the resultant string will be copied.
       
   198   *	@return		none
       
   199   */
       
   200 IMPORT_C void chartotbuf8(const char* aSrc, TDes8& aDes);
       
   201 
       
   202 
       
   203  /**
       
   204   * This Api converts the wide-char to a HBufC16. It is user responsibality 
       
   205   * to allocate a required size of HBufC16 object. Api may resulting in crash,
       
   206   * if the destination object size is smaller than	that of the source.
       
   207   * @param 		aSrc wide-character pointer.
       
   208   * @param 		aDes HBufC16 object, to which the resultant string will be copied.
       
   209   * @return		none
       
   210   */
       
   211 IMPORT_C void wchartohbufc16(const wchar_t* aSrc, HBufC16& aDes);
       
   212 	
       
   213 
       
   214  /**
       
   215   * This Api converts the char to a HBufC16. It is user responsibality 
       
   216   * to allocate a required size of HBufC16 object. Api may resulting in crash,
       
   217   * if the destination object size is smaller than	that of the source.
       
   218   * @param 		aSrc character pointer.
       
   219   * @param 		aDes HBufC16 object, to which the resultant string will be copied.
       
   220   * @return		returns an integer value.
       
   221   * @return		Api returns -1 in case of any error.
       
   222   */
       
   223 IMPORT_C int chartohbufc16(const char* aSrc, HBufC16& aDes);
       
   224 	
       
   225 /**
       
   226   * This Api converts the wide-char to a HBufC8. It is user responsibality 
       
   227   * to allocate a required size of HBufC8 object. Api may resulting in crash,
       
   228   * if the destination object size is smaller than	that of the source.
       
   229   * @param 		aSrc wide-character pointer.
       
   230   * @param 		aDes HBufC8 object, to which the resultant string will be copied.
       
   231   * @return		returns an integer value.
       
   232   * @return		Api returns -1 in case of any error.
       
   233   */
       
   234 IMPORT_C int wchartohbufc8(const wchar_t* aSrc, HBufC8& aDes);
       
   235 
       
   236   
       
   237  /*
       
   238   * This Api converts the char to a HBufC8. It is user responsibality 
       
   239   * to allocate a required size of HBufC8 object. Api may resulting in crash,
       
   240   * if the destination object size is smaller than	that of the source.
       
   241   * @param 		aSrc character pointer.
       
   242   * @param 		aDes HBufC8 object, to which the resultant string will be copied.
       
   243   * @return		none
       
   244   */
       
   245 IMPORT_C void chartohbufc8(const char* aSrc, HBufC8& aDes);
       
   246 
       
   247 
       
   248 	
       
   249 #endif //__STRINGUTILS_H__