Version: 9.15.0
Qtx::Localizer Class Reference

Localization helper. More...

#include <Qtx.h>

Public Member Functions

 Localizer ()
 Default constructor. Forces "C" locale to be set as LC_NUMERIC. More...
 
 Localizer (int, const char *)
 Constructor. Forces locale to be set for category. More...
 
 ~Localizer ()
 Destructor. Reverts back to the initial locale. More...
 

Private Member Functions

void init (int, const char *)
 Internal initialization. More...
 

Private Attributes

int myCategory
 
QString myOriginalLocale
 

Detailed Description

Localization helper.

This helper class can be used to solve the localization problems, usually related to the textual files reading/writing, namely when floating point values are read / written with API functions. The problem relates to such locale specific settings as decimal point separator, thousands separator, etc.

To use the Localizer class, just create a local variable in the beginning of the code where you need to read / write data from textual file(s). The constructor of the class forces setting "C" locale temporarily. The destructor switches back to the initial locale.

There are two ways to create a localizer. First constructor accepts category and locale value to be forced as parameters. The second constructor does not take parameters, and is just a shortcut to the first one, setting LC_NUMERIC as a category and "C" as a locale to force.

readSomething();
writeSomething();
Localization helper.
Definition: Qtx.h:151

Constructor & Destructor Documentation

◆ Localizer() [1/2]

Qtx::Localizer::Localizer ( )

Default constructor. Forces "C" locale to be set as LC_NUMERIC.

References init().

◆ Localizer() [2/2]

Qtx::Localizer::Localizer ( int  category,
const char *  locale 
)

Constructor. Forces locale to be set for category.

◆ ~Localizer()

Qtx::Localizer::~Localizer ( )

Destructor. Reverts back to the initial locale.

Member Function Documentation

◆ init()

void Qtx::Localizer::init ( int  category,
const char *  locale 
)
private

Internal initialization.

Member Data Documentation

◆ myCategory

int Qtx::Localizer::myCategory
private

◆ myOriginalLocale

QString Qtx::Localizer::myOriginalLocale
private

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