Open CASCADE Technology  7.2.0
Public Types | Public Member Functions | Static Public Member Functions

Standard_CLocaleSentry Class Reference

"xlocale.h" available in Mac OS X and glibc (Linux) for a long time as an extension and become part of POSIX since '2008. Notice that this is impossible to test (_POSIX_C_SOURCE >= 200809L) since POSIX didn't declared such identifier. More...

#include <Standard_CLocaleSentry.hxx>

Public Types

typedef void * clocale_t
 

Public Member Functions

 Standard_CLocaleSentry ()
 Setup current C locale to "C". More...
 
 ~Standard_CLocaleSentry ()
 Restore previous locale. More...
 

Static Public Member Functions

static clocale_t GetCLocale ()
 

Detailed Description

"xlocale.h" available in Mac OS X and glibc (Linux) for a long time as an extension and become part of POSIX since '2008. Notice that this is impossible to test (_POSIX_C_SOURCE >= 200809L) since POSIX didn't declared such identifier.

We check _GNU_SOURCE for glibc extensions here and it is always defined by g++ compiler. This class intended to temporary switch C locale and logically equivalent to setlocale(LC_ALL, "C"). It is intended to format text regardless of user locale settings (for import/export functionality). Thus following calls to sprintf, atoi and other functions will use "C" locale. Destructor of this class will return original locale.

Notice that this functionality is platfrom dependent and intended only to workaround alien code that doesn't setup locale correctly.

Internally you should prefer more portable C++ locale interfaces or OCCT wrappers to some C functions like Sprintf, Atof, Strtod.

Member Typedef Documentation

◆ clocale_t

Constructor & Destructor Documentation

◆ Standard_CLocaleSentry()

Standard_CLocaleSentry::Standard_CLocaleSentry ( )

Setup current C locale to "C".

◆ ~Standard_CLocaleSentry()

Standard_CLocaleSentry::~Standard_CLocaleSentry ( )

Restore previous locale.

Member Function Documentation

◆ GetCLocale()

static clocale_t Standard_CLocaleSentry::GetCLocale ( )
static
Returns
locale "C" instance (locale_t within xlocale or _locale_t within Windows) to be used for _l functions with locale argument.

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