From 8119db8624e8f19ce3cddd5c0809beaa23804673 Mon Sep 17 00:00:00 2001 From: ouv Date: Mon, 2 Nov 2009 12:21:39 +0000 Subject: [PATCH] Kernel_Utils::Localizer - common interface to solve problems with non-"C" locales --- src/Basics/Basics_Utils.cxx | 10 ++++++++++ src/Basics/Basics_Utils.hxx | 9 +++++++++ src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 21 +++------------------ 3 files changed, 22 insertions(+), 18 deletions(-) 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"; -- 2.39.2