Back to index

php5  5.3.10
collator_class.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | This source file is subject to version 3.01 of the PHP license,      |
00006    | that is bundled with this package in the file LICENSE, and is        |
00007    | available through the world-wide-web at the following url:           |
00008    | http://www.php.net/license/3_01.txt                                  |
00009    | If you did not receive a copy of the PHP license and are unable to   |
00010    | obtain it through the world-wide-web, please send a note to          |
00011    | license@php.net so we can mail you a copy immediately.               |
00012    +----------------------------------------------------------------------+
00013    | Authors: Vadim Savchuk <vsavchuk@productengine.com>                  |
00014    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
00015    +----------------------------------------------------------------------+
00016  */
00017 
00018 #ifndef COLLATOR_CLASS_H
00019 #define COLLATOR_CLASS_H
00020 
00021 #include <php.h>
00022 
00023 #include "intl_common.h"
00024 #include "intl_error.h"
00025 
00026 #include <unicode/ucol.h>
00027 
00028 typedef struct {
00029        zend_object     zo;
00030 
00031        // error handling
00032        intl_error  err;
00033 
00034        // ICU collator
00035        UCollator*      ucoll;
00036 } Collator_object;
00037 
00038 #define COLLATOR_ERROR(co) (co)->err
00039 #define COLLATOR_ERROR_P(co) &(COLLATOR_ERROR(co))
00040 
00041 #define COLLATOR_ERROR_CODE(co)   INTL_ERROR_CODE(COLLATOR_ERROR(co))
00042 #define COLLATOR_ERROR_CODE_P(co) &(INTL_ERROR_CODE(COLLATOR_ERROR(co)))
00043 
00044 void collator_register_Collator_class( TSRMLS_D );
00045 void collator_object_init( Collator_object* co TSRMLS_DC );
00046 void collator_object_destroy( Collator_object* co TSRMLS_DC );
00047 
00048 extern zend_class_entry *Collator_ce_ptr;
00049 
00050 /* Auxiliary macros */
00051 
00052 #define COLLATOR_METHOD_INIT_VARS       \
00053     zval*             object  = NULL;   \
00054     Collator_object*  co      = NULL;   \
00055     intl_error_reset( NULL TSRMLS_CC ); \
00056 
00057 #define COLLATOR_METHOD_FETCH_OBJECT                                           \
00058     co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC ); \
00059     intl_error_reset( COLLATOR_ERROR_P( co ) TSRMLS_CC );                      \
00060 
00061 // Macro to check return value of a ucol_* function call.
00062 #define COLLATOR_CHECK_STATUS( co, msg )                                        \
00063     intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );           \
00064     if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) )                                \
00065     {                                                                           \
00066         intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), msg, 0 TSRMLS_CC ); \
00067         RETURN_FALSE;                                                           \
00068     }                                                                           \
00069 
00070 #endif // #ifndef COLLATOR_CLASS_H