• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ smart_str_0函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中smart_str_0函数的典型用法代码示例。如果您正苦于以下问题:C++ smart_str_0函数的具体用法?C++ smart_str_0怎么用?C++ smart_str_0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了smart_str_0函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: php_bencode_decode_str

static void php_bencode_decode_str(zval *return_value, char *str, size_t *pos, size_t *str_len) /* {{{ */
{
	size_t len = 0;
	smart_str buf = {0};
	
	while (*pos < *str_len && str[*pos] != ':') {
		smart_str_appendc(&buf, str[*pos]);
		(*pos)++;
	}
	
	if (str[*pos] != ':') {
		zend_error(E_WARNING, "Invaild bencoded-string, expected semicolon, stop at position %u.", *pos);
		RETURN_NULL();
	}
	
	(*pos)++;
	
	smart_str_0(&buf);
	len = atoi(ZSTR_VAL(buf.s));
	smart_str_free(&buf);
	
	if (len > 0 && *pos + len - 1 < *str_len) {
		size_t i;
		for (i = 0; i < len; i++, (*pos)++) {
			smart_str_appendc(&buf, str[*pos]);
		}
		smart_str_0(&buf);
		RETVAL_STR(buf.s);
	} else {
		RETVAL_EMPTY_STRING();
	}
	
}
开发者ID:acgrid,项目名称:php-ext-bencode,代码行数:33,代码来源:cg_bcode.c


示例2: PHP_FUNCTION

/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
   Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
	zval *parameter;
	php_json_encoder encoder;
	smart_str buf = {0};
	zend_long options = 0;
	zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;

	ZEND_PARSE_PARAMETERS_START(1, 3)
		Z_PARAM_ZVAL_DEREF(parameter)
		Z_PARAM_OPTIONAL
		Z_PARAM_LONG(options)
		Z_PARAM_LONG(depth)
	ZEND_PARSE_PARAMETERS_END();

	php_json_encode_init(&encoder);
	encoder.max_depth = (int)depth;
	encoder.error_code = PHP_JSON_ERROR_NONE;
	php_json_encode_zval(&buf, parameter, (int)options, &encoder);
	JSON_G(error_code) = encoder.error_code;

	if (encoder.error_code != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
		smart_str_free(&buf);
		RETURN_FALSE;
	}

	smart_str_0(&buf); /* copy? */
	if (buf.s) {
		RETURN_NEW_STR(buf.s);
	}
	RETURN_EMPTY_STRING();
}
开发者ID:ChadSikorra,项目名称:php-src,代码行数:34,代码来源:json.c


示例3: PHP_FUNCTION

/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
   Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
	zval *parameter;
	php_json_encoder encoder;
	smart_str buf = {0};
	zend_long options = 0;
	zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ll", &parameter, &options, &depth) == FAILURE) {
		return;
	}

	php_json_encode_init(&encoder);
	encoder.max_depth = (int)depth;
	encoder.error_code = PHP_JSON_ERROR_NONE;
	php_json_encode_zval(&buf, parameter, (int)options, &encoder);
	JSON_G(error_code) = encoder.error_code;

	if (encoder.error_code != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
		smart_str_free(&buf);
		RETURN_FALSE;
	}

	smart_str_0(&buf); /* copy? */
	if (buf.s) {
		RETURN_NEW_STR(buf.s);
	}
	RETURN_EMPTY_STRING();
}
开发者ID:unfunco,项目名称:php-src,代码行数:31,代码来源:json.c


示例4: php_filter_encode_html

/* {{{ HELPER FUNCTIONS */
static void php_filter_encode_html(zval *value, const unsigned char *chars)
{
	smart_str str = {0};
	size_t len = Z_STRLEN_P(value);
	unsigned char *s = (unsigned char *)Z_STRVAL_P(value);
	unsigned char *e = s + len;

	if (Z_STRLEN_P(value) == 0) {
		return;
	}

	while (s < e) {
		if (chars[*s]) {
			smart_str_appendl(&str, "&#", 2);
			smart_str_append_unsigned(&str, (zend_ulong)*s);
			smart_str_appendc(&str, ';');
		} else {
			/* XXX: this needs to be optimized to work with blocks of 'safe' chars */
			smart_str_appendc(&str, *s);
		}
		s++;
	}

	smart_str_0(&str);
	zval_ptr_dtor(value);
	ZVAL_NEW_STR(value, str.s);
}
开发者ID:20uf,项目名称:php-src,代码行数:28,代码来源:sanitizing_filters.c


