collator.c 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. +----------------------------------------------------------------------+
  3. | This source file is subject to version 3.01 of the PHP license, |
  4. | that is bundled with this package in the file LICENSE, and is |
  5. | available through the world-wide-web at the following url: |
  6. | https://www.php.net/license/3_01.txt |
  7. | If you did not receive a copy of the PHP license and are unable to |
  8. | obtain it through the world-wide-web, please send a note to |
  9. | license@php.net so we can mail you a copy immediately. |
  10. +----------------------------------------------------------------------+
  11. | Authors: Vadim Savchuk <vsavchuk@productengine.com> |
  12. | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
  13. +----------------------------------------------------------------------+
  14. */
  15. #ifdef HAVE_CONFIG_H
  16. #include "config.h"
  17. #endif
  18. #include "collator_class.h"
  19. #include "collator.h"
  20. #include <unicode/utypes.h>
  21. #include <unicode/ucol.h>
  22. #include <unicode/ustring.h>
  23. /* {{{ collator_register_constants
  24. * Register constants common for the both (OO and procedural)
  25. * APIs.
  26. */
  27. void collator_register_constants( INIT_FUNC_ARGS )
  28. {
  29. if( !Collator_ce_ptr )
  30. {
  31. zend_error( E_ERROR, "Collator class not defined" );
  32. return;
  33. }
  34. #define COLLATOR_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
  35. #define COLLATOR_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( #x ) - 1, UCOL_##x );
  36. #define COLLATOR_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( name ) - 1, value );
  37. /* UColAttributeValue constants */
  38. COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "DEFAULT_VALUE", UCOL_DEFAULT );
  39. COLLATOR_EXPOSE_CLASS_CONST( PRIMARY );
  40. COLLATOR_EXPOSE_CLASS_CONST( SECONDARY );
  41. COLLATOR_EXPOSE_CLASS_CONST( TERTIARY );
  42. COLLATOR_EXPOSE_CLASS_CONST( DEFAULT_STRENGTH );
  43. COLLATOR_EXPOSE_CLASS_CONST( QUATERNARY );
  44. COLLATOR_EXPOSE_CLASS_CONST( IDENTICAL );
  45. COLLATOR_EXPOSE_CLASS_CONST( OFF );
  46. COLLATOR_EXPOSE_CLASS_CONST( ON );
  47. COLLATOR_EXPOSE_CLASS_CONST( SHIFTED );
  48. COLLATOR_EXPOSE_CLASS_CONST( NON_IGNORABLE );
  49. COLLATOR_EXPOSE_CLASS_CONST( LOWER_FIRST );
  50. COLLATOR_EXPOSE_CLASS_CONST( UPPER_FIRST );
  51. /* UColAttribute constants */
  52. COLLATOR_EXPOSE_CLASS_CONST( FRENCH_COLLATION );
  53. COLLATOR_EXPOSE_CLASS_CONST( ALTERNATE_HANDLING );
  54. COLLATOR_EXPOSE_CLASS_CONST( CASE_FIRST );
  55. COLLATOR_EXPOSE_CLASS_CONST( CASE_LEVEL );
  56. COLLATOR_EXPOSE_CLASS_CONST( NORMALIZATION_MODE );
  57. COLLATOR_EXPOSE_CLASS_CONST( STRENGTH );
  58. COLLATOR_EXPOSE_CLASS_CONST( HIRAGANA_QUATERNARY_MODE );
  59. COLLATOR_EXPOSE_CLASS_CONST( NUMERIC_COLLATION );
  60. /* ULocDataLocaleType constants */
  61. COLLATOR_EXPOSE_CONST( ULOC_ACTUAL_LOCALE );
  62. COLLATOR_EXPOSE_CONST( ULOC_VALID_LOCALE );
  63. /* sort flags */
  64. COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_REGULAR", COLLATOR_SORT_REGULAR );
  65. COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_STRING", COLLATOR_SORT_STRING );
  66. COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_NUMERIC", COLLATOR_SORT_NUMERIC );
  67. #undef COLLATOR_EXPOSE_CUSTOM_CLASS_CONST
  68. #undef COLLATOR_EXPOSE_CLASS_CONST
  69. #undef COLLATOR_EXPOSE_CONST
  70. }
  71. /* }}} */