Annotation of embedaddon/php/ext/intl/collator/collator_attr.c, revision 1.1
1.1 ! misho 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: #ifdef HAVE_CONFIG_H
! 19: #include "config.h"
! 20: #endif
! 21:
! 22: #include "php_intl.h"
! 23: #include "collator_class.h"
! 24: #include "collator_convert.h"
! 25: #include "collator_attr.h"
! 26:
! 27: #include <unicode/ustring.h>
! 28:
! 29: /* {{{ proto int Collator::getAttribute( int $attr )
! 30: * Get collation attribute value. }}} */
! 31: /* {{{ proto int collator_get_attribute( Collator $coll, int $attr )
! 32: * Get collation attribute value.
! 33: */
! 34: PHP_FUNCTION( collator_get_attribute )
! 35: {
! 36: long attribute, value;
! 37:
! 38: COLLATOR_METHOD_INIT_VARS
! 39:
! 40: /* Parse parameters. */
! 41: if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
! 42: &object, Collator_ce_ptr, &attribute ) == FAILURE )
! 43: {
! 44: intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
! 45: "collator_get_attribute: unable to parse input params", 0 TSRMLS_CC );
! 46:
! 47: RETURN_FALSE;
! 48: }
! 49:
! 50: /* Fetch the object. */
! 51: COLLATOR_METHOD_FETCH_OBJECT;
! 52:
! 53: value = ucol_getAttribute( co->ucoll, attribute, COLLATOR_ERROR_CODE_P( co ) );
! 54: COLLATOR_CHECK_STATUS( co, "Error getting attribute value" );
! 55:
! 56: RETURN_LONG( value );
! 57: }
! 58: /* }}} */
! 59:
! 60: /* {{{ proto bool Collator::getAttribute( int $attr )
! 61: * Get collation attribute value. }}} */
! 62: /* {{{ proto bool collator_set_attribute( Collator $coll, int $attr, int $val )
! 63: * Set collation attribute.
! 64: */
! 65: PHP_FUNCTION( collator_set_attribute )
! 66: {
! 67: long attribute, value;
! 68: COLLATOR_METHOD_INIT_VARS
! 69:
! 70:
! 71: /* Parse parameters. */
! 72: if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll",
! 73: &object, Collator_ce_ptr, &attribute, &value ) == FAILURE)
! 74: {
! 75: intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
! 76: "collator_set_attribute: unable to parse input params", 0 TSRMLS_CC );
! 77:
! 78: RETURN_FALSE;
! 79: }
! 80:
! 81: /* Fetch the object. */
! 82: COLLATOR_METHOD_FETCH_OBJECT;
! 83:
! 84: /* Set new value for the given attribute. */
! 85: ucol_setAttribute( co->ucoll, attribute, value, COLLATOR_ERROR_CODE_P( co ) );
! 86: COLLATOR_CHECK_STATUS( co, "Error setting attribute value" );
! 87:
! 88: RETURN_TRUE;
! 89: }
! 90: /* }}} */
! 91:
! 92: /* {{{ proto int Collator::getStrength()
! 93: * Returns the current collation strength. }}} */
! 94: /* {{{ proto int collator_get_strength(Collator coll)
! 95: * Returns the current collation strength.
! 96: */
! 97: PHP_FUNCTION( collator_get_strength )
! 98: {
! 99: COLLATOR_METHOD_INIT_VARS
! 100:
! 101: /* Parse parameters. */
! 102: if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
! 103: &object, Collator_ce_ptr ) == FAILURE )
! 104: {
! 105: intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
! 106: "collator_get_strength: unable to parse input params", 0 TSRMLS_CC );
! 107:
! 108: RETURN_FALSE;
! 109: }
! 110:
! 111: /* Fetch the object. */
! 112: COLLATOR_METHOD_FETCH_OBJECT;
! 113:
! 114: /* Get current strength and return it. */
! 115: RETURN_LONG( ucol_getStrength( co->ucoll ) );
! 116: }
! 117: /* }}} */
! 118:
! 119: /* {{{ proto bool Collator::setStrength(int strength)
! 120: * Set the collation strength. }}} */
! 121: /* {{{ proto bool collator_set_strength(Collator coll, int strength)
! 122: * Set the collation strength.
! 123: */
! 124: PHP_FUNCTION( collator_set_strength )
! 125: {
! 126: long strength;
! 127:
! 128: COLLATOR_METHOD_INIT_VARS
! 129:
! 130: /* Parse parameters. */
! 131: if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
! 132: &object, Collator_ce_ptr, &strength ) == FAILURE )
! 133: {
! 134: intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
! 135: "collator_set_strength: unable to parse input params", 0 TSRMLS_CC );
! 136:
! 137: RETURN_FALSE;
! 138: }
! 139:
! 140: /* Fetch the object. */
! 141: COLLATOR_METHOD_FETCH_OBJECT;
! 142:
! 143: /* Set given strength. */
! 144: ucol_setStrength( co->ucoll, strength );
! 145:
! 146: RETURN_TRUE;
! 147: }
! 148: /* }}} */
! 149:
! 150: /*
! 151: * Local variables:
! 152: * tab-width: 4
! 153: * c-basic-offset: 4
! 154: * End:
! 155: * vim600: noet sw=4 ts=4 fdm=marker
! 156: * vim<600: noet sw=4 ts=4
! 157: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>