示例5: hs_response_recv

static inline long
hs_response_recv(php_stream *stream, char *recv, size_t size TSRMLS_DC)
{
    long ret;
#ifdef HS_DEBUG
    long i;
    smart_str debug = {0};
#endif

    ret  = php_stream_read(stream, recv, size);
    if (ret <= 0) {
        return -1;
    }
    recv[size] = '\0';

#ifdef HS_DEBUG
    for (i = 0; i < ret; i++) {
        if ((unsigned char)recv[i] == HS_CODE_NULL) {
            smart_str_appendl_ex(&debug, "\\0", strlen("\\0"), 1);
        } else {
            smart_str_appendc(&debug, recv[i]);
        }
    }
    smart_str_0(&debug);
    php_printf("[handlersocket] (recv) %ld : \"%s\"", ret, debug.c);
    smart_str_free(&debug);
#endif

    return ret;
}
开发者ID:amor-tsai,项目名称:php-ext-handlersocketi,代码行数:30,代码来源:response.c


示例6: PHP_FUNCTION

/* {{{ proto string json_encode(mixed data [, int options[, int depth]])
   Returns the JSON representation of a value */
static PHP_FUNCTION(json_encode)
{
	zval *parameter;
	smart_str buf = {0};
	zend_long options = 0;
	zend_long depth = PHP_JSON_PARSER_DEFAULT_DEPTH;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|ll", &parameter, &options, &depth) == FAILURE) {
		return;
	}

	JSON_G(error_code) = PHP_JSON_ERROR_NONE;

	JSON_G(encode_max_depth) = (int)depth;

	php_json_encode(&buf, parameter, (int)options);

	if (JSON_G(error_code) != PHP_JSON_ERROR_NONE && !(options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR)) {
		smart_str_free(&buf);
		ZVAL_FALSE(return_value);
	} else {
		smart_str_0(&buf); /* copy? */
		ZVAL_NEW_STR(return_value, buf.s);
	}
}
开发者ID:CooCoooo,项目名称:php-src,代码行数:27,代码来源:json.c


示例7: ONPHP_METHOD

ONPHP_METHOD(ExtractPart, toDialectString)
{
	zval *dialect, *what, *from, *whatString, *fromString;
	smart_str string = {0};
	
	ONPHP_GET_ARGS("O", &dialect, onphp_ce_Dialect);
	
	what = ONPHP_READ_PROPERTY(getThis(), "what");
	from = ONPHP_READ_PROPERTY(getThis(), "from");
	
	ONPHP_CALL_METHOD_0(what, "tostring", &whatString);
	
	ONPHP_CALL_METHOD_1_NORET(from, "todialectstring", &fromString, dialect);
	
	if (EG(exception)) {
		ZVAL_FREE(whatString);
		return;
	}
	
	smart_str_appendl(&string, "EXTRACT(", 8);
	onphp_append_zval_to_smart_string(&string, whatString);
	smart_str_appendl(&string, " FROM ", 6);
	onphp_append_zval_to_smart_string(&string, fromString);
	smart_str_appendc(&string, ')');
	smart_str_0(&string);
	
	zval_ptr_dtor(&whatString);
	zval_ptr_dtor(&fromString);
	
	RETURN_STRINGL(string.c, string.len, 0);
}
开发者ID:suquant,项目名称:soloweb-onphp,代码行数:31,代码来源:ExtractPart.c


示例8: php_bencode_decode_int

