numparse_utils.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // © 2018 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. #include "unicode/utypes.h"
  4. #if !UCONFIG_NO_FORMATTING
  5. #ifndef __NUMPARSE_UTILS_H__
  6. #define __NUMPARSE_UTILS_H__
  7. #include "numparse_types.h"
  8. #include "unicode/uniset.h"
  9. U_NAMESPACE_BEGIN namespace numparse {
  10. namespace impl {
  11. namespace utils {
  12. inline static void putLeadCodePoints(const UnicodeSet* input, UnicodeSet* output) {
  13. for (int32_t i = 0; i < input->getRangeCount(); i++) {
  14. output->add(input->getRangeStart(i), input->getRangeEnd(i));
  15. }
  16. // TODO: ANDY: How to iterate over the strings in ICU4C UnicodeSet?
  17. }
  18. inline static void putLeadCodePoint(const UnicodeString& input, UnicodeSet* output) {
  19. if (!input.isEmpty()) {
  20. output->add(input.char32At(0));
  21. }
  22. }
  23. inline static void copyCurrencyCode(UChar* dest, const UChar* src) {
  24. uprv_memcpy(dest, src, sizeof(UChar) * 3);
  25. dest[3] = 0;
  26. }
  27. } // namespace utils
  28. } // namespace impl
  29. } // namespace numparse
  30. U_NAMESPACE_END
  31. #endif //__NUMPARSE_UTILS_H__
  32. #endif /* #if !UCONFIG_NO_FORMATTING */