xref: /PHP-7.0/ext/intl/intl_error.h (revision 122d7596)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
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    |          Stanislav Malyshev <stas@zend.com>                          |
16    +----------------------------------------------------------------------+
17  */
18 
19 #ifndef INTL_ERROR_H
20 #define INTL_ERROR_H
21 
22 #include <unicode/utypes.h>
23 #include <unicode/parseerr.h>
24 #include <zend_smart_str.h>
25 
26 #define INTL_ERROR_CODE(e) (e).code
27 
28 typedef struct _intl_error {
29 	UErrorCode      code;
30 	char*           custom_error_message;
31 	int             free_custom_error_message;
32 } intl_error;
33 
34 intl_error* intl_error_create( void );
35 void        intl_error_init( intl_error* err );
36 void        intl_error_reset( intl_error* err );
37 void        intl_error_set_code( intl_error* err, UErrorCode err_code );
38 void        intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
39 void        intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
40 UErrorCode  intl_error_get_code( intl_error* err );
41 zend_string* intl_error_get_message( intl_error* err );
42 
43 // Wrappers to synchonize object's and global error structures.
44 void        intl_errors_reset( intl_error* err );
45 void        intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
46 void        intl_errors_set_code( intl_error* err, UErrorCode err_code );
47 void        intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
48 
49 // Other error helpers
50 smart_str	intl_parse_error_to_string( UParseError* pe );
51 
52 // exported to be called on extension MINIT
53 void		intl_register_IntlException_class( void );
54 
55 #endif // INTL_ERROR_H
56