From 3d7d251bfcb4a5ae3e722eccf6a79a566adfb218 Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Wed, 12 Jun 2013 15:10:02 +0900 Subject: [PATCH] Change to use _LocalizedNumParser in IO Change-Id: I3d3380fe38f17151ff41efb26b1403b4f705a59a Signed-off-by: Sunwook Bae --- src/io/FIo_RegistryCore.cpp | 8 ++-- src/io/FIo_RegistryImpl.cpp | 93 +++++++++++++------------------------------ src/io/inc/FIo_RegistryImpl.h | 4 -- 3 files changed, 32 insertions(+), 73 deletions(-) diff --git a/src/io/FIo_RegistryCore.cpp b/src/io/FIo_RegistryCore.cpp index 4fde00e..2c916bb 100644 --- a/src/io/FIo_RegistryCore.cpp +++ b/src/io/FIo_RegistryCore.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include "FIo_FileImpl.h" #include "FIo_NormalRegistry.h" @@ -1477,7 +1478,6 @@ _RegistryCore::DecodeData(const String& strValueEncoded, _RegValueType type, voi // for positive values. { double retDoubleVal = 0; - result r = E_SUCCESS; if (*pSize != sizeof(double)) { @@ -1485,10 +1485,12 @@ _RegistryCore::DecodeData(const String& strValueEncoded, _RegValueType type, voi return; } - r = Double::Parse(strValueEncoded, retDoubleVal); - SysTryReturnVoidResult(NID_IO, !IsFailed(r), E_PARSING_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + retDoubleVal = _LocalizedNumParser::ToDouble(strValueEncoded, "C"); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_IO, r == E_SUCCESS, E_PARSING_FAILED, "[%s] Propagated.", GetErrorMessage(r)); *(double*) pValue = retDoubleVal; + break; } diff --git a/src/io/FIo_RegistryImpl.cpp b/src/io/FIo_RegistryImpl.cpp index 9b01f77..9d0f2c2 100644 --- a/src/io/FIo_RegistryImpl.cpp +++ b/src/io/FIo_RegistryImpl.cpp @@ -20,11 +20,7 @@ */ #include -#include #include -#include -#include -#include #include #include @@ -40,6 +36,7 @@ #include #include +#include #include #include #include @@ -58,17 +55,12 @@ static const int _MAX_REG_OPENMODE_LENGTH = 2; _RegistryImpl::_RegistryImpl(void) : __pRegistryCore(null) - , __loc((locale_t)0) { } _RegistryImpl::~_RegistryImpl(void) { delete __pRegistryCore; - if (__loc != (locale_t)0) - { - freelocale(__loc); - } } bool @@ -140,13 +132,6 @@ _RegistryImpl::Construct(const String& regPath, const char* pOpenMode, const Byt __pRegistryCore = pSecureRegistry.release(); } - __loc = newlocale(LC_ALL_MASK, "C", (locale_t)0); - if (__loc == (locale_t)0) - { - SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to create locale object. errno: %d (%s)", - errno, strerror(errno)); - } - return r; } @@ -211,36 +196,32 @@ result _RegistryImpl::GetValue(const String& sectionName, const String& entryName, float& entryValue) { String value; - uselocale(__loc); - result r = GetValue(sectionName, entryName, value); - if (!IsFailed(r)) - { - r = Float::Parse(value, entryValue); - if (IsFailed(r)) - { - r = E_PARSING_FAILED; - } - } - uselocale(LC_GLOBAL_LOCALE); - return r; + result r = __pRegistryCore->GetValue(sectionName, entryName, value); + SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Propagated.", GetErrorMessage(r)); + + float fValue = _LocalizedNumParser::ToFloat(value, "C"); + r = GetLastResult(); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_PARSING_FAILED, "Failed to parse the data."); + + entryValue = fValue; + + return E_SUCCESS; } result _RegistryImpl::GetValue(const String& sectionName, const String& entryName, double& entryValue) { String value; - uselocale(__loc); - result r = GetValue(sectionName, entryName, value); - if (!IsFailed(r)) - { - r = Double::Parse(value, entryValue); - if (IsFailed(r)) - { - r = E_PARSING_FAILED; - } - } - uselocale(LC_GLOBAL_LOCALE); - return r; + result r = __pRegistryCore->GetValue(sectionName, entryName, value); + SysTryReturn(NID_IO, r == E_SUCCESS, r, r, "[%s] Propagated.", GetErrorMessage(r)); + + double dValue = _LocalizedNumParser::ToDouble(value, "C"); + r = GetLastResult(); + SysTryReturnResult(NID_IO, r == E_SUCCESS, E_PARSING_FAILED, "Failed to parse the data."); + + entryValue = dValue; + + return E_SUCCESS; } result @@ -253,19 +234,13 @@ _RegistryImpl::GetValue(const String& sectionName, const String& entryName, Stri result _RegistryImpl::AddValue(const String& sectionName, const String& entryName, float entryValue) { - uselocale(__loc); - result r = AddValue(sectionName, entryName, Float::ToString(entryValue)); - uselocale(LC_GLOBAL_LOCALE); - return r; + return AddValue(sectionName, entryName, _LocalizedNumParser::ToString(entryValue, "C")); } result _RegistryImpl::AddValue(const String& sectionName, const String& entryName, double entryValue) { - uselocale(__loc); - result r = AddValue(sectionName, entryName, Double::ToString(entryValue)); - uselocale(LC_GLOBAL_LOCALE); - return r; + return AddValue(sectionName, entryName, _LocalizedNumParser::ToString(entryValue, "C")); } result @@ -278,19 +253,13 @@ _RegistryImpl::AddValue(const String& sectionName, const String& entryName, cons result _RegistryImpl::SetValue(const String& sectionName, const String& entryName, float entryValue) { - uselocale(__loc); - result r = SetValue(sectionName, entryName, Float::ToString(entryValue)); - uselocale(LC_GLOBAL_LOCALE); - return r; + return SetValue(sectionName, entryName, _LocalizedNumParser::ToString(entryValue, "C")); } result _RegistryImpl::SetValue(const String& sectionName, const String& entryName, double entryValue) { - uselocale(__loc); - result r = SetValue(sectionName, entryName, Double::ToString(entryValue)); - uselocale(LC_GLOBAL_LOCALE); - return r; + return SetValue(sectionName, entryName, _LocalizedNumParser::ToString(entryValue, "C")); } result @@ -381,16 +350,8 @@ void _RegistryImpl::GetEntryValue(int sectionIndex, int entryIndex, _RegValueType type, void* pValue, int* pSize) { SysAssertf(__pRegistryCore != null, "Not yet constructed. Construct() should be called before use.\n"); - if (type == REG_VALUE_TYPE_REAL) - { - uselocale(__loc); - __pRegistryCore->GetEntryValue(sectionIndex, entryIndex, type, pValue, pSize); - uselocale(LC_GLOBAL_LOCALE); - } - else - { - __pRegistryCore->GetEntryValue(sectionIndex, entryIndex, type, pValue, pSize); - } + + __pRegistryCore->GetEntryValue(sectionIndex, entryIndex, type, pValue, pSize); } String diff --git a/src/io/inc/FIo_RegistryImpl.h b/src/io/inc/FIo_RegistryImpl.h index 3662b72..5153d28 100644 --- a/src/io/inc/FIo_RegistryImpl.h +++ b/src/io/inc/FIo_RegistryImpl.h @@ -24,10 +24,8 @@ #ifndef _FIO_INTERNAL_REGISTRY_IMPL_H_ #define _FIO_INTERNAL_REGISTRY_IMPL_H_ -#include #include #include -#include namespace Tizen {namespace Base { @@ -171,8 +169,6 @@ private: _RegistryCore* __pRegistryCore; - locale_t __loc; - }; // _RegistryImpl }} // Tizen::Io -- 2.7.4