2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2015-02-06 18:23:07 +00:00
|
|
|
#ifndef cmLocale_h
|
|
|
|
#define cmLocale_h
|
|
|
|
|
2017-08-25 18:39:02 +00:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2016-09-01 18:05:48 +00:00
|
|
|
|
2019-09-06 20:58:06 +00:00
|
|
|
#include <clocale>
|
2016-12-25 09:51:34 +00:00
|
|
|
#include <string>
|
2015-02-06 18:23:07 +00:00
|
|
|
|
|
|
|
class cmLocaleRAII
|
|
|
|
{
|
|
|
|
public:
|
2016-05-16 14:34:04 +00:00
|
|
|
cmLocaleRAII()
|
2017-08-22 21:42:36 +00:00
|
|
|
: OldLocale(setlocale(LC_CTYPE, nullptr))
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
2015-02-06 18:23:07 +00:00
|
|
|
setlocale(LC_CTYPE, "");
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2019-01-23 19:30:01 +00:00
|
|
|
|
2016-12-25 09:51:34 +00:00
|
|
|
~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale.c_str()); }
|
2017-04-21 19:46:58 +00:00
|
|
|
|
2019-01-23 19:30:01 +00:00
|
|
|
cmLocaleRAII(cmLocaleRAII const&) = delete;
|
|
|
|
cmLocaleRAII& operator=(cmLocaleRAII const&) = delete;
|
|
|
|
|
2017-04-21 19:46:58 +00:00
|
|
|
private:
|
|
|
|
std::string OldLocale;
|
2015-02-06 18:23:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|