Update contrib.
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Contains the source for Descriptor8 to char * conversions
25 * Converts a descriptor of type TBuf8 to char*
26 * @param aSrc is the descriptor of type TBuf8 that is to be converted to char*
27 * @param aDes is a char* that will hold the result after conversion. Care should be taken to
28 * allocate sufficient amount of memory to char* in the calling function. The amount of memory that is
29 * being allocated to the char* is being made known using n_size
30 * @param n_size is the size of the char*. This should have a minimum value equal to size of the
31 * descriptor. Incase its less, the conversion is going to fail and returns the corresponding error code
34 EXPORT_C int Tbuf8ToChar(TDes8& aSrc, char* aDes, int& n_size)
36 unsigned int ilen = aSrc.Length();
40 return EDescriptorNoData;
44 return EInvalidPointer;
46 else if (n_size < (ilen+1))
52 memcpy(aDes , (const char *)aSrc.Ptr(), ilen);
60 * Converts a descriptor of type TBufC8 to char*
61 * @param aSrc is the descriptor of type TBufC8 that is to be converted to char*
62 * @param aDes is a char* that will hold the result after conversion. Care should be taken to
63 * allocate sufficient amount of memory to char* in the calling function. The amount of memory that is
64 * being allocated to the char* is being made known using n_size
65 * @param n_size is the size of the char*. This should have a minimum value equal to size of the
66 * descriptor. Incase its less, the conversion is going to fail and returns the corresponding error code
69 EXPORT_C int Tbufc8ToChar(TDesC8& aSrc, char* aDes, int& n_size)
71 unsigned int ilen = aSrc.Length();
75 return EDescriptorNoData;
79 return EInvalidPointer;
81 else if(n_size < ilen+1)
87 memcpy(aDes, aSrc.Ptr(), ilen);
94 * Converts a descriptor of type TLitC8 to char*
95 * @param aSrc is the descriptor of type TLitC8 that is to be converted to char*
96 * @param aDes is a char* that will hold the result after conversion. Care should be taken to
97 * allocate sufficient amount of memory to char* in the calling function. The amount of memory that is
98 * being allocated to the char* is being made known using n_size
99 * @param n_size is the size of the char*. This should have a minimum value equal to size of the
100 * descriptor. Incase its less, the conversion is going to fail and returns the corresponding error code
103 EXPORT_C int Tlitc8ToChar(const TDesC8& aSrc, char* aDes, int& n_size)
105 unsigned int ilen = aSrc.Length();
109 return EDescriptorNoData;
113 return EInvalidPointer;
115 else if (n_size < ilen )
121 memcpy(aDes, (char *)aSrc.Ptr(), ilen);
129 * Converts a descriptor of type TPtr8 to character stream
131 * @param aSrc is the descriptor to be converted , aDes is the
132 * reference to the character sream where the result of conversion
133 * is stored , n_size specifies the conversion size of the string
134 * @return Status code (0 is ESuccess, -2 is EInvalidSize ,
135 * -4 is EInvalidPointer)
137 EXPORT_C int Tptr8ToChar(const TDes8& aSrc, char* aDes, int& n_size)
139 unsigned int ilen = aSrc.Length();
143 return EDescriptorNoData;
147 return EInvalidPointer;
149 else if (n_size < ilen)
155 memcpy(aDes , (const char *)aSrc.Ptr(), ilen);
162 * Converts a descriptor of type TPtrC8 to character stream
164 * @param aSrc is the descriptor to be converted , aDes is the
165 * reference to the character sream where the result of conversion
166 * is stored , n_size specifies the conversion size of the string
167 * @return Status code (0 is ESuccess, -2 is EInvalidSize ,
168 * -4 is EInvalidPointer)
170 EXPORT_C int Tptrc8ToCharp(TPtrC8& aSrc, char* aDes, int& n_size)
172 unsigned int ilen = aSrc.Length();
175 return EDescriptorNoData;
179 return EInvalidPointer;
181 else if (n_size < ilen)
187 memcpy(aDes , aSrc.Ptr(), ilen);
194 * Converts a descriptor of type RBuf8 to character stream
196 * @param aSrc is the descriptor to be converted , aDes is the
197 * reference to the character sream where the result of conversion
198 * is stored , n_size specifies the conversion size of the string
199 * @return Status code (0 is ESuccess, -2 is EInvalidSize ,
200 * -4 is EInvalidPointer , -5 is EDescriptorNoData)
203 EXPORT_C int Rbuf8ToChar(TDes8& aSrc, char* aDes, int& n_size)
205 unsigned int ilen = aSrc.Length();
209 return EDescriptorNoData;
213 return EInvalidPointer;
215 else if (n_size < ilen)
221 memcpy (aDes,(char *)aSrc.Ptr(), ilen);
228 * Converts a descriptor of type HBufC8 to character stream
230 * @param aSrc is the descriptor to be converted , aDes is the
231 * reference to the character sream where the result of conversion
232 * is stored , n_size specifies the conversion size of the string
233 * @return Status code (0 is ESuccess, -2 is EInvalidSize ,
234 * -4 is EInvalidPointer , -5 is EDescriptorNoData)
237 EXPORT_C int Hbufc8ToChar(HBufC8 *aSrc, char* aDes, int& n_size)
239 unsigned int ilen = 0;
243 return EInvalidPointer;
247 ilen = aSrc->Length();
250 return EDescriptorNoData;
252 else if (n_size < ilen)
259 memcpy (aDes,(char *)aSrc->Ptr(), ilen);