intl_error.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. +----------------------------------------------------------------------+
  3. | This source file is subject to version 3.01 of the PHP license, |
  4. | that is bundled with this package in the file LICENSE, and is |
  5. | available through the world-wide-web at the following url: |
  6. | https://www.php.net/license/3_01.txt |
  7. | If you did not receive a copy of the PHP license and are unable to |
  8. | obtain it through the world-wide-web, please send a note to |
  9. | license@php.net so we can mail you a copy immediately. |
  10. +----------------------------------------------------------------------+
  11. | Authors: Vadim Savchuk <vsavchuk@productengine.com> |
  12. | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
  13. | Stanislav Malyshev <stas@zend.com> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef INTL_ERROR_H
  17. #define INTL_ERROR_H
  18. #include <unicode/utypes.h>
  19. #include <unicode/parseerr.h>
  20. #include <zend_smart_str.h>
  21. #define INTL_ERROR_CODE(e) (e).code
  22. typedef struct _intl_error {
  23. UErrorCode code;
  24. int free_custom_error_message;
  25. char* custom_error_message;
  26. } intl_error;
  27. intl_error* intl_error_create( void );
  28. void intl_error_init( intl_error* err );
  29. void intl_error_reset( intl_error* err );
  30. void intl_error_set_code( intl_error* err, UErrorCode err_code );
  31. void intl_error_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
  32. void intl_error_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
  33. UErrorCode intl_error_get_code( intl_error* err );
  34. zend_string* intl_error_get_message( intl_error* err );
  35. // Wrappers to synchonize object's and global error structures.
  36. void intl_errors_reset( intl_error* err );
  37. void intl_errors_set_custom_msg( intl_error* err, const char* msg, int copyMsg );
  38. void intl_errors_set_code( intl_error* err, UErrorCode err_code );
  39. void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, int copyMsg );
  40. // Other error helpers
  41. smart_str intl_parse_error_to_string( UParseError* pe );
  42. #endif // INTL_ERROR_H