Medical Imaging Interaction Toolkit
2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
|
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 |
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.
WARNING: Please be aware that using setlocale and there for is not thread safe. So use this class with care (see task T24295 for more information. This switch is especially use full if you have to deal with third party code where you have to control the locale via set locale
If you just want to control you own stringstream operations use imbue instead, as it is threadsafe. E.G.:
Definition at line 57 of file mitkLocaleSwitch.h.
|
explicit |
mitk::LocaleSwitch::~LocaleSwitch | ( | ) |
|
delete |
|
delete |