static void php_bencode_decode_int(zval *return_value, char *str, size_t *pos, size_t *str_len) /* {{{ */
{
	int len = 0;
	double d;
	smart_str buf = {0};
	(*pos)++;
	while (*pos < *str_len && str[*pos] != PHP_BENCODE_END_STRUCTURE) {
		smart_str_appendc(&buf, str[*pos]);
		(*pos)++;
		len++;
	}
	smart_str_0(&buf);
	
	if (str[*pos] != PHP_BENCODE_END_STRUCTURE) {
		smart_str_free(&buf);
		zend_error(E_WARNING, "Invaild bencoded-integer, expected 'e'.");
		RETURN_NULL();
	}
	
	(*pos)++;
	
	ZVAL_STRINGL(return_value, ZSTR_VAL(buf.s), len);
	d = zend_strtod(ZSTR_VAL(buf.s), NULL);
	if (d <= ZEND_LONG_MAX && d >= ZEND_LONG_MIN) {
		convert_to_long(return_value);
	}
	smart_str_free(&buf);
	
}
开发者ID:acgrid,项目名称:php-ext-bencode,代码行数:29,代码来源:cg_bcode.c


示例9: zend_print_zval_r_to_buf

ZEND_API zend_string *zend_print_zval_r_to_str(zval *expr, int indent) /* {{{ */
{
	smart_str buf = {0};
	zend_print_zval_r_to_buf(&buf, expr, indent);
	smart_str_0(&buf);
	return buf.s;
}
开发者ID:eaglewu,项目名称:php-src,代码行数:7,代码来源:zend.c


示例10: phalcon_cssmin_internal

static int phalcon_cssmin_internal(zval *return_value, zval *style, const char **error) {

	int i;
	unsigned char c;
	cssmin_parser parser;
	smart_str minified = {0};

	parser.tmp_state = 0;
	parser.state = 1;
	parser.last_state = 1;
	parser.in_paren = 0;
	parser.style = style;
	parser.error = NULL;
	parser.minified = &minified;

	for (i = 0; i < Z_STRLEN_P(style); i++) {
		parser.style_pointer = i + 1;
		c = phalcon_cssmin_machine(&parser, Z_STRVAL_P(style)[i]);
		if (c != 0) {
			smart_str_appendc(parser.minified, c);
		}
		i = parser.style_pointer - 1;
	}

	smart_str_0(&minified);

	if (minified.s) {
		ZVAL_STRINGL(return_value, minified.s->val, minified.s->len);
	} else {
		ZVAL_EMPTY_STRING(return_value);
	}

	*error = parser.error;
	return SUCCESS;
}
开发者ID:Myleft,项目名称:cphalcon7,代码行数:35,代码来源:cssminifier.c


示例11: PHP_METHOD

/**
 * Writes the meta-data to files
 *
 * @param string $key
 * @param array $data
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, write){

	zval **key, **data, *meta_data_dir, *virtual_key;
	zval *path, *php_export, *status;
	smart_str exp = { NULL, 0, 0 };

	phalcon_fetch_params_ex(2, 0, &key, &data);

	PHALCON_MM_GROW();

	meta_data_dir = phalcon_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY TSRMLS_CC);
	
	PHALCON_INIT_VAR(virtual_key);
	phalcon_prepare_virtual_path_ex(virtual_key, Z_STRVAL_PP(key), Z_STRLEN_PP(key), '_' TSRMLS_CC);
	
	PHALCON_INIT_VAR(path);
	PHALCON_CONCAT_VVS(path, meta_data_dir, virtual_key, ".php");
	
	smart_str_appends(&exp, "<?php return ");
	php_var_export_ex(data, 0, &exp TSRMLS_CC);
	smart_str_appendc(&exp, ';');
	smart_str_0(&exp);
	
	PHALCON_INIT_VAR(php_export);
	ZVAL_STRINGL(php_export, exp.c, exp.len, 0);

	PHALCON_INIT_VAR(status);
	phalcon_file_put_contents(status, path, php_export TSRMLS_CC);
	if (PHALCON_IS_FALSE(status)) {
		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Meta-Data directory cannot be written");
		return;
	}
	
	PHALCON_MM_RESTORE();
}
开发者ID:100851766,项目名称:cphalcon,代码行数:41,代码来源:files.c


示例12: PHP_METHOD

/**
 * Writes parsed annotations to files
 *
 * @param string $key
 * @param Phalcon\Annotations\Reflection $data
 */
