vtdata library
Public Member Functions | Protected Attributes | List of all members
ScopedLocale Class Reference

Public Member Functions

 ScopedLocale (int category, const char *locale_string)
 See the C function setlocale() for an explanation of the arguments.
 

Protected Attributes

std::string m_old_locale
 

Detailed Description

The locale might be set to something strange, ala European. that interprets '.' as ',' and vice versa. That terribly breaks VTP's usage of printf/sscanf/atof to encode and parse numbers.

This handy class encapsulates overriding the locale. Use it like this for 'standard' numbers:

Example:
ScopedLocale normal_numbers(LC_NUMERIC, "C");
The locale will be restored when the ScopedLocale object goes out of scope.