Krita Source Code Documentation
Loading...
Searching...
No Matches
AutoSetAndRestoreThreadLocale Class Reference

#include <kis_context_thread_locale.h>

Public Member Functions

 AutoSetAndRestoreThreadLocale ()
 
 ~AutoSetAndRestoreThreadLocale ()
 

Private Attributes

locale_t currentLocale
 
locale_t oldLocale
 

Detailed Description

Definition at line 20 of file kis_context_thread_locale.h.

Constructor & Destructor Documentation

◆ AutoSetAndRestoreThreadLocale()

AutoSetAndRestoreThreadLocale::AutoSetAndRestoreThreadLocale ( )
inline

Definition at line 23 of file kis_context_thread_locale.h.

24 {
25#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
26 // set locale will only change locale on the current thread
27 previousThreadConfig = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
28
29 // get and store current locale
30 ssaLocale.assign(setlocale(LC_ALL, NULL));
31
32 // set to "C" locale
33 setlocale(LC_ALL, "C");
34#else
35 // set to C locale, saving the old one (returned from useLocale)
36 currentLocale = newlocale(LC_ALL_MASK, "C", NULL);
37 oldLocale = uselocale(currentLocale);
38#endif
39 }

References currentLocale, and oldLocale.

◆ ~AutoSetAndRestoreThreadLocale()

AutoSetAndRestoreThreadLocale::~AutoSetAndRestoreThreadLocale ( )
inline

Definition at line 41 of file kis_context_thread_locale.h.

42 {
43#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
44 // thread specific
45 setlocale(LC_ALL, ssaLocale.c_str());
46
47 // set back to global settings]
48 _configthreadlocale(previousThreadConfig);
49#else
50 // restore the previous locale and freeing the created locale
51 uselocale(oldLocale);
52 freelocale(currentLocale);
53#endif
54 }

References currentLocale, and oldLocale.

Member Data Documentation

◆ currentLocale

locale_t AutoSetAndRestoreThreadLocale::currentLocale
private

Definition at line 62 of file kis_context_thread_locale.h.

◆ oldLocale

locale_t AutoSetAndRestoreThreadLocale::oldLocale
private

Definition at line 61 of file kis_context_thread_locale.h.


The documentation for this class was generated from the following file: