cmLocale.h 549 B

123456789101112131415161718192021222324252627
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmLocale_h
  4. #define cmLocale_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <locale.h>
  7. #include <string>
  8. class cmLocaleRAII
  9. {
  10. CM_DISABLE_COPY(cmLocaleRAII)
  11. public:
  12. cmLocaleRAII()
  13. : OldLocale(setlocale(LC_CTYPE, nullptr))
  14. {
  15. setlocale(LC_CTYPE, "");
  16. }
  17. ~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale.c_str()); }
  18. private:
  19. std::string OldLocale;
  20. };
  21. #endif