transliterator_class.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: Gustavo Lopes <cataphract@netcabo.pt> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef TRANSLITERATOR_CLASS_H
  17. #define TRANSLITERATOR_CLASS_H
  18. #include <php.h>
  19. #include "intl_common.h"
  20. #include "intl_error.h"
  21. #include <unicode/utrans.h>
  22. typedef struct {
  23. zend_object zo;
  24. // error handling
  25. intl_error err;
  26. // ICU transliterator
  27. UTransliterator* utrans;
  28. } Transliterator_object;
  29. #define TRANSLITERATOR_FORWARD UTRANS_FORWARD
  30. #define TRANSLITERATOR_REVERSE UTRANS_REVERSE
  31. #define TRANSLITERATOR_ERROR( co ) (co)->err
  32. #define TRANSLITERATOR_ERROR_P( co ) &(TRANSLITERATOR_ERROR( co ))
  33. #define TRANSLITERATOR_ERROR_CODE( co ) INTL_ERROR_CODE(TRANSLITERATOR_ERROR( co ))
  34. #define TRANSLITERATOR_ERROR_CODE_P( co ) &(INTL_ERROR_CODE(TRANSLITERATOR_ERROR( co )))
  35. #define TRANSLITERATOR_METHOD_INIT_VARS INTL_METHOD_INIT_VARS( Transliterator, to )
  36. #define TRANSLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK INTL_METHOD_FETCH_OBJECT( Transliterator, to )
  37. #define TRANSLITERATOR_METHOD_FETCH_OBJECT\
  38. TRANSLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; \
  39. if( to->utrans == NULL ) \
  40. { \
  41. intl_errors_set( &to->err, U_ILLEGAL_ARGUMENT_ERROR, "Found unconstructed transliterator", 0 TSRMLS_CC ); \
  42. RETURN_FALSE; \
  43. }
  44. int transliterator_object_construct( zval *object,
  45. UTransliterator *utrans,
  46. UErrorCode *status TSRMLS_DC );
  47. void transliterator_register_Transliterator_class( TSRMLS_D );
  48. extern zend_class_entry *Transliterator_ce_ptr;
  49. extern zend_object_handlers Transliterator_handlers;
  50. #endif /* #ifndef TRANSLITERATOR_CLASS_H */