Numbers.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace PlatformAgnostic
  7. {
  8. namespace Numbers
  9. {
  10. class Utility
  11. {
  12. #ifndef ENABLE_GLOBALIZATION
  13. class NumbersLocale
  14. {
  15. WCHAR localeThousands;
  16. WCHAR localeDecimal;
  17. WCHAR localeNegativeSign;
  18. int maxDigitsAfterDecimals;
  19. WCHAR defaultDecimalDot;
  20. WCHAR defaultDecimalComma;
  21. public:
  22. NumbersLocale();
  23. inline int GetMaxDigitsAfterDecimals() { return maxDigitsAfterDecimals; }
  24. inline WCHAR GetLocaleThousands() { return localeThousands; }
  25. inline bool HasLocaleThousands() { return localeThousands != 0; }
  26. inline WCHAR GetLocaleDecimal() { return localeDecimal; }
  27. inline WCHAR GetLocaleNegativeSign() { return localeNegativeSign; }
  28. inline bool IsDecimalPoint(const WCHAR wc)
  29. { return wc == defaultDecimalDot
  30. || wc == defaultDecimalComma; }
  31. };
  32. // non-ICU implementation keeps user locale intact process wide
  33. // xplat-todo: While implementing ICU option, make both per context.
  34. static NumbersLocale numbersLocale;
  35. #endif
  36. public:
  37. static size_t NumberToDefaultLocaleString(const WCHAR *number_string,
  38. const size_t length,
  39. WCHAR *buffer,
  40. const size_t pre_allocated_buffer_size);
  41. };
  42. } // namespace Numbers
  43. } // namespace PlatformAgnostic