ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itk::NumericLocale Class Reference

#include <itkNumericLocale.h>

Detailed Description

RAII class for thread-safe temporary setting of LC_NUMERIC locale to "C".

This class provides a thread-safe mechanism to temporarily set the LC_NUMERIC locale to "C" for locale-independent parsing and formatting of floating-point numbers. The original locale is automatically restored when the object goes out of scope.

This is particularly useful when parsing file formats that use dot as decimal separator (like NRRD, VTK, etc.) regardless of the system locale setting.

Thread safety:

  • On POSIX systems (when newlocale/uselocale are available): Uses thread-local locale
  • On Windows (when _configthreadlocale is available): Uses thread-specific locale
  • Fallback (when neither is available): Issues a warning if locale differs from "C", but does not change the locale. Applications must manage locale externally.

Example usage:

{
NumericLocale cLocale;
// Parse file with dot decimal separator
double value = std::strtod("3.14159", nullptr);
// Locale automatically restored here
}

Definition at line 58 of file itkNumericLocale.h.

+ Collaboration diagram for itk::NumericLocale:

Public Member Functions

 NumericLocale ()
 
 NumericLocale (const NumericLocale &)=delete
 
 NumericLocale (NumericLocale &&)=delete
 
NumericLocaleoperator= (const NumericLocale &)=delete
 
NumericLocaleoperator= (NumericLocale &&)=delete
 
 ~NumericLocale ()
 

Private Attributes

std::unique_ptr< Impl > m_Impl
 

Constructor & Destructor Documentation

◆ NumericLocale() [1/3]

itk::NumericLocale::NumericLocale ( )

Constructor: Saves current LC_NUMERIC locale and sets it to "C"

Referenced by NumericLocale(), NumericLocale(), operator=(), and operator=().

◆ ~NumericLocale()

itk::NumericLocale::~NumericLocale ( )

Destructor: Restores the original LC_NUMERIC locale

◆ NumericLocale() [2/3]

itk::NumericLocale::NumericLocale ( const NumericLocale & )
delete

References NumericLocale().

◆ NumericLocale() [3/3]

itk::NumericLocale::NumericLocale ( NumericLocale && )
delete

References NumericLocale().

Member Function Documentation

◆ operator=() [1/2]

NumericLocale & itk::NumericLocale::operator= ( const NumericLocale & )
delete

References NumericLocale().

◆ operator=() [2/2]

NumericLocale & itk::NumericLocale::operator= ( NumericLocale && )
delete

References NumericLocale().

Member Data Documentation

◆ m_Impl

std::unique_ptr<Impl> itk::NumericLocale::m_Impl
private

Definition at line 79 of file itkNumericLocale.h.


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