PHP_METHOD(Phalcon_Annotations_Adapter_Files, write){

	zval *key, *data, annotations_dir = {}, virtual_key = {}, path = {}, php_export = {}, status = {};
	smart_str exp = { 0 };

	phalcon_fetch_params(0, 2, 0, &key, &data);
	PHALCON_ENSURE_IS_STRING(key);

	phalcon_return_property(&annotations_dir, getThis(), SL("_annotationsDir"));
	
	/** 
	 * Paths must be normalized before be used as keys
	 */
	phalcon_prepare_virtual_path_ex(&virtual_key, Z_STRVAL_P(key), Z_STRLEN_P(key), '_');

	PHALCON_CONCAT_VVS(&path, &annotations_dir, &virtual_key, ".php");
	
	smart_str_appends(&exp, "<?php return ");
	php_var_export_ex(data, 0, &exp);
	smart_str_appendc(&exp, ';');
	smart_str_0(&exp);

	ZVAL_STR(&php_export, exp.s);

	phalcon_file_put_contents(&status, &path, &php_export);
	if (PHALCON_IS_FALSE(&status)) {
		PHALCON_THROW_EXCEPTION_STRW(phalcon_annotations_exception_ce, "Annotations directory cannot be written");
		return;
	}
}
开发者ID:dreamsxin,项目名称:cphalcon7,代码行数:36,代码来源:files.c


示例13: phalcon_var_export_ex

/**
 * var_export returns php variables without using the PHP userland
 */
void phalcon_var_export_ex(zval *return_value, zval *var) {

    smart_str buf = { 0 };

    php_var_export_ex(var, 1, &buf);
    smart_str_0(&buf);
    ZVAL_STR(return_value, buf.s);
}
开发者ID:Myleft,项目名称:cphalcon7,代码行数:11,代码来源:variables.c


示例14: yaf_route_simple_assemble

/** {{{ zend_string * yaf_route_simple_assemble(zval *info, zval *query)
 */
zend_string * yaf_route_simple_assemble(yaf_route_t *this_ptr, zval *info, zval *query) {
	smart_str tvalue = {0};
	zval *nmodule, *ncontroller, *naction;

	smart_str_appendc(&tvalue, '?');

	nmodule = zend_read_property(yaf_route_simple_ce,
			this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_MODULE), 1, NULL);
	ncontroller = zend_read_property(yaf_route_simple_ce,
			this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_CONTROLLER), 1, NULL);
	naction = zend_read_property(yaf_route_simple_ce,
			this_ptr, ZEND_STRL(YAF_ROUTE_SIMPLE_VAR_NAME_ACTION), 1, NULL);

	do {
		zval *tmp;

		if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_MOUDLE_FORMAT))) != NULL) {
			smart_str_appendl(&tvalue, Z_STRVAL_P(nmodule), Z_STRLEN_P(nmodule));
			smart_str_appendc(&tvalue, '=');
			smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
			smart_str_appendc(&tvalue, '&');
		} 

		if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_CONTROLLER_FORMAT))) == NULL) {
			yaf_trigger_error(YAF_ERR_TYPE_ERROR, "%s", "You need to specify the controller by ':c'");
			break;
		}

		smart_str_appendl(&tvalue, Z_STRVAL_P(ncontroller), Z_STRLEN_P(ncontroller));
		smart_str_appendc(&tvalue, '=');
		smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
		smart_str_appendc(&tvalue, '&');

		if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), ZEND_STRL(YAF_ROUTE_ASSEMBLE_ACTION_FORMAT))) == NULL) {
			yaf_trigger_error(YAF_ERR_TYPE_ERROR, "%s", "You need to specify the action by ':a'");
			break;
		}

		smart_str_appendl(&tvalue, Z_STRVAL_P(naction), Z_STRLEN_P(naction));
		smart_str_appendc(&tvalue, '=');
		smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));

		if (query && IS_ARRAY == Z_TYPE_P(query)) {
			zend_string *key;

            ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(query), key, tmp) {
				if (IS_STRING == Z_TYPE_P(tmp) && key) {
					smart_str_appendc(&tvalue, '&');
					smart_str_appendl(&tvalue, ZSTR_VAL(key), ZSTR_LEN(key));
					smart_str_appendc(&tvalue, '=');
					smart_str_appendl(&tvalue, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
				}
			} ZEND_HASH_FOREACH_END();
		}

		smart_str_0(&tvalue);
		return tvalue.s;
	} while (0);
