Back to index

php5  5.3.10
Functions | Variables
resourcebundle_iterator.c File Reference
#include <php.h>
#include <zend.h>
#include <zend_API.h>
#include "resourcebundle/resourcebundle.h"
#include "resourcebundle/resourcebundle_class.h"
#include "resourcebundle/resourcebundle_iterator.h"

Go to the source code of this file.

Functions

static void resourcebundle_iterator_read (ResourceBundle_iterator *iterator TSRMLS_DC)
static void resourcebundle_iterator_invalidate (zend_object_iterator *iter TSRMLS_DC)
static void resourcebundle_iterator_dtor (zend_object_iterator *iter TSRMLS_DC)
static int resourcebundle_iterator_has_more (zend_object_iterator *iter TSRMLS_DC)
static void resourcebundle_iterator_current (zend_object_iterator *iter, zval ***data TSRMLS_DC)
static int resourcebundle_iterator_key (zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
static void resourcebundle_iterator_step (zend_object_iterator *iter TSRMLS_DC)
static void resourcebundle_iterator_reset (zend_object_iterator *iter TSRMLS_DC)
zend_object_iterator * resourcebundle_get_iterator (zend_class_entry *ce, zval *object, int byref TSRMLS_DC)

Variables

static zend_object_iterator_funcs resourcebundle_iterator_funcs

Function Documentation

zend_object_iterator* resourcebundle_get_iterator ( zend_class_entry *  ce,
zval *  object,
int byref  TSRMLS_DC 
)

Definition at line 156 of file resourcebundle_iterator.c.

{
       ResourceBundle_object   *rb = (ResourceBundle_object *) zend_object_store_get_object( object TSRMLS_CC );
       ResourceBundle_iterator *iterator = emalloc( sizeof( ResourceBundle_iterator ) );

       if (byref) {
            php_error( E_ERROR, "ResourceBundle does not support writable iterators" );
       }

       Z_ADDREF_P(object);
       iterator->intern.data = (void *) object;
       iterator->intern.funcs = &resourcebundle_iterator_funcs;

       iterator->subject = rb;

       /* The iterated rb can only be either URES_TABLE or URES_ARRAY
        * All other types are returned as php primitives!
        */
       iterator->is_table = (ures_getType( rb->me ) == URES_TABLE);
       iterator->length = ures_getSize( rb->me );

       iterator->current = NULL;
       iterator->currentkey = NULL;
       iterator->i = 0;

       return (zend_object_iterator *) iterator;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void resourcebundle_iterator_current ( zend_object_iterator *  iter,
zval ***data  TSRMLS_DC 
) [static]

Definition at line 93 of file resourcebundle_iterator.c.

{
       ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
       if (!iterator->current) {
              resourcebundle_iterator_read( iterator TSRMLS_CC);
       }
       *data = &iterator->current;
}

Here is the call graph for this function:

static void resourcebundle_iterator_dtor ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 71 of file resourcebundle_iterator.c.

{
       ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
       zval                    *object = (zval *)iterator->intern.data;

       resourcebundle_iterator_invalidate( iter TSRMLS_CC );

       Z_DELREF_P(object);

       efree(iterator);
}

Here is the call graph for this function:

static int resourcebundle_iterator_has_more ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 85 of file resourcebundle_iterator.c.

{
       ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;
       return (iterator->i < iterator->length) ? SUCCESS : FAILURE;
}
static void resourcebundle_iterator_invalidate ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 55 of file resourcebundle_iterator.c.

{
       ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;

       if (iterator->current) {
              zval_ptr_dtor( &iterator->current );
              iterator->current = NULL;
       }
       if (iterator->currentkey) {
              efree( iterator->currentkey );
              iterator->currentkey = NULL;
       }
}

Here is the caller graph for this function:

static int resourcebundle_iterator_key ( zend_object_iterator *  iter,
char **  str_key,
uint str_key_len,
ulong *int_key  TSRMLS_DC 
) [static]

Definition at line 104 of file resourcebundle_iterator.c.

{
       ResourceBundle_iterator *iterator = (ResourceBundle_iterator *) iter;

       if (!iterator->current) {
              resourcebundle_iterator_read( iterator TSRMLS_CC);
       }
       if (iterator->is_table) {
              *str_key = estrdup( iterator->currentkey );
              *str_key_len = strlen( iterator->currentkey ) + 1;
              return HASH_KEY_IS_STRING;
       }
       else {
              *int_key = iterator->i;
              return HASH_KEY_IS_LONG;
       }
}

Here is the call graph for this function:

static void resourcebundle_iterator_read ( ResourceBundle_iterator *iterator  TSRMLS_DC) [static]

Definition at line 32 of file resourcebundle_iterator.c.

{
       UErrorCode icuerror = U_ZERO_ERROR;
       ResourceBundle_object *rb = iterator->subject;

       rb->child = ures_getByIndex( rb->me, iterator->i, rb->child, &icuerror );

       if (U_SUCCESS(icuerror)) {
              /* ATTN: key extraction must be the first thing to do... rb->child might be reset in read! */
              if (iterator->is_table) {
                     iterator->currentkey = estrdup( ures_getKey( rb->child ) );
              }
              MAKE_STD_ZVAL( iterator->current );
              resourcebundle_extract_value( iterator->current, rb TSRMLS_CC );
       }
       else {
              // zend_throw_exception( spl_ce_OutOfRangeException, "Running past end of ResourceBundle", 0 TSRMLS_CC);
              iterator->current = NULL;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void resourcebundle_iterator_reset ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 134 of file resourcebundle_iterator.c.

Here is the call graph for this function:

static void resourcebundle_iterator_step ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 124 of file resourcebundle_iterator.c.

Here is the call graph for this function:


Variable Documentation