collator.c 3.5 KB

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