Example #1
0
/**
 * Return a collection with an order-operator added.
 *
 * @param coll  the original collection
 * @param value an ordering string, optionally starting with "-" (for
 *              descending ordering), followed by a string "id", "random"
 *              or a key identifying a  property, such as "artist" or "album".
 *              Or it can be a dict containing the attributes to set.
 * @return coll with order-operators added
 */
xmmsv_t *
xmmsv_coll_add_order_operator (xmmsv_t *coll, xmmsv_t *value)
{
	value = xmmsv_coll_normalize_order_arguments (value);
	if (value != NULL) {
		xmmsv_t *ordered;

		ordered = xmmsv_new_coll (XMMS_COLLECTION_TYPE_ORDER);
		xmmsv_coll_add_operand (ordered, coll);
		xmmsv_coll_attributes_set (ordered, value);

		xmmsv_unref (value);

		return ordered;
	}

	return xmmsv_ref (coll);
}
Example #2
0
static xmmsv_t *
duplicate_coll_value (xmmsv_t *val)
{
	xmmsv_t *dup_val, *attributes, *operands, *idlist, *copy;

	dup_val = xmmsv_new_coll (xmmsv_coll_get_type (val));

	attributes = xmmsv_coll_attributes_get (val);
	copy = xmmsv_copy (attributes);
	xmmsv_coll_attributes_set (dup_val, copy);
	xmmsv_unref (copy);

	operands = xmmsv_coll_operands_get (val);
	copy = xmmsv_copy (operands);
	xmmsv_coll_operands_set (dup_val, copy);
	xmmsv_unref (copy);

	idlist = xmmsv_coll_idlist_get (val);
	copy = xmmsv_copy (idlist);
	xmmsv_coll_idlist_set (dup_val, copy);
	xmmsv_unref (copy);

	return dup_val;
}