return null;
}
-IList*
-_EncodingCore::GetAvailableEncodingsN(void)
-{
- ClearLastResult();
- result r = E_SUCCESS;
-
- unique_ptr<LinkedList, AllElementsDeleter> pList(new (std::nothrow) LinkedList());
- SysTryReturn(NID_TEXT, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-
- _IcuEncodingCore icuConverter;
- _GsmEncodingCore gsmConverter;
- _Ucs2EncodingCore ucs2Converter;
- _Iso885916EncodingCore iso885916Converter;
-
- r = icuConverter.GetAvailableEncodingsN(pList.get());
- SysTryReturn(NID_TEXT, !IsFailed(r), null, r, "[%s] Available encoding list is empty. List allocation failed.", GetErrorMessage(r));
-
- r = gsmConverter.GetAvailableEncodingsN(pList.get());
- SysTryReturn(NID_TEXT, !IsFailed(r), null, r, "[%s] Available encoding list is empty. List allocation failed.", GetErrorMessage(r));
-
- r = ucs2Converter.GetAvailableEncodingsN(pList.get());
- SysTryReturn(NID_TEXT, !IsFailed(r), null, r, "[%s] Available encoding list is empty. List allocation failed.", GetErrorMessage(r));
-
- r = iso885916Converter.GetAvailableEncodingsN(pList.get());
- SysTryReturn(NID_TEXT, !IsFailed(r), null, r, "[%s] Available encoding list is empty. List allocation failed.", GetErrorMessage(r));
-
- return pList.release();
-}
byte*
_EncodingCore::ConvertN(_EncodingCore* pDstConverter, const byte* pSrc, int srcLength, int& retLength)
ClearLastResult();
result r = E_SUCCESS;
- std::unique_ptr<LinkedList, AllElementsDeleter> pList(new (std::nothrow) LinkedList());
+ std::unique_ptr< LinkedList > pList(new (std::nothrow) LinkedList(SingleObjectDeleter));
SysTryReturn(NID_TEXT, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
for (int i = 0; i < AVAILABLE_ENCODING_COUNT; i++)
{
- String* pEncodingStr = new (std::nothrow) String(availableEncodings[i]);
+ std::unique_ptr< String > pEncodingStr(new (std::nothrow) String(availableEncodings[i]));
SysTryReturn(NID_TEXT, pEncodingStr, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
- r = pList->Add(*pEncodingStr);
- if(IsFailed(r))
- {
- delete pEncodingStr;
- SysTryReturn(NID_TEXT, !IsFailed(r), null, r, "[%s] Unable to add encoding to list", GetErrorMessage(r));
- }
+ r = pList->Add(*(pEncodingStr.get()));
+ SysTryReturn(NID_TEXT, !IsFailed(r), null, r, "[%s] Unable to add encoding to list", GetErrorMessage(r));
+ pEncodingStr.release();
}
return pList.release();
_EncodingCore*
_GsmEncodingCore::GetEncodingCoreImplN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo)
{
- if (encodingFrom != L"GSM")
- {
- SetLastResult(E_UNSUPPORTED_TYPE);
- return null;
- }
-
+ SysTryReturn(NID_TEXT, encodingFrom == L"GSM", null, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE] It is the unsupported type.");
_GsmEncodingCore* pEncoderDecoder = new (std::nothrow) _GsmEncodingCore;
SysTryReturn(NID_TEXT, pEncoderDecoder, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-
return pEncoderDecoder;
}
-result
-_GsmEncodingCore::GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList)
-{
- SysTryReturnResult(NID_TEXT, pEncodingList, E_INVALID_ARG,
- "[%s] Invalid argument is used. Input encoding list is null", GetErrorMessage(E_INVALID_ARG));
-
- String* pEncodingStr = new (std::nothrow) String(L"GSM");
- SysTryReturnResult(NID_TEXT, pEncodingStr, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-
- result r = pEncodingList->Add(*pEncodingStr);
- if (IsFailed(r))
- {
- delete pEncodingStr;
- return r;
- }
- return E_SUCCESS;
-}
String
_GsmEncodingCore::GetName(void)
~_GsmEncodingCore(void);
static _EncodingCore* GetEncodingCoreImplN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo);
- virtual result GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList);
virtual result GetByteCount(const wchar_t* pSrc, int srcLength, int& retLength);
virtual result GetCharCount(const byte* pSrc, int srcLength, int& retLength);
return byteCount / (ucnv_getMinCharSize(__pEncoder));
}
-result
-_IcuEncodingCore::GetAvailableEncodingsN(IList* pEncodingList)
-{
- SysTryReturnResult(NID_TEXT, pEncodingList, E_INVALID_ARG, "[%s] Invalid argument is used.Input encoding list is null", GetErrorMessage(E_INVALID_ARG));
-
- result r = E_SUCCESS;
- int count = ucnv_countAvailable();
- SysTryReturnResult(NID_TEXT, count > 0, E_SYSTEM, "[%s] Unable to get available encoding list count.", GetErrorMessage(E_SYSTEM));
-
- String* pEncodingStr = null;
- for (int i = 0; i < count; i++)
- {
- pEncodingStr = new (std::nothrow) String(ucnv_getAvailableName(i));
- SysTryReturnResult(NID_TEXT, pEncodingStr, E_OUT_OF_MEMORY, "[%s] Memory allocationfailed", GetErrorMessage(E_OUT_OF_MEMORY));
-
- r = pEncodingList->Add(*pEncodingStr);
- if (IsFailed(r))
- {
- delete pEncodingStr;
- return r;
- }
- }
-
- for (int i = 0; i < EXTRA_ENCODINGS_LENGTH; i++)
- {
- pEncodingStr = new (std::nothrow) String(extraEncodings[i]);
- SysTryReturnResult(NID_TEXT, pEncodingStr, E_OUT_OF_MEMORY, "[%s] Memory allocationfailed", GetErrorMessage(E_OUT_OF_MEMORY));
-
- r = pEncodingList->Add(*pEncodingStr);
- if (IsFailed(r))
- {
- delete pEncodingStr;
- return r;
- }
- }
-
- return E_SUCCESS;
-}
result
_IcuEncodingCore::GetResultFromIcuErrorCode(UErrorCode& err)
virtual ~_IcuEncodingCore(void);
static _EncodingCore* GetEncodingCoreImplN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo);
- result GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList);
virtual result GetByteCount(const wchar_t* pSrc, int srcLength, int& retLength);
virtual result GetCharCount(const byte* pSrc, int srcLength, int& retLength);
_EncodingCore*
_Iso885916EncodingCore::GetEncodingCoreImplN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo)
{
- if (encodingFrom != L"ISO-8859-16")
- {
- SetLastResult(E_UNSUPPORTED_TYPE);
- return null;
- }
-
+ SysTryReturn(NID_TEXT, encodingFrom == L"ISO-8859-16", null, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE] It is the unsupported type.");
_Iso885916EncodingCore* pEncodingCore = new (std::nothrow) _Iso885916EncodingCore;
SysTryReturn(NID_TEXT, pEncodingCore, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-
return pEncodingCore;
}
-result
-_Iso885916EncodingCore::GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList)
-{
- SysTryReturnResult(NID_TEXT, pEncodingList, E_INVALID_ARG,
- "[%s] Invalid argument is used. Input encoding list is null", GetErrorMessage(E_INVALID_ARG));
-
- String* pEncodingStr = new (std::nothrow) String(L"ISO-8859-16");
- SysTryReturnResult(NID_TEXT, pEncodingStr, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-
- result r = pEncodingList->Add(*pEncodingStr);
- if (IsFailed(r))
- {
- delete pEncodingStr;
- return r;
- }
- return E_SUCCESS;
-}
String
_Iso885916EncodingCore::GetName(void)
~_Iso885916EncodingCore(void);
static _EncodingCore* GetEncodingCoreImplN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo);
- virtual result GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList);
virtual result GetByteCount(const wchar_t* pSrc, int srcLength, int& retLength);
virtual result GetCharCount(const byte* pSrc, int srcLength, int& retLength);
encodingStr.Replace(L"-", "");
encodingStr.Replace("_", "");
-
- if (!encodingStr.StartsWith(L"UCS2", 0))
- {
- SetLastResult(E_UNSUPPORTED_TYPE);
- return null;
- }
+
+ SysTryReturn(NID_TEXT, encodingStr.StartsWith(L"UCS2", 0), null, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE] It is the unsupported type");
if ((encodingStr == "UCS2") || (encodingStr == "UCS2BE") || (encodingStr == "UCS2LE"))
{
return null;
}
-result
-_Ucs2EncodingCore::GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList)
-{
- SysTryReturnResult(NID_TEXT, pEncodingList, E_INVALID_ARG,
- "[%s] Invalid argument is used. Input encoding list is null", GetErrorMessage(E_INVALID_ARG));
-
- result r = E_SUCCESS;
- String* pEncodingStr = null;
- for (int i = 0; i < SUPPORTED_ENCODINGS_LENGTH; i++)
- {
- pEncodingStr = new (std::nothrow) String(supportedEncodings[i]);
- SysTryReturnResult(NID_TEXT, pEncodingStr, E_OUT_OF_MEMORY, "Unable to allocate memory for encoding string.");
-
- r = pEncodingList->Add(*pEncodingStr);
- if (IsFailed(r))
- {
- delete pEncodingStr;
- return r;
- }
- }
-
- return r;
-}
String
_Ucs2EncodingCore::GetName(void)
~_Ucs2EncodingCore(void);
static _EncodingCore* GetEncodingCoreImplN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo);
- virtual result GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList);
virtual result GetByteCount(const wchar_t* pSrc, int srcLength, int& retLength);
virtual result GetCharCount(const byte* pSrc, int srcLength, int& retLength);
static _EncodingCore* GetEncodingCoreN(const Tizen::Base::String& encodingFrom, const Tizen::Base::String& encodingTo);
- static Tizen::Base::Collection::IList* GetAvailableEncodingsN(void);
-
- virtual result GetAvailableEncodingsN(Tizen::Base::Collection::IList* pEncodingList) = 0;
-
virtual result GetByteCount(const wchar_t* pSrc, int srcLength, int& retLength) = 0;
virtual result GetCharCount(const byte* pSrc, int srcLength, int& retLength) = 0;