From: ouv Date: Mon, 2 Nov 2009 12:21:39 +0000 (+0000) Subject: Kernel_Utils::Localizer - common interface to solve problems with non-"C" locales X-Git-Tag: V5_1_3rc2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8119db8624e8f19ce3cddd5c0809beaa23804673;p=modules%2Fkernel.git Kernel_Utils::Localizer - common interface to solve problems with non-"C" locales --- diff --git a/src/Basics/Basics_Utils.cxx b/src/Basics/Basics_Utils.cxx index 10a12b74a..3be1e68c2 100644 --- a/src/Basics/Basics_Utils.cxx +++ b/src/Basics/Basics_Utils.cxx @@ -82,4 +82,14 @@ namespace Kernel_Utils return p; } + Localizer::Localizer() + { + myCurLocale = setlocale(LC_NUMERIC, 0); + setlocale(LC_NUMERIC, "C"); + } + + Localizer::~Localizer() + { + setlocale(LC_NUMERIC, myCurLocale.c_str()); + } } diff --git a/src/Basics/Basics_Utils.hxx b/src/Basics/Basics_Utils.hxx index ed99361c7..fe6736562 100644 --- a/src/Basics/Basics_Utils.hxx +++ b/src/Basics/Basics_Utils.hxx @@ -34,6 +34,15 @@ namespace Kernel_Utils { BASICS_EXPORT std::string GetHostname(); + + class Localizer + { + public: + Localizer(); + ~Localizer(); + private: + std::string myCurLocale; + }; } #endif //_Basics_UTILS_HXX_ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index ccde0d3ef..2b24641ad 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -28,6 +28,8 @@ using namespace std; +#include + #include "DF_Application.hxx" #include "DF_ChildIterator.hxx" @@ -48,23 +50,6 @@ using namespace std; #define VARIABLE_SEPARATOR ':' #define OPERATION_SEPARATOR '|' -// auxilary class intended to fix problems with locales -class Localizer -{ -public: - Localizer() - { - myCurLocale = setlocale(LC_NUMERIC, 0); - setlocale(LC_NUMERIC, "C"); - } - ~Localizer() - { - setlocale(LC_NUMERIC, myCurLocale.c_str()); - } -private: - std::string myCurLocale; -}; - //============================================================================ /*! Function : SALOMEDSImpl_Study * Purpose : SALOMEDSImpl_Study constructor @@ -922,7 +907,7 @@ string SALOMEDSImpl_Study::_GetStudyVariablesScript() if(myNoteBookVars.empty()) return dump; - Localizer loc; + Kernel_Utils::Localizer loc; dump += "####################################################\n"; dump += "## Begin of NoteBook variables section ##\n";