KiCad PCB EDA Suite
LOCALE_IO Class Reference

Instantiate the current locale within a scope in which you are expecting exceptions to be thrown. More...

#include <locale_io.h>

Public Member Functions

 LOCALE_IO ()
 
 ~LOCALE_IO ()
 

Private Attributes

std::string m_user_locale
 
wxLocale * m_wxLocale
 

Static Private Attributes

static std::atomic< unsigned int > m_c_count
 

Detailed Description

Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.

The constructor sets a "C" language locale option, to read/print files with floating point numbers. The destructor insures that the default locale is restored if an exception is thrown or not.

Definition at line 40 of file locale_io.h.

Constructor & Destructor Documentation

◆ LOCALE_IO()

LOCALE_IO::LOCALE_IO ( )

Definition at line 30 of file locale_io.cpp.

30  : m_wxLocale( nullptr )
31 {
32  // use thread safe, atomic operation
33  if( m_c_count++ == 0 )
34  {
35  m_wxLocale = new wxLocale( "C", "C", "C", false );
36  }
37 }
wxLocale * m_wxLocale
Definition: locale_io.h:53
static std::atomic< unsigned int > m_c_count
Definition: locale_io.h:48

References m_c_count, and m_wxLocale.

◆ ~LOCALE_IO()

LOCALE_IO::~LOCALE_IO ( )

Definition at line 40 of file locale_io.cpp.

41 {
42  // use thread safe, atomic operation
43  if( --m_c_count == 0 )
44  {
45  delete m_wxLocale; // Deleting m_wxLocale restored previous locale
46  m_wxLocale = nullptr;
47  }
48 }
wxLocale * m_wxLocale
Definition: locale_io.h:53
static std::atomic< unsigned int > m_c_count
Definition: locale_io.h:48

References m_c_count, and m_wxLocale.

Member Data Documentation

◆ m_c_count

std::atomic< unsigned int > LOCALE_IO::m_c_count
staticprivate

Definition at line 48 of file locale_io.h.

Referenced by LOCALE_IO(), and ~LOCALE_IO().

◆ m_user_locale

std::string LOCALE_IO::m_user_locale
private

Definition at line 52 of file locale_io.h.

◆ m_wxLocale

wxLocale* LOCALE_IO::m_wxLocale
private

Definition at line 53 of file locale_io.h.

Referenced by LOCALE_IO(), and ~LOCALE_IO().


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