sprpimpl.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. *
  6. * Copyright (C) 2003-2006, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. *******************************************************************************
  10. * file name: sprpimpl.h
  11. * encoding: UTF-8
  12. * tab size: 8 (not used)
  13. * indentation:4
  14. *
  15. * created on: 2003feb1
  16. * created by: Ram Viswanadha
  17. */
  18. #ifndef SPRPIMPL_H
  19. #define SPRPIMPL_H
  20. #include "unicode/utypes.h"
  21. #if !UCONFIG_NO_IDNA
  22. #include "unicode/ustring.h"
  23. #include "unicode/parseerr.h"
  24. #include "unicode/usprep.h"
  25. #include "unicode/udata.h"
  26. #include "utrie.h"
  27. #include "udataswp.h"
  28. #include "ubidi_props.h"
  29. #define _SPREP_DATA_TYPE "spp"
  30. enum UStringPrepType{
  31. USPREP_UNASSIGNED = 0x0000 ,
  32. USPREP_MAP = 0x0001 ,
  33. USPREP_PROHIBITED = 0x0002 ,
  34. USPREP_DELETE = 0x0003 ,
  35. USPREP_TYPE_LIMIT = 0x0004
  36. };
  37. typedef enum UStringPrepType UStringPrepType;
  38. #ifdef USPREP_TYPE_NAMES_ARRAY
  39. static const char* usprepTypeNames[] ={
  40. "UNASSIGNED" ,
  41. "MAP" ,
  42. "PROHIBITED" ,
  43. "DELETE",
  44. "TYPE_LIMIT"
  45. };
  46. #endif
  47. enum{
  48. _SPREP_NORMALIZATION_ON = 0x0001,
  49. _SPREP_CHECK_BIDI_ON = 0x0002
  50. };
  51. enum{
  52. _SPREP_TYPE_THRESHOLD = 0xFFF0,
  53. _SPREP_MAX_INDEX_VALUE = 0x3FBF, /*16139*/
  54. _SPREP_MAX_INDEX_TOP_LENGTH = 0x0003
  55. };
  56. /* indexes[] value names */
  57. enum {
  58. _SPREP_INDEX_TRIE_SIZE = 0, /* number of bytes in StringPrep trie */
  59. _SPREP_INDEX_MAPPING_DATA_SIZE = 1, /* The array that contains the mapping */
  60. _SPREP_NORM_CORRECTNS_LAST_UNI_VERSION = 2, /* The index of Unicode version of last entry in NormalizationCorrections.txt */
  61. _SPREP_ONE_UCHAR_MAPPING_INDEX_START = 3, /* The starting index of 1 UChar mapping index in the mapping data array */
  62. _SPREP_TWO_UCHARS_MAPPING_INDEX_START = 4, /* The starting index of 2 UChars mapping index in the mapping data array */
  63. _SPREP_THREE_UCHARS_MAPPING_INDEX_START = 5, /* The starting index of 3 UChars mapping index in the mapping data array */
  64. _SPREP_FOUR_UCHARS_MAPPING_INDEX_START = 6, /* The starting index of 4 UChars mapping index in the mapping data array */
  65. _SPREP_OPTIONS = 7, /* Bit set of options to turn on in the profile */
  66. _SPREP_INDEX_TOP=16 /* changing this requires a new formatVersion */
  67. };
  68. typedef struct UStringPrepKey UStringPrepKey;
  69. struct UStringPrepKey{
  70. char* name;
  71. char* path;
  72. };
  73. struct UStringPrepProfile{
  74. int32_t indexes[_SPREP_INDEX_TOP];
  75. UTrie sprepTrie;
  76. const uint16_t* mappingData;
  77. UDataMemory* sprepData;
  78. int32_t refCount;
  79. UBool isDataLoaded;
  80. UBool doNFKC;
  81. UBool checkBiDi;
  82. };
  83. /**
  84. * Helper function for populating the UParseError struct
  85. * @internal
  86. */
  87. U_CAPI void U_EXPORT2
  88. uprv_syntaxError(const UChar* rules,
  89. int32_t pos,
  90. int32_t rulesLen,
  91. UParseError* parseError);
  92. /**
  93. * Swap StringPrep .spp profile data. See udataswp.h.
  94. * @internal
  95. */
  96. U_CAPI int32_t U_EXPORT2
  97. usprep_swap(const UDataSwapper *ds,
  98. const void *inData, int32_t length, void *outData,
  99. UErrorCode *pErrorCode);
  100. #endif /* #if !UCONFIG_NO_IDNA */
  101. #endif
  102. /*
  103. * Hey, Emacs, please set the following:
  104. *
  105. * Local Variables:
  106. * indent-tabs-mode: nil
  107. * End:
  108. *
  109. */