Numbers.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef RUNTIME_PLATFORM_AGNOSTIC_COMMON_NUMBERS
  6. #define RUNTIME_PLATFORM_AGNOSTIC_COMMON_NUMBERS
  7. namespace PlatformAgnostic
  8. {
  9. namespace Numbers
  10. {
  11. class Utility
  12. {
  13. #ifndef ENABLE_GLOBALIZATION
  14. class NumbersLocale
  15. {
  16. WCHAR localeThousands;
  17. WCHAR localeDecimal;
  18. WCHAR localeNegativeSign;
  19. int maxDigitsAfterDecimals;
  20. WCHAR defaultDecimalDot;
  21. WCHAR defaultDecimalComma;
  22. public:
  23. NumbersLocale();
  24. inline int GetMaxDigitsAfterDecimals() { return maxDigitsAfterDecimals; }
  25. inline WCHAR GetLocaleThousands() { return localeThousands; }
  26. inline bool HasLocaleThousands() { return localeThousands != 0; }
  27. inline WCHAR GetLocaleDecimal() { return localeDecimal; }
  28. inline WCHAR GetLocaleNegativeSign() { return localeNegativeSign; }
  29. inline bool IsDecimalPoint(const WCHAR wc)
  30. { return wc == defaultDecimalDot
  31. || wc == defaultDecimalComma; }
  32. };
  33. // non-ICU implementation keeps user locale intact process wide
  34. // xplat-todo: While implementing ICU option, make both per context.
  35. static NumbersLocale numbersLocale;
  36. #endif
  37. public:
  38. static size_t NumberToDefaultLocaleString(const WCHAR *number_string,
  39. const size_t length,
  40. WCHAR *buffer,
  41. const size_t pre_allocated_buffer_size);
  42. };
  43. } // namespace Numbers
  44. } // namespace PlatformAgnostic
  45. #endif // RUNTIME_PLATFORM_AGNOSTIC_COMMON_NUMBERS