collator_class.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef COLLATOR_CLASS_H
  18. #define COLLATOR_CLASS_H
  19. #include <php.h>
  20. #include "../intl_common.h"
  21. #include "../intl_error.h"
  22. #include "../intl_data.h"
  23. #include <unicode/ucol.h>
  24. typedef struct {
  25. zend_object zo;
  26. // error handling
  27. intl_error err;
  28. // ICU collator
  29. UCollator* ucoll;
  30. } Collator_object;
  31. #define COLLATOR_ERROR(co) (co)->err
  32. #define COLLATOR_ERROR_P(co) &(COLLATOR_ERROR(co))
  33. #define COLLATOR_ERROR_CODE(co) INTL_ERROR_CODE(COLLATOR_ERROR(co))
  34. #define COLLATOR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(COLLATOR_ERROR(co)))
  35. void collator_register_Collator_class( TSRMLS_D );
  36. void collator_object_init( Collator_object* co TSRMLS_DC );
  37. void collator_object_destroy( Collator_object* co TSRMLS_DC );
  38. extern zend_class_entry *Collator_ce_ptr;
  39. /* Auxiliary macros */
  40. #define COLLATOR_METHOD_INIT_VARS \
  41. zval* object = NULL; \
  42. Collator_object* co = NULL; \
  43. intl_error_reset( NULL TSRMLS_CC ); \
  44. #define COLLATOR_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(Collator, co)
  45. // Macro to check return value of a ucol_* function call.
  46. #define COLLATOR_CHECK_STATUS( co, msg ) \
  47. intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC ); \
  48. if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) ) \
  49. { \
  50. intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), msg, 0 TSRMLS_CC ); \
  51. RETURN_FALSE; \
  52. } \
  53. #endif // #ifndef COLLATOR_CLASS_H