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