Back to index

php5  5.3.10
formatter.c
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: Stanislav Malyshev <stas@zend.com>                          |
00014    +----------------------------------------------------------------------+
00015  */
00016 
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020 
00021 #include <unicode/utypes.h>
00022 #include <unicode/unum.h>
00023 #include <unicode/ustring.h>
00024 
00025 #include "php_intl.h"
00026 #include "formatter_class.h"
00027 #include "formatter_format.h"
00028 
00029 #if U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM <= 4
00030 #define UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL 17
00031 #endif
00032 
00033 /* {{{ formatter_register_constants
00034  * Register constants common for the both (OO and procedural)
00035  * APIs.
00036  */
00037 void formatter_register_constants( INIT_FUNC_ARGS )
00038 {
00039        if( NumberFormatter_ce_ptr == NULL) {
00040               zend_error(E_ERROR, "NumberFormatter class not defined");
00041        }
00042 
00043        #define FORMATTER_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS)
00044        #define FORMATTER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( NumberFormatter_ce_ptr, ZEND_STRS( #x ) - 1, UNUM_##x TSRMLS_CC );
00045        #define FORMATTER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( NumberFormatter_ce_ptr, ZEND_STRS( name ) - 1, value TSRMLS_CC );
00046 
00047        /* UNumberFormatStyle constants */
00048        FORMATTER_EXPOSE_CLASS_CONST( PATTERN_DECIMAL );
00049        FORMATTER_EXPOSE_CLASS_CONST( DECIMAL );
00050        FORMATTER_EXPOSE_CLASS_CONST( CURRENCY );
00051        FORMATTER_EXPOSE_CLASS_CONST( PERCENT );
00052        FORMATTER_EXPOSE_CLASS_CONST( SCIENTIFIC );
00053        FORMATTER_EXPOSE_CLASS_CONST( SPELLOUT );
00054        FORMATTER_EXPOSE_CLASS_CONST( ORDINAL );
00055        FORMATTER_EXPOSE_CLASS_CONST( DURATION );
00056        FORMATTER_EXPOSE_CLASS_CONST( PATTERN_RULEBASED );
00057        FORMATTER_EXPOSE_CLASS_CONST( IGNORE );
00058 
00059        FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "DEFAULT_STYLE",  UNUM_DEFAULT );
00060 
00061 /* workaround for ICU bug */
00062 #if U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM < 8
00063 #define UNUM_ROUND_HALFEVEN UNUM_FOUND_HALFEVEN
00064 #endif
00065 
00066        /* UNumberFormatRoundingMode */
00067        FORMATTER_EXPOSE_CLASS_CONST( ROUND_CEILING );
00068        FORMATTER_EXPOSE_CLASS_CONST( ROUND_FLOOR );
00069        FORMATTER_EXPOSE_CLASS_CONST( ROUND_DOWN );
00070        FORMATTER_EXPOSE_CLASS_CONST( ROUND_UP );
00071        FORMATTER_EXPOSE_CLASS_CONST( ROUND_HALFEVEN );
00072        FORMATTER_EXPOSE_CLASS_CONST( ROUND_HALFDOWN );
00073        FORMATTER_EXPOSE_CLASS_CONST( ROUND_HALFUP );
00074 
00075        /* UNumberFormatPadPosition */
00076        FORMATTER_EXPOSE_CLASS_CONST( PAD_BEFORE_PREFIX ); 
00077        FORMATTER_EXPOSE_CLASS_CONST( PAD_AFTER_PREFIX ); 
00078        FORMATTER_EXPOSE_CLASS_CONST( PAD_BEFORE_SUFFIX ); 
00079        FORMATTER_EXPOSE_CLASS_CONST( PAD_AFTER_SUFFIX );
00080 
00081        /* UNumberFormatAttribute */
00082        FORMATTER_EXPOSE_CLASS_CONST( PARSE_INT_ONLY ); 
00083        FORMATTER_EXPOSE_CLASS_CONST( GROUPING_USED ); 
00084        FORMATTER_EXPOSE_CLASS_CONST( DECIMAL_ALWAYS_SHOWN ); 
00085        FORMATTER_EXPOSE_CLASS_CONST( MAX_INTEGER_DIGITS );
00086        FORMATTER_EXPOSE_CLASS_CONST( MIN_INTEGER_DIGITS ); 
00087        FORMATTER_EXPOSE_CLASS_CONST( INTEGER_DIGITS ); 
00088        FORMATTER_EXPOSE_CLASS_CONST( MAX_FRACTION_DIGITS ); 
00089        FORMATTER_EXPOSE_CLASS_CONST( MIN_FRACTION_DIGITS );
00090        FORMATTER_EXPOSE_CLASS_CONST( FRACTION_DIGITS ); 
00091        FORMATTER_EXPOSE_CLASS_CONST( MULTIPLIER ); 
00092        FORMATTER_EXPOSE_CLASS_CONST( GROUPING_SIZE ); 
00093        FORMATTER_EXPOSE_CLASS_CONST( ROUNDING_MODE );
00094        FORMATTER_EXPOSE_CLASS_CONST( ROUNDING_INCREMENT ); 
00095        FORMATTER_EXPOSE_CLASS_CONST( FORMAT_WIDTH ); 
00096        FORMATTER_EXPOSE_CLASS_CONST( PADDING_POSITION ); 
00097        FORMATTER_EXPOSE_CLASS_CONST( SECONDARY_GROUPING_SIZE );
00098        FORMATTER_EXPOSE_CLASS_CONST( SIGNIFICANT_DIGITS_USED ); 
00099        FORMATTER_EXPOSE_CLASS_CONST( MIN_SIGNIFICANT_DIGITS ); 
00100        FORMATTER_EXPOSE_CLASS_CONST( MAX_SIGNIFICANT_DIGITS ); 
00101        FORMATTER_EXPOSE_CLASS_CONST( LENIENT_PARSE ); 
00102 
00103        /* UNumberFormatTextAttribute */
00104        FORMATTER_EXPOSE_CLASS_CONST( POSITIVE_PREFIX ); 
00105        FORMATTER_EXPOSE_CLASS_CONST( POSITIVE_SUFFIX ); 
00106        FORMATTER_EXPOSE_CLASS_CONST( NEGATIVE_PREFIX ); 
00107        FORMATTER_EXPOSE_CLASS_CONST( NEGATIVE_SUFFIX );
00108        FORMATTER_EXPOSE_CLASS_CONST( PADDING_CHARACTER ); 
00109        FORMATTER_EXPOSE_CLASS_CONST( CURRENCY_CODE ); 
00110        FORMATTER_EXPOSE_CLASS_CONST( DEFAULT_RULESET ); 
00111        FORMATTER_EXPOSE_CLASS_CONST( PUBLIC_RULESETS );
00112 
00113        /* UNumberFormatSymbol */
00114        FORMATTER_EXPOSE_CLASS_CONST( DECIMAL_SEPARATOR_SYMBOL ); 
00115        FORMATTER_EXPOSE_CLASS_CONST( GROUPING_SEPARATOR_SYMBOL ); 
00116        FORMATTER_EXPOSE_CLASS_CONST( PATTERN_SEPARATOR_SYMBOL ); 
00117        FORMATTER_EXPOSE_CLASS_CONST( PERCENT_SYMBOL );
00118        FORMATTER_EXPOSE_CLASS_CONST( ZERO_DIGIT_SYMBOL ); 
00119        FORMATTER_EXPOSE_CLASS_CONST( DIGIT_SYMBOL ); 
00120        FORMATTER_EXPOSE_CLASS_CONST( MINUS_SIGN_SYMBOL ); 
00121        FORMATTER_EXPOSE_CLASS_CONST( PLUS_SIGN_SYMBOL );
00122        FORMATTER_EXPOSE_CLASS_CONST( CURRENCY_SYMBOL ); 
00123        FORMATTER_EXPOSE_CLASS_CONST( INTL_CURRENCY_SYMBOL );
00124        FORMATTER_EXPOSE_CLASS_CONST( MONETARY_SEPARATOR_SYMBOL ); 
00125        FORMATTER_EXPOSE_CLASS_CONST( EXPONENTIAL_SYMBOL );
00126        FORMATTER_EXPOSE_CLASS_CONST( PERMILL_SYMBOL ); 
00127        FORMATTER_EXPOSE_CLASS_CONST( PAD_ESCAPE_SYMBOL );
00128        FORMATTER_EXPOSE_CLASS_CONST( INFINITY_SYMBOL );
00129        FORMATTER_EXPOSE_CLASS_CONST( NAN_SYMBOL );
00130        FORMATTER_EXPOSE_CLASS_CONST( SIGNIFICANT_DIGIT_SYMBOL );
00131        FORMATTER_EXPOSE_CLASS_CONST( MONETARY_GROUPING_SEPARATOR_SYMBOL ); 
00132 
00133        FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "TYPE_DEFAULT", FORMAT_TYPE_DEFAULT );
00134        FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "TYPE_INT32", FORMAT_TYPE_INT32 );
00135        FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "TYPE_INT64", FORMAT_TYPE_INT64 );
00136        FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "TYPE_DOUBLE", FORMAT_TYPE_DOUBLE );
00137        FORMATTER_EXPOSE_CUSTOM_CLASS_CONST( "TYPE_CURRENCY", FORMAT_TYPE_CURRENCY );
00138 
00139        #undef FORMATTER_EXPOSE_CUSTOM_CLASS_CONST
00140        #undef FORMATTER_EXPOSE_CLASS_CONST
00141        #undef FORMATTER_EXPOSE_CONST
00142 }
00143 /* }}} */
00144 
00145 /*
00146  * Local variables:
00147  * tab-width: 4
00148  * c-basic-offset: 4
00149  * End:
00150  * vim600: noet sw=4 ts=4 fdm=marker
00151  * vim<600: noet sw=4 ts=4
00152  */