예제 #1
0
struct tnt_iter *tnt_iter_reply(struct tnt_iter *i, struct tnt_stream *s) {
	i = tnt_iter_init(i);
	if (i == NULL)
		return NULL;
	i->type = TNT_ITER_REPLY;
	i->next = tnt_iter_reply_next;
	i->rewind = NULL;
	i->free = tnt_iter_reply_free;
	struct tnt_iter_reply *ir = TNT_IREPLY(i);
	ir->s = s;
	tnt_reply_init(&ir->r);
	return i;
}
예제 #2
0
/*
 * tnt_iter_request()
 *
 * initialize tuple request iterator;
 * create and initialize request iterator;
 *
 * i - tuple request iterator pointer, maybe NULL
 * s - stream pointer
 * 
 * if stream iterator pointer is NULL, then new stream
 * iterator will be created. 
 *
 * returns stream iterator pointer, or NULL on error.
*/
struct tnt_iter *tnt_iter_request(struct tnt_iter *i, struct tnt_stream *s) {
	i = tnt_iter_init(i);
	if (i == NULL)
		return NULL;
	i->type = TNT_ITER_REQUEST;
	i->next = tnt_iter_request_next;
	i->rewind = NULL;
	i->free = tnt_iter_request_free;
	struct tnt_iter_request *ir = TNT_IREQUEST(i);
	ir->s = s;
	tnt_request_init(&ir->r);
	return i;
}
예제 #3
0
/*
 * tnt_iter_list()
 *
 * initialize tuple list iterator;
 * create and initialize tuple list iterator;
 *
 * i - tuple list iterator pointer, maybe NULL
 * t - tuple list pointer
 * 
 * if tuple list iterator pointer is NULL, then new tuple list
 * iterator will be created. 
 *
 * returns tuple list iterator pointer, or NULL on error.
*/
struct tnt_iter*
tnt_iter_list(struct tnt_iter *i, struct tnt_list *l)
{
	i = tnt_iter_init(i);
	if (i == NULL)
		return NULL;
	i->type = TNT_ITER_LIST;
	i->next = tnt_iter_list_next;
	i->rewind = tnt_iter_list_rewind;
	i->free = NULL;
	struct tnt_iter_list *il = TNT_ILIST(i);
	il->l = l;
	return i;
}
예제 #4
0
/*
 * tnt_iter()
 *
 * initialize tuple field iterator;
 * create and initialize tuple field iterator;
 *
 * i - tuple field iterator pointer, maybe NULL
 * t - tuple pointer
 * 
 * if tuple field iterator pointer is NULL, then new tuple iterator will be created. 
 *
 * returns tuple iterator pointer, or NULL on error.
*/
struct tnt_iter*
tnt_iter(struct tnt_iter *i, struct tnt_tuple *t)
{
	i = tnt_iter_init(i);
	if (i == NULL)
		return NULL;
	i->type = TNT_ITER_FIELD;
	i->next = tnt_iter_field_next;
	i->rewind = tnt_iter_field_rewind;
	i->free = NULL;
	struct tnt_iter_field *ip = TNT_IFIELD(i);
	ip->tu = t;
	return i;
}
예제 #5
0
struct tnt_iter *
tnt_iter_array(struct tnt_iter *i, const char *data, size_t size)
{
	const char *tmp_data = data;
	if (mp_check(&tmp_data, data + size) != 0)
		return NULL;
	if (!data || !size || mp_typeof(*data) != MP_ARRAY)
		return NULL;
	i = tnt_iter_init(i);
	if (i == NULL)
		return NULL;
	i->type = TNT_ITER_ARRAY;
	i->next = tnt_iter_array_next;
	i->rewind = tnt_iter_array_rewind;
	i->free = NULL;
	struct tnt_iter_array *itr = TNT_IARRAY(i);
	itr->data = data;
	itr->first_elem = data;
	itr->elem_count = mp_decode_array(&itr->first_elem);
	itr->cur_index = -1;
	return i;
}
예제 #6
0
struct tnt_iter *
tnt_iter_map(struct tnt_iter *i, const char *data, size_t size)
{
	const char *tmp_data = data;
	if (mp_check(&tmp_data, data + size) != 0)
		return NULL;
	if (!data || !size || mp_typeof(*data) != MP_MAP)
		return NULL;
	i = tnt_iter_init(i);
	if (i == NULL)
		return NULL;
	i->type = TNT_ITER_MAP;
	i->next = tnt_iter_map_next;
	i->rewind = tnt_iter_map_rewind;
	i->free = NULL;
	struct tnt_iter_map *itr = TNT_IMAP(i);
	itr->data = data;
	itr->first_key = data;
	itr->pair_count = mp_decode_map(&itr->first_key);
	itr->cur_index = -1;
	return i;
}