Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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 46 of file mitkLocaleSwitch.h.

Constructor & Destructor Documentation

◆ LocaleSwitch() [1/3]

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

Definition at line 64 of file mitkLocaleSwitch.cpp.

◆ ~LocaleSwitch() [1/2]

mitk::LocaleSwitch::~LocaleSwitch ( )

Definition at line 65 of file mitkLocaleSwitch.cpp.

◆ LocaleSwitch() [2/3]

mitk::LocaleSwitch::LocaleSwitch ( LocaleSwitch )
delete

◆ LocaleSwitch() [3/3]

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

Definition at line 36 of file mitkMAPRegistrationWrapperIO.cpp.

References MITK_INFO.

◆ ~LocaleSwitch() [2/2]

Member Function Documentation

◆ operator=()

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

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