开发者ID:recoye,项目名称:php-yaf,代码行数:60,代码来源:yaf_route_simple.c


示例15: ONPHP_METHOD

ONPHP_METHOD(Joiner, toDialectString)
{
	zval
		*dialect,
		*from = ONPHP_READ_PROPERTY(getThis(), "from"),
		*table;
	zend_class_entry **cep;
	smart_str string = {0};
	unsigned int i = 0, count = zend_hash_num_elements(Z_ARRVAL_P(from));
	
	if (!count) {
		RETURN_NULL();
	} else {
		smart_str_appendl(&string, " FROM ", 6);
	}
	
	ONPHP_GET_ARGS("O", &dialect, onphp_ce_Dialect);
	
	ONPHP_FIND_FOREIGN_CLASS("SelectQuery", cep);
	
	for (i = 0; i < count; ++i) {
		zval *out;
		
		ONPHP_ARRAY_GET(from, i, table);
		
		if (i == 0) {
			/* nop */
		} else {
			if (ONPHP_INSTANCEOF(from, FromTable)) {
				zval *name;
				
				ONPHP_CALL_METHOD_0(table, "gettable", &name);
				
				if (instanceof_function(Z_OBJCE_P(table), *cep TSRMLS_CC)) {
					smart_str_appendl(&string, ", ", 2);
				} else {
					smart_str_appendc(&string, ' ');
				}
				
				zval_ptr_dtor(&name);
			} else {
				smart_str_appendc(&string, ' ');
			}
		}
		
		ONPHP_CALL_METHOD_1(table, "todialectstring", &out, dialect);
		
		onphp_append_zval_to_smart_string(&string, out);
		
		zval_ptr_dtor(&out);
	}
	
	smart_str_0(&string);
	
	RETURN_STRINGL(string.c, string.len, 0);
}
开发者ID:suquant,项目名称:soloweb-onphp,代码行数:56,代码来源:Joiner.c


示例16: mic_time

void mic_time(smart_str *buf)
{
    struct timeval now;

    timerclear(&now);
    gettimeofday(&now, NULL);

    smart_str_append_long(buf,(long)time(NULL));
    smart_str_appendc(buf,'.');
    smart_str_append_long(buf,(long)now.tv_usec / 1000);

    smart_str_0(buf);
}
开发者ID:lovelock,项目名称:SeasLog,代码行数:13,代码来源:Datetime.c


示例17: ONPHP_METHOD

ONPHP_METHOD(DBField, toDialectString)
{
	smart_str string = {0};
	zval *table, *field, *dialect, *cast, *quoted;
	
	ONPHP_GET_ARGS("O", &dialect, onphp_ce_Dialect);
	
	table = ONPHP_READ_PROPERTY(getThis(), "table");
	field = ONPHP_READ_PROPERTY(getThis(), "field");
	cast = ONPHP_READ_PROPERTY(getThis(), "cast");
	
	// either null or instance of DialectString
	if (Z_TYPE_P(table) == IS_OBJECT) {
		zval *tmp;
		
		ONPHP_CALL_METHOD_1(table, "todialectstring", &tmp, dialect);
		
		onphp_append_zval_to_smart_string(&string, tmp);
		zval_ptr_dtor(&tmp);
		smart_str_appendc(&string, '.');
	}
	
	ONPHP_CALL_METHOD_1(dialect, "quotefield", &quoted, field);
	
	onphp_append_zval_to_smart_string(&string, quoted);
	
	zval_ptr_dtor(&quoted);
	
	smart_str_0(&string);
	
	if (Z_STRLEN_P(cast)) {
		zval *tmp, *out;
		
		ALLOC_INIT_ZVAL(tmp);
		
		ZVAL_STRINGL(tmp, string.c, string.len, 1);
		
		ONPHP_CALL_METHOD_2_NORET(dialect, "tocasted", &out, tmp, cast);
		
		ZVAL_FREE(tmp);
		smart_str_free(&string);
		
		if (EG(exception)) {
			return;
		}
		
		RETURN_ZVAL(out, 1, 1);
	}
	
	RETURN_STRINGL(string.c, string.len, 0);
}
开发者ID:suquant,项目名称:soloweb-onphp,代码行数:51,代码来源:DBField.c


