这篇教程C++ zend_hash_get_current_key_ex函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中zend_hash_get_current_key_ex函数的典型用法代码示例。如果您正苦于以下问题:C++ zend_hash_get_current_key_ex函数的具体用法?C++ zend_hash_get_current_key_ex怎么用?C++ zend_hash_get_current_key_ex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了zend_hash_get_current_key_ex函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: array/* complete - should deal either with: hash keys = keys, hash values = values hash = array( keys, values ) hash = array( value )*/void activerecord_sql_create_where_zval( activerecord_sql *sql, zval *hash ){ int len, i = 0; zval **value; char **keys, **values; HashPosition pos; if( Z_TYPE_P(hash) != IS_ARRAY ) /* throw exception */; len = zend_hash_num_elements( Z_ARRVAL_P(hash) ); keys = (char**)emalloc( sizeof(char*)*len ); values = (char**)emalloc( sizeof(char*)*len ); for( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(joins), &pos); zend_hash_get_current_data_ex(Z_ARRVAL_P(joins), (void **)&value, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_P(joins), &pos) ) { zval **key; int key_len; if( HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(arr), &key, &key_len, &j, 0, &pos) ) { keys[i] = key; values[i] = Z_STRVAL_PP(value); } } activerecord_sql_create_where( sql, keys, values, len );}
开发者ID:roeitell,项目名称:php-activerecord-plusplus,代码行数:38,
示例2: binary_serialize_specstaticvoid binary_serialize_spec(zval* zthis, PHPOutputTransport& transport, HashTable* spec) { HashPosition key_ptr; zval* val_ptr; for (zend_hash_internal_pointer_reset_ex(spec, &key_ptr); (val_ptr = zend_hash_get_current_data_ex(spec, &key_ptr)) != nullptr; zend_hash_move_forward_ex(spec, &key_ptr)) { zend_ulong fieldno; if (zend_hash_get_current_key_ex(spec, nullptr, &fieldno, &key_ptr) != HASH_KEY_IS_LONG) { throw_tprotocolexception("Bad keytype in TSPEC (expected 'long')", INVALID_DATA); return; } HashTable* fieldspec = Z_ARRVAL_P(val_ptr); // field name val_ptr = zend_hash_str_find(fieldspec, "var", sizeof("var")-1); char* varname = Z_STRVAL_P(val_ptr); // thrift type val_ptr = zend_hash_str_find(fieldspec, "type", sizeof("type")-1); if (Z_TYPE_P(val_ptr) != IS_LONG) convert_to_long(val_ptr); int8_t ttype = Z_LVAL_P(val_ptr); zval rv; zval* prop = zend_read_property(Z_OBJCE_P(zthis), zthis, varname, strlen(varname), false, &rv); if (Z_TYPE_P(prop) != IS_NULL) { transport.writeI8(ttype); transport.writeI16(fieldno); binary_serialize(ttype, transport, prop, fieldspec); } } transport.writeI8(T_STOP); // struct end}
开发者ID:angejia,项目名称:thrift,代码行数:35,
示例3: util_array_flattenvoid util_array_flatten(zval* arr, zval* result, zend_bool preserve_keys) { zval **zvalue; char *key; uint keylen; ulong idx; int type; HashTable* arr_hash; HashPosition pointer; // Copy a temp array zval temp; temp = *arr; zval_copy_ctor(&temp); arr_hash = Z_ARRVAL_P(&temp); zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); while (zend_hash_get_current_data_ex(arr_hash, (void**) &zvalue, &pointer) == SUCCESS) { if (Z_TYPE_P(*zvalue) == IS_ARRAY) { util_array_flatten(*zvalue, result, preserve_keys); } else { type = zend_hash_get_current_key_ex(arr_hash, &key, &keylen, &idx, 0, &pointer); if (preserve_keys && type != HASH_KEY_IS_LONG) { add_assoc_zval(result, key, *zvalue); } else { add_next_index_zval(result, *zvalue); } } zend_hash_move_forward_ex(arr_hash, &pointer); //ALLOC_INIT_ZVAL(*zvalue); }}
开发者ID:CraryPrimitiveMan,项目名称:util,代码行数:31,
示例4: activerecord_is_options_hashzend_bool activerecord_is_options_hash( zval * arr, zend_bool throw_e ){ HashPosition pos; char * key; int key_len, res; if( !activerecord_is_hash(arr) ) return 0; for( zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos); HASH_KEY_NON_EXISTANT != (res = zend_hash_get_current_key_ex(Z_ARRVAL_P(arr), &key, &key_len, &j, 0, &pos)); zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos) ) { int i; if( res != HASH_KEY_IS_STRING ) /* throw exception */; found = false; for( i = 0; i < 11; i++ ) { if( !strncmp(activerecord_valid_options[i], key, key_len) ) found = true; } if( !found && throw_e) /* throw exception */; } return 1;}
开发者ID:roeitell,项目名称:php-activerecord-plusplus,代码行数:32,
示例5: mysqlnd_minfo_print_hashPHPAPI void mysqlnd_minfo_print_hash(zval *values){ zval **values_entry; HashPosition pos_values; zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&values_entry, &pos_values) == SUCCESS) { zstr string_key; uint string_key_len; ulong num_key; int s_len; char *s = NULL; TSRMLS_FETCH(); zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &string_key, &string_key_len, &num_key, 0, &pos_values); convert_to_string(*values_entry); if (zend_unicode_to_string(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &s, &s_len, string_key.u, string_key_len TSRMLS_CC) == SUCCESS) { php_info_print_table_row(2, s, Z_STRVAL_PP(values_entry)); } if (s) { mnd_efree(s); } zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values); }}
开发者ID:66Ton99,项目名称:php5.4-ppa,代码行数:30,
示例6: binary_serialize_hashtable_keystaticvoid binary_serialize_hashtable_key(int8_t keytype, PHPOutputTransport& transport, HashTable* ht, HashPosition& ht_pos) { bool keytype_is_numeric = (!((keytype == T_STRING) || (keytype == T_UTF8) || (keytype == T_UTF16))); zend_string* key; uint key_len; long index = 0; zval z; int res = zend_hash_get_current_key_ex(ht, &key, (zend_ulong*)&index, &ht_pos); if (keytype_is_numeric) { if (res == HASH_KEY_IS_STRING) { index = strtol(ZSTR_VAL(key), nullptr, 10); } ZVAL_LONG(&z, index); } else { char buf[64]; if (res == HASH_KEY_IS_STRING) { ZVAL_STR_COPY(&z, key); } else { snprintf(buf, 64, "%ld", index); ZVAL_STRING(&z, buf); } } binary_serialize(keytype, transport, &z, nullptr); zval_dtor(&z);}
开发者ID:apupier,项目名称:fn,代码行数:28,
示例7: php_mimepart_remove_from_parentPHP_MAILPARSE_API void php_mimepart_remove_from_parent(php_mimepart *part){ php_mimepart *parent = part->parent; HashPosition pos; php_mimepart *childpart; zval *childpart_z; if (parent == NULL) return; part->parent = NULL; zend_hash_internal_pointer_reset_ex(&parent->children, &pos); while((childpart_z = zend_hash_get_current_data_ex(&parent->children, &pos)) != NULL) { if ((childpart_z = zend_hash_get_current_data_ex(&parent->children, &pos)) != NULL) { mailparse_fetch_mimepart_resource(childpart, childpart_z); if (childpart == part) { ulong h; zend_hash_get_current_key_ex(&parent->children, NULL, &h, &pos); zend_hash_index_del(&parent->children, h); break; } } zend_hash_move_forward_ex(&parent->children, &pos); }}
开发者ID:php,项目名称:pecl-mail-mailparse,代码行数:26,
示例8: zend_hash_get_current_key_exint CPHPArray::get_key(){ ulong retval; zend_hash_get_current_key_ex(Z_ARRVAL_P(m_arr), NULL, NULL, &retval, 0, &m_pos); return retval;};
开发者ID:tantra35,项目名称:PyRender,代码行数:7,
示例9: PHP_METHOD/* {{{ proto array SolrInputDocument::getFieldNames(void) Returns an array of all the field names in the document. */PHP_METHOD(SolrInputDocument, getFieldNames){ solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht = doc_entry->fields; register zend_bool duplicate = 0; array_init(return_value); SOLR_HASHTABLE_FOR_LOOP(fields_ht) { char *fieldname = NULL; uint fieldname_length = 0U; ulong num_index = 0L; solr_field_list_t **field = NULL; zend_bool duplicate_field_name = 1; zend_hash_get_current_key_ex(fields_ht, &fieldname, &fieldname_length, &num_index, duplicate, NULL); zend_hash_get_current_data_ex(fields_ht, (void **) &field, NULL); add_next_index_string(return_value, (char *) (*field)->field_name, duplicate_field_name); } /* We are done */ return; }
开发者ID:cfgxy,项目名称:php-solr,代码行数:32,
示例10: PHP_METHOD// CHash method setTargets(array(<target> => <weight> [, ...])) -> longPHP_METHOD(CHash, setTargets){ HashPosition position; chash_object *instance = (chash_object *)zend_object_store_get_object(getThis() TSRMLS_CC); zval *targets, **weight; char *target; ulong unused; uint length; int status; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &targets) != SUCCESS) { RETURN_LONG(chash_return(instance, CHASH_ERROR_INVALID_PARAMETER)) } if ((status = chash_clear_targets(&(instance->context))) < 0) { RETURN_LONG(chash_return(instance, status)) } for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(targets), &position); zend_hash_get_current_key_ex(Z_ARRVAL_P(targets), &target, &length, &unused, 0, &position) == HASH_KEY_IS_STRING && zend_hash_get_current_data_ex(Z_ARRVAL_P(targets), (void **)&weight, &position) == SUCCESS && Z_TYPE_PP(weight) == IS_LONG; zend_hash_move_forward_ex(Z_ARRVAL_P(targets), &position)) { if ((status = chash_add_target(&(instance->context), target, Z_LVAL_PP(weight))) < 0) { RETURN_LONG(chash_return(instance, status)) } } RETURN_LONG(chash_return(instance, chash_targets_count(&(instance->context))))}
开发者ID:dailymotion,项目名称:chash,代码行数:32,
示例11: rpb_print_hashtablevoid rpb_print_hashtable(HashTable *arr_hash) { HashPosition pointer; char *str_key; uint key_len; ulong int_key; zval **data; for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { zend_hash_get_current_key_ex(arr_hash, &str_key, &key_len, &int_key,0, &pointer); if(zend_hash_get_current_key_type_ex(arr_hash, &pointer) == IS_STRING) { // zend_print_pval_r(str_key,0); printf("%s/n", str_key); } else { printf("%s/n", str_key); // zend_print_pval_r(data,0); } }}
开发者ID:nickjenkin,项目名称:Ruby-PHP-Bridge,代码行数:27,
示例12: binary_serialize_hashtable_keyvoid binary_serialize_hashtable_key(int8_t keytype, PHPOutputTransport& transport, HashTable* ht, HashPosition& ht_pos) { bool keytype_is_numeric = (!((keytype == T_STRING) || (keytype == T_UTF8) || (keytype == T_UTF16))); char* key; uint key_len; long index = 0; zval* z; MAKE_STD_ZVAL(z); int res = zend_hash_get_current_key_ex(ht, &key, &key_len, (ulong*)&index, 0, &ht_pos); if (keytype_is_numeric) { if (res == HASH_KEY_IS_STRING) { index = strtol(key, NULL, 10); } ZVAL_LONG(z, index); } else { char buf[64]; if (res == HASH_KEY_IS_STRING) { key_len -= 1; // skip the null terminator } else { sprintf(buf, "%ld", index); key = buf; key_len = strlen(buf); } ZVAL_STRINGL(z, key, key_len, 1); } binary_serialize(keytype, transport, &z, NULL); zval_ptr_dtor(&z);}
开发者ID:wmorgan,项目名称:thrift,代码行数:30,
示例13: air_arr_del_index_elzval* air_arr_del_index_el(zval *arr) { HashTable *ht = Z_ARRVAL_P(arr); zval *tmp; MAKE_STD_ZVAL(tmp); array_init(tmp); for( zend_hash_internal_pointer_reset(ht); zend_hash_has_more_elements(ht) == SUCCESS; zend_hash_move_forward(ht) ){ int type; ulong idx; char *key; uint key_len; zval **tmp_data; type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL); if(type == HASH_KEY_IS_STRING){ if(zend_hash_get_current_data(ht, (void**)&tmp_data) != FAILURE) { add_assoc_stringl_ex(tmp, key, key_len, Z_STRVAL_PP(tmp_data), Z_STRLEN_PP(tmp_data), 1); } } } return tmp;}
开发者ID:jaykizhou,项目名称:air,代码行数:25,
示例14: activerecord_extract_validate_optionszval * activerecord_extract_validate_options( zval * arr ){ zval * retval; MAKE_STD_ZVAL( retval ); array_init( retval ); if( Z_TYPE_P(arr) == IS_ARRAY && zend_hash_num_elements( Z_ARRVAL_P(arr) ) > 0 ) { zval **last; char *key; int key_len, j; zend_hash_internal_pointer_end(Z_ARRVAL_P(arr)); zend_hash_get_current_data(Z_ARRVAL_P(arr), (void **)&last); if( activerecord_is_options_hash(last, 0) ) { retval = last; zend_hash_get_current_key_ex(Z_ARRVAL_P(arr), &key, &key_len, &j, 0, NULL); zend_hash_del_key_or_index(Z_ARRVAL_P(arr), key, key_len, j, (key) ? HASH_DEL_KEY : HASH_DEL_INDEX); if( !key_len && j >= Z_ARRVAL_P(arr)->nNextFreeElement - 1 ) Z_ARRVAL_P(arr)->nNextFreeElement = Z_ARRVAL_P(arr)->nNextFreeElement - 1; zend_hash_internal_pointer_reset(Z_ARRVAL_P(arr)); } else { if( !activerecord_is_hash(last) ) /* throw exception */; zend_hash_add( Z_ARRVAL_P(retval), "conditions", 10, last, sizeof(zval*), NULL ); } } return retval;}
开发者ID:roeitell,项目名称:php-activerecord-plusplus,代码行数:35,
示例15: binary_serialize_specvoid binary_serialize_spec(zval* zthis, PHPOutputTransport& transport, HashTable* spec) { HashPosition key_ptr; zval** val_ptr; TSRMLS_FETCH(); zend_class_entry* ce = zend_get_class_entry(zthis TSRMLS_CC); for (zend_hash_internal_pointer_reset_ex(spec, &key_ptr); zend_hash_get_current_data_ex(spec, (void**)&val_ptr, &key_ptr) == SUCCESS; zend_hash_move_forward_ex(spec, &key_ptr)) { ulong fieldno; if (zend_hash_get_current_key_ex(spec, NULL, NULL, &fieldno, 0, &key_ptr) != HASH_KEY_IS_LONG) { throw_tprotocolexception("Bad keytype in TSPEC (expected 'long')", INVALID_DATA); return; } HashTable* fieldspec = Z_ARRVAL_PP(val_ptr); // field name zend_hash_find(fieldspec, "var", 4, (void**)&val_ptr); char* varname = Z_STRVAL_PP(val_ptr); // thrift type zend_hash_find(fieldspec, "type", 5, (void**)&val_ptr); if (Z_TYPE_PP(val_ptr) != IS_LONG) convert_to_long(*val_ptr); int8_t ttype = Z_LVAL_PP(val_ptr); zval* prop = zend_read_property(ce, zthis, varname, strlen(varname), false TSRMLS_CC); if (Z_TYPE_P(prop) != IS_NULL) { transport.writeI8(ttype); transport.writeI16(fieldno); binary_serialize(ttype, transport, &prop, fieldspec); } } transport.writeI8(T_STOP); // struct end}
开发者ID:wmorgan,项目名称:thrift,代码行数:33,
示例16: zval_to_hashVALUE zval_to_hash(zval *zv) { HashTable *ht; HashPosition pos; zval **data; VALUE ret; convert_to_array(zv); ht = Z_ARRVAL_P(zv); ret = rb_hash_new(); zend_hash_internal_pointer_reset_ex(ht, &pos); while (zend_hash_get_current_data_ex(ht, (void **)&data, &pos) == SUCCESS) { char* key_str; uint key_len; ulong num_index; VALUE key = Qnil; VALUE val = new_php_embed_value(*data); switch(zend_hash_get_current_key_ex(ht, &key_str, &key_len, &num_index, 0, &pos)) { case HASH_KEY_IS_STRING: //key = rb_str_new(key_str, key_len); key = rb_str_new_cstr(key_str); break; case HASH_KEY_IS_LONG: key = LONG2NUM(num_index); break; } rb_hash_aset(ret, key, val); zend_hash_move_forward_ex(ht, &pos); } return ret;}
开发者ID:Epictetus,项目名称:php_embed,代码行数:34,
示例17: create_php_configvoid *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf){ php_conf_rec *d = base_conf, *e = new_conf, *n = NULL; php_dir_entry *pe; php_dir_entry *data; char *str; uint str_len; ulong num_index; n = create_php_config(p, "merge_php_config"); zend_hash_copy(&n->config, &e->config, NULL, NULL, sizeof(php_dir_entry)); phpapdebug((stderr, "Merge dir (%p)+(%p)=(%p)/n", base_conf, new_conf, n)); for (zend_hash_internal_pointer_reset(&d->config); zend_hash_get_current_key_ex(&d->config, &str, &str_len, &num_index, 0, NULL) == HASH_KEY_IS_STRING; zend_hash_move_forward(&d->config)) { pe = NULL; zend_hash_get_current_data(&d->config, (void **) &data); if (zend_hash_find(&n->config, str, str_len, (void **) &pe) == SUCCESS) { if (pe->status >= data->status) continue; } zend_hash_update(&n->config, str, str_len, data, sizeof(*data), NULL); phpapdebug((stderr, "ADDING/OVERWRITING %s (%d vs. %d)/n", str, data->status, pe?pe->status:-1)); } return n;}
开发者ID:Doap,项目名称:php-src,代码行数:28,
示例18: xc_coverager_autodump/* }}} */static void xc_coverager_autodump(TSRMLS_D) /* {{{ */{ coverager_t *pcov; zstr s; char *outfilename; int dumpdir_len, outfilelen, alloc_len = 0; uint size; HashPosition pos; if (XG(coverages) && xc_coveragedump_dir) { dumpdir_len = strlen(xc_coveragedump_dir); alloc_len = dumpdir_len + 1 + 128; outfilename = emalloc(alloc_len); strcpy(outfilename, xc_coveragedump_dir); zend_hash_internal_pointer_reset_ex(XG(coverages), &pos); while (zend_hash_get_current_data_ex(XG(coverages), (void **) &pcov, &pos) == SUCCESS) { zend_hash_get_current_key_ex(XG(coverages), &s, &size, NULL, 0, &pos); outfilelen = dumpdir_len + size + 5; if (alloc_len < outfilelen) { alloc_len = outfilelen + 128; outfilename = erealloc(outfilename, alloc_len); } strcpy(outfilename + dumpdir_len, ZSTR_S(s)); strcpy(outfilename + dumpdir_len + size - 1, ".pcov"); TRACE("outfilename %s", outfilename); xc_coverager_save_cov(ZSTR_S(s), outfilename, *pcov TSRMLS_CC); zend_hash_move_forward_ex(XG(coverages), &pos); } efree(outfilename); }}
开发者ID:alepharchives,项目名称:xcache,代码行数:34,
示例19: wkhtmltox_set_object_paramsint wkhtmltox_set_object_params(void *settings, fp set_function, zval *params, zval *input){ zval **data; HashTable *params_hash; HashPosition pointer; int params_count; char *key; int key_len; long index; int page = 0; int html = 0; params_hash = Z_ARRVAL_P(params); params_count = zend_hash_num_elements(params_hash); for(zend_hash_internal_pointer_reset_ex(params_hash, &pointer); zend_hash_get_current_data_ex(params_hash, (void **)&data, &pointer) == SUCCESS; zend_hash_move_forward_ex(params_hash, &pointer)) { zval temp = **data; zval_copy_ctor(&temp); if (zend_hash_get_current_key_ex(params_hash, &key, &key_len, &index, 0, &pointer) == HASH_KEY_IS_STRING) { switch (Z_TYPE(temp)) { case IS_BOOL: set_function(settings, key, Z_BVAL(temp) ? "true" : "false"); break; default: convert_to_string(&temp); case IS_STRING: if (strcmp(key, "page") == 0 || strcmp(key, "out") == 0) { //TODO do checking of page/out url/file according to php security settings like open_basedir, allow_url_fopen a.s.o // php main fopenwrapper ?! php_check_specific_open_basedir php_check_open_basedir //php_printf("key: %s, val: %s/n", key, Z_STRVAL(temp)); } if (strcmp(key, "page") == 0 && Z_STRLEN(temp) > 0) { page = 1; } if (strcmp(key, "html") == 0 && Z_STRLEN(temp) > 0) { ZVAL_STRING(input, Z_STRVAL(temp), 1); html = 1; } set_function(settings, key, Z_STRVAL(temp)); break; } } zval_dtor(&temp); } if (page == 1) { return 0; } else if (page == 0 && html == 1) { return 1; } else { return 2; }}
开发者ID:jymboche,项目名称:php-wkhtmltox,代码行数:58,
示例20: php_mongo_command_supports_rpstatic int php_mongo_command_supports_rp(zval *cmd){ HashPosition pos; char *str; uint str_len; long type; ulong idx; if (!cmd || Z_TYPE_P(cmd) != IS_ARRAY) { return 0; } zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(cmd), &pos); type = zend_hash_get_current_key_ex(Z_ARRVAL_P(cmd), &str, &str_len, &idx, 0, &pos); if (type != HASH_KEY_IS_STRING) { return 0; } /* Commands in MongoDB are case-sensitive */ if (str_len == 6) { if (strcmp(str, "count") == 0 || strcmp(str, "group") == 0) { return 1; } return 0; } if (str_len == 8) { if (strcmp(str, "dbStats") == 0 || strcmp(str, "geoNear") == 0 || strcmp(str, "geoWalk") == 0) { return 1; } return 0; } if (str_len == 9) { if (strcmp(str, "distinct") == 0) { return 1; } return 0; } if (str_len == 10) { if (strcmp(str, "aggregate") == 0 || strcmp(str, "collStats") == 0 || strcmp(str, "geoSearch") == 0) { return 1; } if (strcmp(str, "mapreduce") == 0) { zval **value = NULL; if (zend_hash_find(Z_ARRVAL_P(cmd), "out", 4, (void **)&value) == SUCCESS) { if (Z_TYPE_PP(value) == IS_STRING) { if (strcmp(Z_STRVAL_PP(value), "inline") == 0) { return 1; } } } } return 0; } return 0;}
开发者ID:morozow,项目名称:mongo-php-driver,代码行数:57,
示例21: ZEND_METHOD//平均数ZEND_METHOD( alinq_class , Average ){ zend_fcall_info fci; zend_fcall_info_cache fci_cache; zend_class_entry *ce; ce = Z_OBJCE_P(getThis()); zval * reArrVal; MAKE_STD_ZVAL(reArrVal); array_init(reArrVal); zval *dataSource, **tmpns; ALLOC_INIT_ZVAL(reArrVal); //持久化分配内存 zval *retval_ptr = NULL; long resulTotal = 0,averagable=0; float averNum; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fci, &fci_cache) == FAILURE) { return; } dataSource = zend_read_property(ce, getThis(), "dataSource", sizeof("dataSource")-1, 0 TSRMLS_DC); while (zend_hash_get_current_data(Z_ARRVAL_P(dataSource), (void **)&tmpns) == SUCCESS) { char *key; uint keylen; ulong idx; int type; zval **ppzval, *tmpcopy; MAKE_STD_ZVAL(tmpcopy); type = zend_hash_get_current_key_ex(Z_ARRVAL_P(dataSource), &key, &keylen,&idx, 0, NULL); //重新copy一个zval,防止破坏原数据 tmpcopy = *tmpns; zval_copy_ctor(tmpcopy); // INIT_PZVAL(tmpcopy); walu_call_anony_function(&retval_ptr, NULL, fci, "sz", key, keylen,&tmpcopy); resulTotal = resulTotal + Z_LVAL_P(retval_ptr); averagable++; // php_printf("value: %d/n", Z_LVAL_P(retval_ptr)); zend_hash_move_forward(Z_ARRVAL_P(dataSource)); } // php_printf("resulTotal: %d/n", resulTotal); // php_printf("averagable: %d/n", averagable); if(averagable > 0){ averNum = (float)resulTotal/(float)averagable; // php_printf("averagable: %f/n", averNum); RETURN_DOUBLE(averNum); } RETURN_DOUBLE(0); RETURN_ZVAL(reArrVal,1,1);}
开发者ID:wosiwo,项目名称:clinq,代码行数:57,
示例22: message_proto/* Extract a single optional/required or multiple repeated sub messages from native php types into the given protobuf message. Allocates memory for the created messages */intmessage_proto (const ProtobufCMessage* message, const ProtobufCFieldDescriptor* field, zval** val){ if (Z_TYPE_PP(val) != IS_ARRAY) return 1; const void* member = get_member(message, field); unsigned int* quantifier = get_quantifier(message, field); ProtobufCMessageDescriptor* descriptor = (ProtobufCMessageDescriptor*)field->descriptor; if (field->label == PROTOBUF_C_LABEL_REQUIRED) { ProtobufCMessage* base = emalloc(descriptor->sizeof_message); protobuf_c_message_init(descriptor, base); php_message(base, val[0]); memcpy((void*)member, (void*)&base, sizeof(void*)); } else if (field->label == PROTOBUF_C_LABEL_REPEATED) { HashPosition pos; HashTable* hash_table = Z_ARRVAL_PP(val); size_t* num_elements = emalloc(sizeof(size_t)); num_elements[0] = (size_t)zend_hash_num_elements(hash_table); zval** data; char* key; int i, key_len, curr = 0; long index; void** values = emalloc(sizeof(void*) * *num_elements); zend_hash_internal_pointer_reset_ex(hash_table, &pos); for (;; zend_hash_move_forward_ex(hash_table, &pos)) { zend_hash_get_current_data_ex(hash_table, (void**)&data, &pos); i = zend_hash_get_current_key_ex(hash_table, &key, &key_len, &index, 0, &pos); if (i == HASH_KEY_NON_EXISTANT) { break; } void* curr_value = emalloc(descriptor->sizeof_message); protobuf_c_message_init(descriptor, curr_value); php_message((ProtobufCMessage*)curr_value, data[0]); values[curr] = curr_value; curr++; } memcpy((void*)member, (void*)&values, sizeof(void*)); memcpy((void*)quantifier, (void*)num_elements, sizeof(void*)); } return 0;}
开发者ID:zined,项目名称:phproto,代码行数:56,
示例23: php_map_from_HasTable/** * Convert a php Array to a map * * @param t the php Array to convert * @return the created map */map* php_map_from_HasTable(HashTable* t){#ifdef DEBUG fprintf(stderr,"mapsFromPHPArray start/n");#endif map* final_res=(map*)malloc(MAP_SIZE); final_res=NULL; char key[1024]; for(zend_hash_internal_pointer_reset(t); zend_hash_has_more_elements(t) == SUCCESS; zend_hash_move_forward(t)) { char *key; uint keylen; ulong idx; int type; int len; zval **ppzval, tmpcopy; type = zend_hash_get_current_key_ex(t, &key, &keylen, &idx, 0, NULL); if (zend_hash_get_current_data(t, (void**)&ppzval) == FAILURE) { /* Should never actually fail * since the key is known to exist. */ continue; } /** * Duplicate the zval so that * the orignal’s contents are not destroyed */ tmpcopy = **ppzval; zval_copy_ctor(&tmpcopy); /** * Reset refcount & Convert */ INIT_PZVAL(&tmpcopy); convert_to_string(&tmpcopy); if(strncmp(key,"value",5)==0){ len=Z_STRLEN_P(&tmpcopy); final_res = addToMapWithSize(final_res,key,Z_STRVAL_P(&tmpcopy),len); } else{ if(final_res==NULL){#ifdef DEBUG fprintf(stderr,"%s => %s/n",key,Z_STRVAL(tmpcopy));#endif final_res=createMap(key,Z_STRVAL(tmpcopy)); } else{#ifdef DEBUG fprintf(stderr,"%s => %s/n",key,Z_STRVAL(tmpcopy));#endif addToMap(final_res,key,Z_STRVAL(tmpcopy)); } } /* Toss out old copy */ zval_dtor(&tmpcopy); } return final_res;}
开发者ID:OSGeo,项目名称:zoo-project,代码行数:60,
示例24: uint32_proto/* Extract uint32_t values from the given zval** and write them into the given protobuf message pointer. handle optional/required/repeated */intuint32_proto (const ProtobufCMessage* message, const ProtobufCFieldDescriptor* field, zval** val){ uint32_t* member = (uint32_t*)get_member(message, field); unsigned int* quantifier = get_quantifier(message, field); if (field->label == PROTOBUF_C_LABEL_REQUIRED || field->label == PROTOBUF_C_LABEL_OPTIONAL) { if (Z_TYPE_PP(val) == IS_LONG) *member = (uint32_t)Z_LVAL_PP(val); else if (Z_TYPE_PP(val) == IS_DOUBLE) *member = (uint32_t)Z_DVAL_PP(val); else return 1; if (field->label == PROTOBUF_C_LABEL_OPTIONAL) *quantifier = 1; } else if (field->label == PROTOBUF_C_LABEL_REPEATED) { if (Z_TYPE_PP(val) != IS_ARRAY) return 1; HashPosition pos; HashTable* hash_table = Z_ARRVAL_PP(val); size_t num_elements = (size_t)zend_hash_num_elements(hash_table); zval** data; char* key; int i, key_len, curr = 0; long index; uint32_t* values = emalloc(sizeof(uint32_t) * num_elements); zend_hash_internal_pointer_reset_ex(hash_table, &pos); for (;; zend_hash_move_forward_ex(hash_table, &pos)) { zend_hash_get_current_data_ex(hash_table, (void**)&data, &pos); i = zend_hash_get_current_key_ex(hash_table, &key, &key_len, &index, 0, &pos); if (i == HASH_KEY_NON_EXISTANT) break; if (Z_TYPE_PP(data) == IS_LONG) values[curr++] = (uint32_t)(Z_LVAL_PP(data)); else if (Z_TYPE_PP(data) == IS_DOUBLE) values[curr++] = (uint32_t)(Z_DVAL_PP(data)); } *quantifier = num_elements; memcpy((void*)member, (void*)&values, sizeof(void*)); } return 0;}
开发者ID:zined,项目名称:phproto,代码行数:55,
示例25: php_message/* Iterate over the given php zval** and transform into protobuf compatible values. Write those into the given protobuf message pointer. */intphp_message (const ProtobufCMessage* message, zval* val){ HashPosition pos; HashTable* hash_table = Z_ARRVAL_P(val); zval** data; char* key; int i, j, key_len; long index; // check if all required fields are existent in the given php array. // NULL default values if not for (j=0 ; j < message->descriptor->n_fields ; ++j) { const ProtobufCFieldDescriptor* tmp_field = message->descriptor->fields + j; if (! zend_symtable_exists(hash_table, (char*)tmp_field->name, strlen((char*)(tmp_field->name)) + 1)) { if (tmp_field->label == PROTOBUF_C_LABEL_REQUIRED) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "cannot find required field '%s'", tmp_field->name); return 1; } else { null_field(message, tmp_field); } } } // copy php values to proto zend_hash_internal_pointer_reset_ex(hash_table, &pos); for (;; zend_hash_move_forward_ex(hash_table, &pos)) { zend_hash_get_current_data_ex(hash_table, (void**)&data, &pos); i = zend_hash_get_current_key_ex(hash_table, &key, &key_len, &index, 0, &pos); if (i == HASH_KEY_NON_EXISTANT) { break; } else if (i == HASH_KEY_IS_STRING) { const ProtobufCFieldDescriptor* field = find_field(message, key); if (field == NULL) continue; if (write_field(message, field, data) != 0) { zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "unable to pack field '%s'", field->name); return 1; } } } return 0;}
开发者ID:zined,项目名称:phproto,代码行数:54,
示例26: Z_ARRVAL_Pstatic void *clock_loop(void* _clock_array) { int x, y, i; char *key; uint key_len; int array_count; HashTable *arr_hash; HashPosition pointer; zval **data; ulong index; static struct clocks_struct clock_args; zval* clock_array = (zval*) _clock_array; arr_hash = Z_ARRVAL_P(clock_array); array_count = zend_hash_num_elements(arr_hash); clock_args.clock = ecalloc(array_count, sizeof(struct clock_struct)); clock_args.anz_clocks = array_count; i = 0; for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS; zend_hash_move_forward_ex(arr_hash, &pointer)) { zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer); clock_args.clock[i].start_time = Z_LVAL_PP(data); clock_args.clock[i].x = 62; clock_args.clock[i].y = index + 4; i++; } while (stop == 0) { time_t now; time(&now); long dauer; int stunden, minuten, sekunden; for (i = 0; i < clock_args.anz_clocks; i++) { dauer = difftime(now, clock_args.clock[i].start_time); x = clock_args.clock[i].x; y = clock_args.clock[i].y; stunden = dauer / 3600; minuten = (dauer % 3600) / 60; sekunden = (dauer % 3600) % 60; php_printf("/x1B[%d;%dH%02d:%02d:%02d/n", y, x, stunden, minuten, sekunden); } php_printf("/x1B[%d;%dH", line + 4, 3); fflush(stdout); sleep(1); } efree(clock_args.clock); return NULL;}
开发者ID:ThomasJez,项目名称:ClockThread,代码行数:51,
示例27: PHP_METHOD/** * Interpolates context values into the message placeholders * * @see http://www.php-fig.org/psr/psr-3/ Section 1.2 Message * @param string $message * @param array $context */PHP_METHOD(Phalcon_Logger_Formatter, interpolate){ zval **message, **context; phalcon_fetch_params_ex(2, 0, &message, &context); if (Z_TYPE_PP(context) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_PP(context)) > 0) { HashTable *ht = Z_ARRVAL_PP(context); HashPosition hp; zval *replace, **val; PHALCON_ALLOC_GHOST_ZVAL(replace); array_init_size(replace, zend_hash_num_elements(ht)); for ( zend_hash_internal_pointer_reset_ex(ht, &hp); zend_hash_get_current_data_ex(ht, (void**)&val, &hp) == SUCCESS; zend_hash_move_forward_ex(ht, &hp) ) { char *str_index, *idx; uint str_length; ulong num_index; int type = zend_hash_get_current_key_ex(ht, &str_index, &str_length, &num_index, 0, &hp); if (HASH_KEY_IS_STRING == type) { str_length += 2; idx = emalloc(str_length); idx[0] = '{'; idx[str_length-2] = '}'; idx[str_length-1] = '/0'; memcpy(idx + 1, str_index, str_length - 3); } else if (HASH_KEY_IS_LONG == type) { str_length = spprintf(&idx, 0, "{%ld}", num_index); } else { /* Better safe than sorry */ continue; } Z_ADDREF_PP(val); zend_hash_add(Z_ARRVAL_P(replace), idx, str_length, (void*)val, sizeof(zval*), NULL); efree(idx); } PHALCON_RETURN_CALL_FUNCTIONW("strtr", *message, replace); return; } RETURN_ZVAL(*message, 1, 0);}
开发者ID:9466,项目名称:cphalcon,代码行数:57,
示例28: PHP_METHOD/* {{{ proto string ProtocolBuffersEnum::getName(long $value)*/PHP_METHOD(protocolbuffers_enum, getName){#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 3) zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "ProtocolBuffersEnum::getName can't work under PHP 5.3. please consider upgrading your PHP"); return;#else long value; zval *result; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) == FAILURE) { return; } if (zend_call_method_with_0_params(NULL, EG(called_scope), NULL, "getenumdescriptor", &result)) { zval *values, **entry; HashPosition pos; if (!instanceof_function_ex(Z_OBJCE_P(result), php_protocol_buffers_enum_descriptor_class_entry, 0 TSRMLS_CC)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "ProtocolBuffersEnum::getEnumDescriptor returns unexpected value."); zval_ptr_dtor(&result); return; } php_protocolbuffers_read_protected_property(result, ZEND_STRS("values"), &values TSRMLS_CC); zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&entry, &pos) == SUCCESS) { if (Z_LVAL_PP(entry) == value) { char *key; uint key_len; ulong index; zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &key, &key_len, &index, 0, &pos); RETURN_STRINGL(key, key_len, 1); break; } zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos); } zval_ptr_dtor(&result); RETVAL_FALSE; } else { zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "cannot call ProtocolBuffersEnum::getEnumDescriptor."); return; }#endif}
开发者ID:Easthy,项目名称:php-protocolbuffers,代码行数:49,
注:本文中的zend_hash_get_current_key_ex函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ zend_hash_index_update函数代码示例 C++ zend_hash_get_current_data_ex函数代码示例 |