utilitylibraries/libutils/src/stringtodescriptor8.cpp
changeset 34 5fae379060a7
parent 0 e4d67989cc36
child 57 2efc27d87e1c
equal deleted inserted replaced
31:ce057bb09d0b 34:5fae379060a7
    77    * Converts a string to a descriptor of type TPtr8
    77    * Converts a string to a descriptor of type TPtr8
    78    *
    78    *
    79    * @param aSrc is the string to be converted , aDes is the 
    79    * @param aSrc is the string to be converted , aDes is the 
    80    * reference to the descriptor where the result of conversion 
    80    * reference to the descriptor where the result of conversion 
    81    * is stored
    81    * is stored
    82    * @return Status code (0 is ESuccess, -3 is EStringNoData)
    82    * @return Status code (0 is ESuccess, -3 is EStringNoData, -1 is EInsufficientMemory)
    83    */
    83    */
    84 
    84 
    85 EXPORT_C  int StringToTptr8 (string& aSrc, TPtr8& aDes)
    85 EXPORT_C  int StringToTptr8 (string& aSrc, TPtr8& aDes)
    86 {
    86 {
    87     const char* charString = aSrc.c_str();
    87     const char* charString = aSrc.c_str();
   108    *
   108    *
   109    * @param aSrc is the string to be converted , aDes is the 
   109    * @param aSrc is the string to be converted , aDes is the 
   110    * reference to the descriptor where the result of conversion 
   110    * reference to the descriptor where the result of conversion 
   111    * is stored 
   111    * is stored 
   112    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   112    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   113    * -3 is EStringNoData , -5 is EUSENEWMAXL )
   113    * -3 is EStringNoData , -5 is EUseNewMaxL , -4 is EInvalidPointer )
   114    */
   114    */
   115 
   115 
   116 EXPORT_C int StringToHbufc8(string& aSrc , HBufC8* aDes)
   116 EXPORT_C int StringToHbufc8(string& aSrc , HBufC8* aDes)
   117 {
   117 {
   118     unsigned int ilendes = 0;
   118     unsigned int ilendes = 0;
   146    * Converts a string to a descriptor of type RBuf8
   146    * Converts a string to a descriptor of type RBuf8
   147    *
   147    *
   148    * @param aSrc is the string to be converted , aDes is the 
   148    * @param aSrc is the string to be converted , aDes is the 
   149    * reference to the descriptor where the result of conversion 
   149    * reference to the descriptor where the result of conversion 
   150    * is stored
   150    * is stored
   151    * @return Status code (0 is ESuccess,-3 is EStringNoData)
   151    * @return Status code (0 is ESuccess,-3 is EStringNoData, -9 is EInsufficientSystemMemory)
   152    */  
   152    */  
   153 
   153 
   154 EXPORT_C int StringToRbuf8(const string& aSrc, RBuf8& aDes)
   154 EXPORT_C int StringToRbuf8(const string& aSrc, RBuf8& aDes)
   155 {
   155 {
   156     int retval = ESuccess;
   156     int retval = ESuccess;
   159     {
   159     {
   160         return EStringNoData;
   160         return EStringNoData;
   161     }
   161     }
   162     
   162     
   163     int ilen = strlen(charString);
   163     int ilen = strlen(charString);
   164     
   164 
   165     if (KErrNone == aDes.Create(ilen))
   165     aDes.Copy((const unsigned char *)charString, ilen);	
   166     {
       
   167     	aDes.Copy((const unsigned char *)charString, ilen);	
       
   168     }
       
   169 	else 
       
   170 	{
       
   171         retval = EInsufficientSystemMemory;	
       
   172 	}
       
   173 	
   166 	
   174 	return retval;
   167 	  return retval;
   175 }
   168 }