示例18: to_indexed

/** {{{ to_indexed
*/
static zval * to_indexed(zval * keys, char * query, int len) {
	zval * sql = NULL;
	char   ch  = 0;
	int    i   = 0;
	smart_str skey       = {NULL, 0, 0};
	smart_str ssql       = {NULL, 0, 0};

	for(i=0; i<len; i++) {
		ch = *(query + i);
		if (ch == ':') {
			for (i++; i < len; i++) {
				ch = *(query + i);
				/* [a-zA-Z0-9_]+ */
				if ((ch > 96 && ch < 123)
						|| (ch > 64 && ch < 91)
						|| (ch > 47 && ch < 58)
						|| ch == 95
				   ) {
					smart_str_appendc(&skey, ch);
				} else {
					break;
				}
			}
			smart_str_appendc(&ssql, '?');
			smart_str_appendc(&ssql, ch);

			smart_str_0(&skey);

			if (ssql.len) {
				add_next_index_stringl(keys, skey.c, skey.len, 1);
			}
			smart_str_free(&skey);
		} else {
			smart_str_appendc(&ssql, ch);
		}
	}

	MAKE_STD_ZVAL(sql);
	if (ssql.len) {
		ZVAL_STRINGL(sql, ssql.c, ssql.len, 1);
	}else{
		ZVAL_STRINGL(sql, "", 0, 1);
	}

	smart_str_free(&skey);
	smart_str_free(&ssql);

	return sql;
}
开发者ID:eixom,项目名称:zoeeyphp,代码行数:51,代码来源:recorder.c


示例19: PHP_FUNCTION

/* {{{ proto mixed hstore_encode(array hstore)
   Decodes the hStore representation into a PHP value */
static PHP_FUNCTION(hstore_encode)
{
    zval *array, *value;
	zend_ulong num_idx;
    zend_string *str_idx;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
        return;
    }

    smart_str buf = {};
    smart_str_alloc(&buf, 2048, 0);

    zend_bool need_comma = 0;

    ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, value) {
        if (need_comma) {
            smart_str_appendl(&buf, ", ", 2);
        } else {
            need_comma = 1;
        }

        smart_str_appendc(&buf, '"');

        if (str_idx) {
            escape_string(&buf, str_idx);
        } else {
            smart_str_append_long(&buf, (long) num_idx);
        }

        smart_str_appendl(&buf, "\"=>", 3);

        if (Z_TYPE_P(value) == IS_NULL) {
            smart_str_appendl(&buf, "NULL", 4);
        } else {
            convert_to_string_ex(value);

            smart_str_appendc(&buf, '"');
            zend_string *str = zval_get_string(value);
            escape_string(&buf, str);
            zend_string_release(str);
            smart_str_appendc(&buf, '"');
        }
    } ZEND_HASH_FOREACH_END();

	smart_str_0(&buf); /* copy? */
	ZVAL_NEW_STR(return_value, buf.s);
}
开发者ID:intaro,项目名称:hstore-extension,代码行数:50,代码来源:php_hstore.c


示例20: smart_str_appends

static zend_string *ast_version_info() {
	smart_str str = {0};
	size_t i;

	smart_str_appends(&str, "Current version is ");
	smart_str_append_long(&str, AST_CURRENT_VERSION);
	smart_str_appends(&str, ". All versions (including experimental): {");
	for (i = 0; i < versions_count; ++i) {
		if (i != 0) smart_str_appends(&str, ", ");
		smart_str_append_long(&str, versions[i]);
	}
	smart_str_appends(&str, "}");

	smart_str_0(&str);
	return str.s;
}
开发者ID:billschaller,项目名称:php-ast,代码行数:16,代码来源:ast.c



注:本文中的smart_str_0函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ smart_str_appendl函数代码示例发布时间:2022-05-30
下一篇:
C++ smalloc函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap