Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::LocaleSwitch Struct Reference

Convenience class to temporarily change the current locale. More...

#include <mitkLocaleSwitch.h>

Public Member Functions

 LocaleSwitch (const char *newLocale)
 
 ~LocaleSwitch ()
 
 LocaleSwitch (LocaleSwitch &)=delete
 
LocaleSwitch operator= (LocaleSwitch &)=delete
 
 LocaleSwitch (const std::string &newLocale)
 
 ~LocaleSwitch ()
 

Detailed Description

Convenience class to temporarily change the current locale.

This helper class can be used to switch to a specific locale for a couple of operations. Once the class is destroyed, the previous locale will be restored. This avoids calling or forgetting to call setlocale() in multiple return locations.

Typically this is used to switch to a "C" locale when parsing or printing numbers, in order to consistently get "." and not "," as a decimal separator.

std::string toString(int number)
{
mitk::LocaleSwitch localeSwitch("C");// installs C locale until the end of the function
std::stringstream parser;
parser << number;
return parser.str();
}

Helper structure to change (and reset) the local settings in a function scope

Definition at line 50 of file mitkLocaleSwitch.h.

Constructor & Destructor Documentation

mitk::LocaleSwitch::LocaleSwitch ( const char *  newLocale)
explicit

Definition at line 68 of file mitkLocaleSwitch.cpp.

mitk::LocaleSwitch::~LocaleSwitch ( )

Definition at line 69 of file mitkLocaleSwitch.cpp.

mitk::LocaleSwitch::LocaleSwitch ( LocaleSwitch )
delete
mitk::LocaleSwitch::LocaleSwitch ( const std::string &  newLocale)
inline

Definition at line 40 of file mitkMAPRegistrationWrapperIO.cpp.

References MITK_INFO.

mitk::LocaleSwitch::~LocaleSwitch ( )
inline

Definition at line 59 of file mitkMAPRegistrationWrapperIO.cpp.

References MITK_INFO.

Member Function Documentation

LocaleSwitch mitk::LocaleSwitch::operator= ( LocaleSwitch )
delete

The documentation for this struct was generated from the following files: