Back to index

php5  5.3.10
resourcebundle.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: Hans-Peter Oeri (University of St.Gallen) <hp@oeri.ch>      |
00014    +----------------------------------------------------------------------+
00015  */
00016 
00017 #include <unicode/ures.h>
00018 
00019 #include <zend.h>
00020 #include <zend_API.h>
00021 
00022 #include "intl_convert.h"
00023 #include "intl_data.h"
00024 #include "resourcebundle/resourcebundle_class.h"
00025 
00026 /* {{{ ResourceBundle_extract_value */
00027 void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *source TSRMLS_DC ) 
00028 {
00029        UResType               restype;
00030        const UChar*           ufield;
00031        const uint8_t*         bfield;
00032        const int32_t*         vfield;
00033        int32_t                ilen;
00034        int                    i;
00035        long                   lfield;
00036        ResourceBundle_object* newrb;
00037 
00038        restype = ures_getType( source->child );
00039        switch (restype)
00040        {
00041               case URES_STRING:
00042                      ufield = ures_getString( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
00043                      INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve string value");
00044                      INTL_METHOD_RETVAL_UTF8(source, ufield, ilen, 0);
00045                      break;
00046 
00047               case URES_BINARY:
00048                      bfield = ures_getBinary( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
00049                      INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve binary value");
00050                      ZVAL_STRINGL( return_value, (char *) bfield, ilen, 1 );
00051                      break;
00052 
00053               case URES_INT:
00054                      lfield = ures_getInt( source->child, &INTL_DATA_ERROR_CODE(source) );
00055                      INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve integer value");
00056                      ZVAL_LONG( return_value, lfield );
00057                      break;
00058 
00059               case URES_INT_VECTOR:
00060                      vfield = ures_getIntVector( source->child, &ilen, &INTL_DATA_ERROR_CODE(source) );
00061                      INTL_METHOD_CHECK_STATUS(source, "Failed to retrieve vector value");
00062                      array_init( return_value );
00063                      for (i=0; i<ilen; i++) {
00064                             add_next_index_long( return_value, vfield[i] );
00065                      }
00066                      break;
00067 
00068               case URES_ARRAY:
00069               case URES_TABLE:
00070                      object_init_ex( return_value, ResourceBundle_ce_ptr );
00071                      newrb = (ResourceBundle_object *) zend_object_store_get_object( return_value TSRMLS_CC );
00072                      newrb->me = source->child;
00073                      source->child = NULL;
00074                      intl_errors_reset(INTL_DATA_ERROR_P(source) TSRMLS_CC);
00075                      break;
00076 
00077               default:
00078                      intl_errors_set(INTL_DATA_ERROR_P(source), U_ILLEGAL_ARGUMENT_ERROR, "Unknown resource type", 0 TSRMLS_CC);
00079                      RETURN_FALSE;
00080                      break;
00081        }
00082 }
00083 /* }}} */
00084 
00085 /*
00086  * Local variables:
00087  * tab-width: 4
00088  * c-basic-offset: 4
00089  * End:
00090  * vim600: noet sw=4 ts=4 fdm=marker
00091  * vim<600: noet sw=4 ts=4
00092  */